-
-
Notifications
You must be signed in to change notification settings - Fork 954
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
webauthn
to list of identifiers
This patch adds the key `webauthn` to the list of possible identifiers in the Identity JSON Schema. Use this key to specify what field is used to find the WebAuthn credentials on passwordless login flows.
- Loading branch information
Showing
4 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,16 +25,19 @@ func TestSchemaExtensionCredentials(t *testing.T) { | |
doc string | ||
expect []string | ||
existing *identity.Credentials | ||
ct identity.CredentialsType | ||
}{ | ||
{ | ||
doc: `{"email":"[email protected]"}`, | ||
schema: "file://./stub/extension/credentials/schema.json", | ||
expect: []string{"[email protected]"}, | ||
ct: identity.CredentialsTypePassword, | ||
}, | ||
{ | ||
doc: `{"emails":["[email protected]","[email protected]","[email protected]"], "username": "foobar"}`, | ||
schema: "file://./stub/extension/credentials/multi.schema.json", | ||
expect: []string{"[email protected]", "[email protected]", "foobar"}, | ||
ct: identity.CredentialsTypePassword, | ||
}, | ||
{ | ||
doc: `{"emails":["[email protected]","[email protected]"], "username": "foobar"}`, | ||
|
@@ -43,6 +46,22 @@ func TestSchemaExtensionCredentials(t *testing.T) { | |
existing: &identity.Credentials{ | ||
Identifiers: []string{"[email protected]"}, | ||
}, | ||
ct: identity.CredentialsTypePassword, | ||
}, | ||
{ | ||
doc: `{"email":"[email protected]"}`, | ||
schema: "file://./stub/extension/credentials/webauthn.schema.json", | ||
expect: []string{"[email protected]"}, | ||
ct: identity.CredentialsTypeWebAuthn, | ||
}, | ||
{ | ||
doc: `{"email":"[email protected]"}`, | ||
schema: "file://./stub/extension/credentials/webauthn.schema.json", | ||
expect: []string{"[email protected]"}, | ||
existing: &identity.Credentials{ | ||
Identifiers: []string{"[email protected]"}, | ||
}, | ||
ct: identity.CredentialsTypeWebAuthn, | ||
}, | ||
} { | ||
t.Run(fmt.Sprintf("case=%d", k), func(t *testing.T) { | ||
|
@@ -53,7 +72,7 @@ func TestSchemaExtensionCredentials(t *testing.T) { | |
i := new(identity.Identity) | ||
e := identity.NewSchemaExtensionCredentials(i) | ||
if tc.existing != nil { | ||
i.SetCredentials(identity.CredentialsTypePassword, *tc.existing) | ||
i.SetCredentials(tc.ct, *tc.existing) | ||
} | ||
|
||
runner.AddRunner(e).Register(c) | ||
|
@@ -63,7 +82,7 @@ func TestSchemaExtensionCredentials(t *testing.T) { | |
} | ||
require.NoError(t, e.Finish()) | ||
|
||
credentials, ok := i.GetCredentials(identity.CredentialsTypePassword) | ||
credentials, ok := i.GetCredentials(tc.ct) | ||
require.True(t, ok) | ||
assert.ElementsMatch(t, tc.expect, credentials.Identifiers) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"email": { | ||
"type": "string", | ||
"format": "email", | ||
"ory.sh/kratos": { | ||
"credentials": { | ||
"password": { | ||
"identifier": true | ||
}, | ||
"webauthn": { | ||
"identifier": true | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters