feat(oidc-prompts): Add Validation for Prompts (#4130)

Add validation to prevent "none" from being combined with multiple prompts.

- Valid `["none"]`
- Invalid `["none", "select_account"]`
- Valid `["consent", "select_account"]`
This commit is contained in:
Elim Tsiagbey authored and GitHub committed 2023-12-08 09:51:54 -05:00
1 parent c70a6ff6ba
commit 053421600d
4 files changed
+86 -9

No files matched your search

@@ -1454,6 +1454,25 @@ func TestCreate(t *testing.T) {
},
},
},
{
name: "Create OIDC AuthMethod with none and other prompts",
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
ScopeId: o.GetPublicId(),
Type: oidc.Subtype.String(),
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
Issuer: wrapperspb.String("https://example.discovery.url:4821/.well-known/openid-configuration/"),
ClientId: wrapperspb.String("exampleclientid"),
ClientSecret: wrapperspb.String("secret"),
ApiUrlPrefix: wrapperspb.String("https://callback.prefix:9281/path"),
Prompts: []string{string(oidc.None), string(oidc.SelectAccount)},
},
},
}},
idPrefix: globals.OidcAuthMethodPrefix + "_",
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
errContains: "includes \\\"none\\\" with other values",
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {