feat(oidc): OIDC Prompt (#4053)
Boundary OIDC method does not currently support passing in prompts during authentication. This change adds the capability of passing OIDC prompts. Prompts are optional OIDC parameters that determine the behaviour of the authentication server: https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest ## Changes - New `auth_oidc_prompt` table which contains all the prompts for OIDC auth method - New `auth_oidc_prompt_enm` table which contains possible enum values for a prompt - Currently supported: - `none`: The Authorization Server MUST NOT display any authentication or consent user interface pages - `login`: The Authorization Server SHOULD prompt the End-User for reauthentication - `consent`: The Authorization Server SHOULD prompt the End-User for consent before returning information to the Client - `select_account`: The Authorization Server SHOULD prompt the End-User to select a user account - `oidc_auth_method_with_value_obj` view has been updated to return `prompt` value - Add `prompt` option for OIDC auth method CLI create and update - Pass configured prompt during OIDC authentication - Add `prompt` API validation for create and update
This commit is contained in:
1 parent
b6df5693b5
commit
8b8d2822df
31 files changed
+1668
-345
No files matched your search
@@ -107,6 +107,12 @@ func NewAuthMethod(ctx context.Context, scopeId string, clientId string, clientS
|
||||
a.SigningAlgs = append(a.SigningAlgs, string(alg))
|
||||
}
|
||||
}
|
||||
if len(opts.withPrompts) > 0 {
|
||||
a.Prompts = make([]string, 0, len(opts.withPrompts))
|
||||
for _, prompts := range opts.withPrompts {
|
||||
a.Prompts = append(a.Prompts, string(prompts))
|
||||
}
|
||||
}
|
||||
if len(opts.withAccountClaimMap) > 0 {
|
||||
a.AccountClaimMaps = make([]string, 0, len(opts.withAccountClaimMap))
|
||||
for k, v := range opts.withAccountClaimMap {
|
||||
@@ -282,6 +288,7 @@ type convertedValues struct {
|
||||
Certs []any
|
||||
ClaimsScopes []any
|
||||
AccountClaimMaps []any
|
||||
Prompts []any
|
||||
}
|
||||
|
||||
// convertValueObjects converts the embedded value objects. It will return an
|
||||
@@ -292,7 +299,7 @@ func (am *AuthMethod) convertValueObjects(ctx context.Context) (*convertedValues
|
||||
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id")
|
||||
}
|
||||
var err error
|
||||
var addAlgs, addAuds, addCerts, addScopes, addAccountClaimMaps []any
|
||||
var addAlgs, addAuds, addCerts, addScopes, addAccountClaimMaps, addPrompts []any
|
||||
if addAlgs, err = am.convertSigningAlgs(ctx); err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
@@ -308,12 +315,16 @@ func (am *AuthMethod) convertValueObjects(ctx context.Context) (*convertedValues
|
||||
if addAccountClaimMaps, err = am.convertAccountClaimMaps(ctx); err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
if addPrompts, err = am.convertPrompts(ctx); err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
return &convertedValues{
|
||||
Algs: addAlgs,
|
||||
Auds: addAuds,
|
||||
Certs: addCerts,
|
||||
ClaimsScopes: addScopes,
|
||||
AccountClaimMaps: addAccountClaimMaps,
|
||||
Prompts: addPrompts,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -458,3 +469,22 @@ func ParseAccountClaimMaps(ctx context.Context, m ...string) ([]ClaimMap, error)
|
||||
}
|
||||
return claimMap, nil
|
||||
}
|
||||
|
||||
// convertPrompts converts the embedded prompts from []string
|
||||
// to []interface{} where each slice element is a *Prompt. It will return an
|
||||
// error if the AuthMethod's public id is not set.
|
||||
func (am *AuthMethod) convertPrompts(ctx context.Context) ([]any, error) {
|
||||
const op = "oidc.(AuthMethod).convertPrompts"
|
||||
if am.PublicId == "" {
|
||||
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id")
|
||||
}
|
||||
newInterfaces := make([]any, 0, len(am.Prompts))
|
||||
for _, a := range am.Prompts {
|
||||
obj, err := NewPrompt(ctx, am.PublicId, PromptParam(a))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
newInterfaces = append(newInterfaces, obj)
|
||||
}
|
||||
return newInterfaces, nil
|
||||
}
|
||||
Reference in new issue
Block a user