Skip to content
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

Add asymmetric JWT signing #16010

Merged
merged 16 commits into from
Jun 17, 2021
Merged
Changes from 1 commit
Commits
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
Fixed name.
KN4CK3R committed Jun 16, 2021
commit 032c0ab09be2b2a793c408e4e364fd2cbd8ca0db
16 changes: 8 additions & 8 deletions modules/auth/oauth2/jwtsigningkey.go
Original file line number Diff line number Diff line change
@@ -48,35 +48,35 @@ type JWTSigningKey interface {
PreProcessToken(*jwt.Token)
}

type hmacSingingKey struct {
type hmacSigningKey struct {
signingMethod jwt.SigningMethod
secret []byte
}

func (key hmacSingingKey) IsSymmetric() bool {
func (key hmacSigningKey) IsSymmetric() bool {
return true
}

func (key hmacSingingKey) SigningMethod() jwt.SigningMethod {
func (key hmacSigningKey) SigningMethod() jwt.SigningMethod {
return key.signingMethod
}

func (key hmacSingingKey) SignKey() interface{} {
func (key hmacSigningKey) SignKey() interface{} {
return key.secret
}

func (key hmacSingingKey) VerifyKey() interface{} {
func (key hmacSigningKey) VerifyKey() interface{} {
return key.secret
}

func (key hmacSingingKey) ToJWK() (map[string]string, error) {
func (key hmacSigningKey) ToJWK() (map[string]string, error) {
return map[string]string{
"kty": "oct",
"alg": key.SigningMethod().Alg(),
}, nil
}

func (key hmacSingingKey) PreProcessToken(*jwt.Token) {}
func (key hmacSigningKey) PreProcessToken(*jwt.Token) {}

type rsaSingingKey struct {
signingMethod jwt.SigningMethod
@@ -240,7 +240,7 @@ func CreateJWTSingingKey(algorithm string, key interface{}) (JWTSigningKey, erro
if !ok {
return nil, jwt.ErrInvalidKeyType
}
return hmacSingingKey{signingMethod, secret}, nil
return hmacSigningKey{signingMethod, secret}, nil
}
}