Skip to content

Commit

Permalink
fix: add ability to specify amr values natively in id_token payload (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bernard-wagner authored Mar 17, 2020
1 parent 4104135 commit f99bb80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions token/jwt/claims_id_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type IDTokenClaims struct {
AuthTime time.Time
AccessTokenHash string
AuthenticationContextClassReference string
AuthenticationMethodsReference string
CodeHash string
Extra map[string]interface{}
}
Expand Down Expand Up @@ -82,6 +83,10 @@ func (c *IDTokenClaims) ToMap() map[string]interface{} {
ret["acr"] = c.AuthenticationContextClassReference
}

if len(c.AuthenticationMethodsReference) > 0 {
ret["amr"] = c.AuthenticationMethodsReference
}

ret["iat"] = float64(c.IssuedAt.Unix())
ret["exp"] = float64(c.ExpiresAt.Unix())
ret["rat"] = float64(c.RequestedAt.Unix())
Expand Down
2 changes: 2 additions & 0 deletions token/jwt/claims_id_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var idTokenClaims = &IDTokenClaims{
AccessTokenHash: "foobar",
CodeHash: "barfoo",
AuthenticationContextClassReference: "acr",
AuthenticationMethodsReference: "amr",
Extra: map[string]interface{}{
"foo": "bar",
"baz": "bar",
Expand Down Expand Up @@ -73,5 +74,6 @@ func TestIDTokenClaimsToMap(t *testing.T) {
"c_hash": idTokenClaims.CodeHash,
"auth_time": idTokenClaims.AuthTime.Unix(),
"acr": idTokenClaims.AuthenticationContextClassReference,
"amr": idTokenClaims.AuthenticationMethodsReference,
}, idTokenClaims.ToMap())
}

0 comments on commit f99bb80

Please sign in to comment.