Skip to content

feat: add jwt pkg #14928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b5d939e
feat: add jwt pkg
sreya Oct 1, 2024
6025c7b
update make gen
sreya Oct 2, 2024
8b235be
Refactor JWT package to modularize key functions
sreya Oct 2, 2024
843de38
Remove unused JWT test file from repository
sreya Oct 2, 2024
099544f
Refactor JWT key functions and add tests
sreya Oct 2, 2024
acc4db3
Rename VerifyFn to ParseFn in JWT tests
sreya Oct 2, 2024
b4973a8
Remove unused JWE test file
sreya Oct 2, 2024
f7d7c95
Refactor JWT test structs to use public field names
sreya Oct 2, 2024
3ba8ad3
Refactor JWT to use new crypto key management system
sreya Oct 3, 2024
73c902c
Refactor JWT package for improved modularity and clarity
sreya Oct 3, 2024
e348a7a
mv dir
sreya Oct 3, 2024
c7489b4
update references
sreya Oct 3, 2024
d890ea2
refactor interfaces
sreya Oct 3, 2024
67ccd5c
refactor dbkeycache
sreya Oct 3, 2024
1a81c7a
Refactor JWT utility options for flexibility
sreya Oct 3, 2024
e529c4a
Enhance key generation and JWT error messages
sreya Oct 3, 2024
437e587
Update cryptographic key length requirements
sreya Oct 3, 2024
54214e2
Refactor key provider interfaces in JWT utilities
sreya Oct 3, 2024
93603a2
Refactor dbCache to remove feature validation
sreya Oct 3, 2024
e654a65
Refactor cryptokeys and jwtutils interfaces and logic
sreya Oct 3, 2024
0efabfd
Remove unused test code and mock cleanup
sreya Oct 3, 2024
e065356
Remove cryptokeys keycachemock from Makefile
sreya Oct 3, 2024
938bdda
Add feature validation to dbCache key methods
sreya Oct 3, 2024
48b1b3b
fmt
sreya Oct 3, 2024
1dd2205
Add initialization comment for db key cache timer
sreya Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor JWT key functions and add tests
- Renamed key functions to clarify their use.
- Removed unused `featureHeaderKey`.
- Added comprehensive tests for JWT signing and verifying.
  • Loading branch information
sreya committed Oct 2, 2024
commit 099544f9222fbd7d1ea735b23e8edb059ed4628d
1 change: 0 additions & 1 deletion coderd/jwt/jws.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

const (
defaultSigningAlgo = jose.HS512
featureHeaderKey = "feat"
keyIDHeaderKey = "kid"
)

Expand Down
8 changes: 4 additions & 4 deletions coderd/jwt/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ type Claims interface {
// SecuringKeyFn returns a key for signing or encrypting.
type SecuringKeyFn func() (id string, key interface{}, err error)

// KeycacheSecure returns the appropriate key for signing or encrypting.
func KeycacheSecure(ctx context.Context, keys cryptokeys.Keycache) SecuringKeyFn {
// SecuringKeyFromCache returns the appropriate key for signing or encrypting.
func SecuringKeyFromCache(ctx context.Context, keys cryptokeys.Keycache) SecuringKeyFn {
return func() (id string, key interface{}, err error) {
signing, err := keys.Signing(ctx)
if err != nil {
Expand All @@ -39,8 +39,8 @@ func KeycacheSecure(ctx context.Context, keys cryptokeys.Keycache) SecuringKeyFn
// ParseKeyFunc returns a key for verifying or decrypting a token.
type ParseKeyFunc func(jose.Header) (interface{}, error)

// KeycacheParse returns the appropriate key to decrypt or verify a token.
func KeycacheParse(ctx context.Context, keys cryptokeys.Keycache) ParseKeyFunc {
// ParseKeyFromCache returns the appropriate key to decrypt or verify a token.
func ParseKeyFromCache(ctx context.Context, keys cryptokeys.Keycache) ParseKeyFunc {
return func(header jose.Header) (interface{}, error) {
sequenceStr := header.KeyID
if sequenceStr == "" {
Expand Down
Loading
Loading