Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: configuration to allow cross-platform devices for passkeys #4047

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions driver/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,14 @@ const (
ViperKeyIgnoreNetworkErrors = "selfservice.methods.password.config.ignore_network_errors"
ViperKeyTOTPIssuer = "selfservice.methods.totp.config.issuer"
ViperKeyOIDCBaseRedirectURL = "selfservice.methods.oidc.config.base_redirect_uri"
ViperKeyWebAuthnAttachmentModality = "selfservice.methods.webauthn.config.attachment.modality"
ViperKeyWebAuthnRPDisplayName = "selfservice.methods.webauthn.config.rp.display_name"
ViperKeyWebAuthnRPID = "selfservice.methods.webauthn.config.rp.id"
ViperKeyWebAuthnRPOrigin = "selfservice.methods.webauthn.config.rp.origin"
ViperKeyWebAuthnRPOrigins = "selfservice.methods.webauthn.config.rp.origins"
ViperKeyWebAuthnPasswordless = "selfservice.methods.webauthn.config.passwordless"
ViperKeyPasskeyEnabled = "selfservice.methods.passkey.enabled"
ViperKeyPasskeyAttachmentModality = "selfservice.methods.passkey.config.attachment.modality"
ViperKeyPasskeyRPDisplayName = "selfservice.methods.passkey.config.rp.display_name"
ViperKeyPasskeyRPID = "selfservice.methods.passkey.config.rp.id"
ViperKeyPasskeyRPOrigins = "selfservice.methods.passkey.config.rp.origins"
Expand Down Expand Up @@ -1474,12 +1476,23 @@ func (p *Config) WebAuthnConfig(ctx context.Context) *webauthn.Config {
id := p.GetProvider(ctx).String(ViperKeyWebAuthnRPID)
origin := p.GetProvider(ctx).String(ViperKeyWebAuthnRPOrigin)
origins := p.GetProvider(ctx).StringsF(ViperKeyWebAuthnRPOrigins, []string{stringsx.Coalesce(origin, scheme+"://"+id)})
authenticatorModalityValue := p.GetProvider(ctx).String(ViperKeyWebAuthnAttachmentModality)
var authenticatorModality protocol.AuthenticatorAttachment
switch authenticatorModalityValue {
case "platform":
authenticatorModality = protocol.Platform
case "cross-platform":
authenticatorModality = protocol.CrossPlatform
default:
authenticatorModality = ""
}
return &webauthn.Config{
RPDisplayName: p.GetProvider(ctx).String(ViperKeyWebAuthnRPDisplayName),
RPID: id,
RPOrigins: origins,
AuthenticatorSelection: protocol.AuthenticatorSelection{
UserVerification: protocol.VerificationDiscouraged,
AuthenticatorAttachment: authenticatorModality,
UserVerification: protocol.VerificationDiscouraged,
},
EncodeUserIDAsString: false,
}
Expand All @@ -1489,12 +1502,22 @@ func (p *Config) PasskeyConfig(ctx context.Context) *webauthn.Config {
scheme := p.SelfPublicURL(ctx).Scheme
id := p.GetProvider(ctx).String(ViperKeyPasskeyRPID)
origins := p.GetProvider(ctx).StringsF(ViperKeyPasskeyRPOrigins, []string{scheme + "://" + id})
authenticatorModalityValue := p.GetProvider(ctx).String(ViperKeyPasskeyAttachmentModality)
var authenticatorModality protocol.AuthenticatorAttachment
switch authenticatorModalityValue {
case "":
authenticatorModality = ""
case "cross-platform":
authenticatorModality = protocol.CrossPlatform
default:
authenticatorModality = protocol.Platform
}
return &webauthn.Config{
RPDisplayName: p.GetProvider(ctx).String(ViperKeyPasskeyRPDisplayName),
RPID: id,
RPOrigins: origins,
AuthenticatorSelection: protocol.AuthenticatorSelection{
AuthenticatorAttachment: "platform",
AuthenticatorAttachment: authenticatorModality,
RequireResidentKey: pointerx.Ptr(true),
UserVerification: protocol.VerificationPreferred,
},
Expand Down Expand Up @@ -1610,7 +1633,6 @@ func (p *Config) DefaultConsistencyLevel(ctx context.Context) crdbx.ConsistencyL
}

func (p *Config) PasswordMigrationHook(ctx context.Context) *PasswordMigrationHook {

hook := &PasswordMigrationHook{
Enabled: p.GetProvider(ctx).BoolF(ViperKeyPasswordMigrationHook+".enabled", false),
}
Expand Down
28 changes: 28 additions & 0 deletions embedx/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,20 @@
"title": "Use For Passwordless Flows",
"description": "If enabled will have the effect that WebAuthn is used for passwordless flows (as a first factor) and not for multi-factor set ups. With this set to true, users will see an option to sign up with WebAuthn on the registration screen."
},
"attachment": {
"title": "Authenticator Configuration",
"properties": {
"modality": {
"type": "string",
"title": "Authenticator Modality",
"description": "Restrict types of authenticators that are allowed.",
"examples": ["platform", "cross-platform", ""],
"default": ""
}
},
"type": "object",
"required": []
},
"rp": {
"title": "Relying Party (RP) Config",
"properties": {
Expand Down Expand Up @@ -1858,6 +1872,20 @@
"type": "object",
"title": "Passkey Configuration",
"properties": {
"attachment": {
"title": "Authenticator Configuration",
"properties": {
"modality": {
"type": "string",
"title": "Authenticator Modality",
"description": "Restrict types of authenticators that are allowed.",
"examples": ["platform", "cross-platform", ""],
"default": "platform"
}
},
"type": "object",
"required": []
},
"rp": {
"title": "Relying Party (RP) Config",
"properties": {
Expand Down
Loading