Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion lib/jwt/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ func (k *Key) Sign(p SignParams) (string, error) {
Traits: p.Traits,
}

return k.sign(claims, nil)
// RFC 7517 requires that `kid` be present in the JWT header if there are multiple keys in the JWKS.
// We ignore the error because go-jose omits the kid if it is empty.
kid, _ := KeyID(k.config.PublicKey)
return k.sign(claims, (&jose.SignerOptions{}).WithHeader("kid", kid))
}

// awsOIDCCustomClaims defines the require claims for the JWT token used in AWS OIDC Integration.
Expand Down
7 changes: 7 additions & 0 deletions lib/jwt/jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ func TestSignAndVerify(t *testing.T) {
})
require.NoError(t, err)

//decode the signed token
decodedToken, err := josejwt.ParseSigned(token)
require.NoError(t, err)

// verify that the kid header is present, and not empty
require.NotEmpty(t, decodedToken.Headers[0].KeyID)

// Verify that the token can be validated and values match expected values.
claims, err := key.Verify(VerifyParams{
Username: "foo@example.com",
Expand Down