OIDC: add support for account claim maps (#1186)

This commit is contained in:
Jim authored and GitHub committed 2021-05-04 08:41:04 -04:00
1 parent 4ae5003763
commit 2437cdcc8d
28 files changed
+1456 -200

No files matched your search

@@ -38,6 +38,14 @@ func Test_upsertAccount(t *testing.T) {
WithApiUrl(TestConvertToUrls(t, "https://alice-active-priv.com/callback")[0]),
WithSigningAlgs(RS256))
amWithMapping := TestAuthMethod(
t,
conn, databaseWrapper, org.PublicId, ActivePrivateState,
"alice_rp", "fido",
WithAccountClaimMap(map[string]AccountToClaim{"oid": ToSubClaim}),
WithApiUrl(TestConvertToUrls(t, "https://alice-active-priv.com/callback")[0]),
WithSigningAlgs(RS256))
tests := []struct {
name string
am *AuthMethod
@@ -84,6 +92,17 @@ func Test_upsertAccount(t *testing.T) {
FullName: "alice eve-smith",
}},
},
{
name: "success-map-idTk",
am: amWithMapping,
idClaims: map[string]interface{}{"iss": "https://alice-active-priv.com", "sub": "success-defaults", "oid": "success-map"},
atClaims: map[string]interface{}{},
wantAcct: &Account{Account: &store.Account{
AuthMethodId: amWithMapping.PublicId,
Issuer: "https://alice-active-priv.com",
Subject: "success-map",
}},
},
{
name: "non-existent-auth-method-scope-id",
am: func() *AuthMethod { cp := amActivePriv.Clone(); cp.ScopeId = "non-existent-scope-id"; return cp }(),
@@ -130,7 +149,7 @@ func Test_upsertAccount(t *testing.T) {
idClaims: map[string]interface{}{"iss": "https://alice.com"},
atClaims: map[string]interface{}{},
wantErrMatch: errors.T(errors.Unknown),
wantErrContains: "subject is not present",
wantErrContains: "to account subject and it is not present in ID Token",
},
{
name: "missing-id-token-claims",