Skip to content

Commit 2cb0ae4

Browse files
committed
Add support for enabling webAuthn passwordless passkeys
1 parent be3b093 commit 2cb0ae4

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

docs/resources/realm.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ Each of these attributes are blocks with the following attributes:
255255
- `avoid_same_authenticator_register` - (Optional) When `true`, Keycloak will avoid registering the authenticator for WebAuthn if it has already been registered. Defaults to `false`.
256256
- `acceptable_aaguids` - (Optional) A set of AAGUIDs for which an authenticator can be registered.
257257
- `extra_origins` - (Optional) A set of extra origins for non-web applications.
258+
- `passwordless_passkeys_enabled` - (Optional) When `true`, Keycloak will enable passwordless passkey support. Defaults to `false`.
258259

259260
## Default Client Scopes
260261

keycloak/realm.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ type Realm struct {
141141
WebAuthnPolicyPasswordlessRpId string `json:"webAuthnPolicyPasswordlessRpId"`
142142
WebAuthnPolicyPasswordlessSignatureAlgorithms []string `json:"webAuthnPolicyPasswordlessSignatureAlgorithms"`
143143
WebAuthnPolicyPasswordlessUserVerificationRequirement string `json:"webAuthnPolicyPasswordlessUserVerificationRequirement"`
144+
WebAuthnPolicyPasswordlessPasskeysEnabled bool `json:"webAuthnPolicyPasswordlessPasskeysEnabled"`
144145

145146
// Roles
146147
DefaultRole *Role `json:"defaultRole,omitempty"`

provider/data_source_keycloak_realm.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ func dataSourceKeycloakRealm() *schema.Resource {
9595
Description: "Either required, preferred or discouraged",
9696
Computed: true,
9797
},
98+
"passwordless_passkeys_enabled": {
99+
Type: schema.TypeBool,
100+
Computed: true,
101+
},
98102
}
99103
return &schema.Resource{
100104
ReadContext: dataSourceKeycloakRealmRead,

provider/resource_keycloak_realm.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,10 @@ func getRealmFromData(data *schema.ResourceData, keycloakVersion *version.Versio
12201220
if webAuthnPolicyPasswordlessUserVerificationRequirement, ok := webAuthnPasswordlessPolicy["user_verification_requirement"]; ok {
12211221
realm.WebAuthnPolicyPasswordlessUserVerificationRequirement = webAuthnPolicyPasswordlessUserVerificationRequirement.(string)
12221222
}
1223+
1224+
if webAuthnPolicyPasswordlessPasskeysEnabled, ok := webAuthnPasswordlessPolicy["passwordless_passkeys_enabled"]; ok {
1225+
realm.WebAuthnPolicyPasswordlessPasskeysEnabled = webAuthnPolicyPasswordlessPasskeysEnabled.(bool)
1226+
}
12231227
}
12241228

12251229
return realm, nil
@@ -1423,6 +1427,7 @@ func setRealmData(data *schema.ResourceData, realm *keycloak.Realm, keycloakVers
14231427
webAuthnPasswordlessPolicy["relying_party_id"] = realm.WebAuthnPolicyPasswordlessRpId
14241428
webAuthnPasswordlessPolicy["signature_algorithms"] = realm.WebAuthnPolicyPasswordlessSignatureAlgorithms
14251429
webAuthnPasswordlessPolicy["user_verification_requirement"] = realm.WebAuthnPolicyPasswordlessUserVerificationRequirement
1430+
webAuthnPasswordlessPolicy["passwordless_passkeys_enabled"] = realm.WebAuthnPolicyPasswordlessPasskeysEnabled
14261431
data.Set("web_authn_passwordless_policy", []interface{}{webAuthnPasswordlessPolicy})
14271432

14281433
attributes := map[string]interface{}{}

provider/resource_keycloak_realm_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ resource "keycloak_realm" "realm" {
17811781
`, realm, realmDisplayName, realmDisplayNameHtml, rpName, rpId, arrayOfStringsForTerraformResource(signatureAlgorithms), attestationConveyancePreference, authenticatorAttachment, avoidSameAuthenticatorRegister, requireResidentKey, userVerificationRequirement)
17821782
}
17831783

1784-
func testKeycloakRealm_webauthn_passwordless_policy(realm, realmDisplayName, realmDisplayNameHtml, rpName, rpId, attestationConveyancePreference, authenticatorAttachment, requireResidentKey, userVerificationRequirement string, signatureAlgorithms []string, avoidSameAuthenticatorRegister bool) string {
1784+
func testKeycloakRealm_webauthn_passwordless_policy(realm, realmDisplayName, realmDisplayNameHtml, rpName, rpId, attestationConveyancePreference, authenticatorAttachment, requireResidentKey, userVerificationRequirement string, signatureAlgorithms []string, avoidSameAuthenticatorRegister bool, passwordlessPasskeysEnabled bool) string {
17851785
return fmt.Sprintf(`
17861786
resource "keycloak_realm" "realm" {
17871787
realm = "%s"
@@ -1799,9 +1799,10 @@ resource "keycloak_realm" "realm" {
17991799
avoid_same_authenticator_register = %t
18001800
require_resident_key = "%s"
18011801
user_verification_requirement = "%s"
1802+
passwordless_passkeys_enabled = %t
18021803
}
18031804
}
1804-
`, realm, realmDisplayName, realmDisplayNameHtml, rpName, rpId, arrayOfStringsForTerraformResource(signatureAlgorithms), attestationConveyancePreference, authenticatorAttachment, avoidSameAuthenticatorRegister, requireResidentKey, userVerificationRequirement)
1805+
`, realm, realmDisplayName, realmDisplayNameHtml, rpName, rpId, arrayOfStringsForTerraformResource(signatureAlgorithms), attestationConveyancePreference, authenticatorAttachment, avoidSameAuthenticatorRegister, requireResidentKey, userVerificationRequirement, passwordlessPasskeysEnabled)
18051806
}
18061807

18071808
func testKeycloakRealm_basicInternalId(realm, internalId string) string {

0 commit comments

Comments
 (0)