-
-
Notifications
You must be signed in to change notification settings - Fork 931
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
1,599 additions
and
71 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
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
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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"$id": "https://schemas.ory.sh/kratos/selfservice/strategy/webauthn/login.schema.json", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"properties": { | ||
"csrf_token": { | ||
"type": "string" | ||
}, | ||
"webauthn_login": { | ||
"type": "string" | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
selfservice/strategy/webauthn/.schema/settings.schema.json
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,43 @@ | ||
{ | ||
"$id": "https://schemas.ory.sh/kratos/selfservice/strategy/webauthn/settings.schema.json", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"properties": { | ||
"csrf_token": { | ||
"type": "string" | ||
}, | ||
"method": { | ||
"type": "string" | ||
}, | ||
"webauthn_register": { | ||
"type": "string" | ||
}, | ||
"webauthn_register_displayname": { | ||
"type": "string" | ||
}, | ||
"webauthn_remove": { | ||
"type": "string" | ||
} | ||
}, | ||
"if": { | ||
"properties": { | ||
"webauthn_register": { | ||
"minLength": 1 | ||
} | ||
}, | ||
"required": [ | ||
"webauthn_register" | ||
] | ||
}, | ||
"then": { | ||
"properties": { | ||
"webauthn_register_displayname": { | ||
"minLength": 1 | ||
} | ||
}, | ||
"required": [ | ||
"webauthn_register_displayname" | ||
] | ||
} | ||
} | ||
|
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,64 @@ | ||
package webauthn | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/duo-labs/webauthn/webauthn" | ||
) | ||
|
||
// CredentialsConfig is the struct that is being used as part of the identity credentials. | ||
type CredentialsConfig struct { | ||
// List of webauthn credentials. | ||
Credentials Credentials `json:"credentials"` | ||
} | ||
|
||
type Credentials []Credential | ||
|
||
func CredentialFromWebAuthn(credential *webauthn.Credential) *Credential { | ||
return &Credential{ | ||
ID: credential.ID, | ||
PublicKey: credential.PublicKey, | ||
AttestationType: credential.AttestationType, | ||
Authenticator: Authenticator{ | ||
AAGUID: credential.Authenticator.AAGUID, | ||
SignCount: credential.Authenticator.SignCount, | ||
CloneWarning: credential.Authenticator.CloneWarning, | ||
}, | ||
} | ||
} | ||
|
||
func (c Credentials) ToWebAuthn() []webauthn.Credential { | ||
result := make([]webauthn.Credential, len(c)) | ||
for k := range c { | ||
result[k] = *c[k].ToWebAuthn() | ||
} | ||
return result | ||
} | ||
|
||
func (c *Credential) ToWebAuthn() *webauthn.Credential { | ||
return &webauthn.Credential{ | ||
ID: c.ID, | ||
PublicKey: c.PublicKey, | ||
AttestationType: c.AttestationType, | ||
Authenticator: webauthn.Authenticator{ | ||
AAGUID: c.Authenticator.AAGUID, | ||
SignCount: c.Authenticator.SignCount, | ||
CloneWarning: c.Authenticator.CloneWarning, | ||
}, | ||
} | ||
} | ||
|
||
type Credential struct { | ||
ID []byte `json:"id"` | ||
PublicKey []byte `json:"public_key"` | ||
AttestationType string `json:"attestation_type"` | ||
Authenticator Authenticator `json:"authenticator"` | ||
DisplayName string `json:"display_name"` | ||
AddedAt time.Time `json:"added_at"` | ||
} | ||
|
||
type Authenticator struct { | ||
AAGUID []byte `json:"aaguid"` | ||
SignCount uint32 `json:"sign_count"` | ||
CloneWarning bool `json:"clone_warning"` | ||
} |
Oops, something went wrong.