Add validated ID token claims to the oidctypes.Token structure.

This is just a more convenient copy of these values which are already stored inside the ID token. This will save us from having to pass them around seprately or re-parse them later.

Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
Matt Moyer 2020-12-04 15:15:33 -06:00
parent 7b088d611d
commit 014d760f3d
No known key found for this signature in database
GPG Key ID: EAE88AD172C5AE2D
3 changed files with 15 additions and 0 deletions

View File

@ -38,6 +38,13 @@ var validSession = sessionCache{
IDToken: &oidctypes.IDToken{ IDToken: &oidctypes.IDToken{
Token: "test-id-token", Token: "test-id-token",
Expiry: metav1.NewTime(time.Date(2020, 10, 20, 19, 42, 07, 0, time.UTC).Local()), Expiry: metav1.NewTime(time.Date(2020, 10, 20, 19, 42, 07, 0, time.UTC).Local()),
Claims: map[string]interface{}{
"foo": "bar",
"nested": map[string]interface{}{
"key1": "value1",
"key2": "value2",
},
},
}, },
RefreshToken: &oidctypes.RefreshToken{ RefreshToken: &oidctypes.RefreshToken{
Token: "test-refresh-token", Token: "test-refresh-token",

View File

@ -20,5 +20,10 @@ sessions:
id: id:
expiryTimestamp: "2020-10-20T19:42:07Z" expiryTimestamp: "2020-10-20T19:42:07Z"
token: test-id-token token: test-id-token
claims:
foo: bar
nested:
key1: value1
key2: value2
refresh: refresh:
token: test-refresh-token token: test-refresh-token

View File

@ -31,6 +31,9 @@ type IDToken struct {
// Expiry is the optional expiration time of the ID token. // Expiry is the optional expiration time of the ID token.
Expiry v1.Time `json:"expiryTimestamp,omitempty"` Expiry v1.Time `json:"expiryTimestamp,omitempty"`
// Claims are the claims expressed by the Token.
Claims map[string]interface{} `json:"claims,omitempty"`
} }
// Token contains the elements of an OIDC session. // Token contains the elements of an OIDC session.