mirror of
https://github.com/teamhanko/hanko.git
synced 2025-10-27 06:06:54 +08:00
Feat: android support (#145)
* chore(backend): use 'ResidentKeyRequirementPreferred' during credential registration * chore(hanko-js): hide passkey button on android
This commit is contained in:
@ -77,7 +77,7 @@ func (h *WebauthnHandler) BeginRegistration(c echo.Context) error {
|
|||||||
webauthn.WithAuthenticatorSelection(protocol.AuthenticatorSelection{
|
webauthn.WithAuthenticatorSelection(protocol.AuthenticatorSelection{
|
||||||
AuthenticatorAttachment: protocol.Platform,
|
AuthenticatorAttachment: protocol.Platform,
|
||||||
RequireResidentKey: &t,
|
RequireResidentKey: &t,
|
||||||
ResidentKey: protocol.ResidentKeyRequirementRequired,
|
ResidentKey: protocol.ResidentKeyRequirementPreferred,
|
||||||
UserVerification: protocol.VerificationRequired,
|
UserVerification: protocol.VerificationRequired,
|
||||||
}),
|
}),
|
||||||
webauthn.WithConveyancePreference(protocol.PreferNoAttestation),
|
webauthn.WithConveyancePreference(protocol.PreferNoAttestation),
|
||||||
|
|||||||
@ -50,7 +50,7 @@ func TestWebauthnHandler_BeginRegistration(t *testing.T) {
|
|||||||
assert.NotEmpty(t, creationOptions.Response.Challenge)
|
assert.NotEmpty(t, creationOptions.Response.Challenge)
|
||||||
assert.Equal(t, userIdBytes, creationOptions.Response.User.ID)
|
assert.Equal(t, userIdBytes, creationOptions.Response.User.ID)
|
||||||
assert.Equal(t, defaultConfig.RelyingParty.Id, creationOptions.Response.RelyingParty.ID)
|
assert.Equal(t, defaultConfig.RelyingParty.Id, creationOptions.Response.RelyingParty.ID)
|
||||||
assert.Equal(t, creationOptions.Response.AuthenticatorSelection.ResidentKey, protocol.ResidentKeyRequirementRequired)
|
assert.Equal(t, creationOptions.Response.AuthenticatorSelection.ResidentKey, protocol.ResidentKeyRequirementPreferred)
|
||||||
assert.Equal(t, creationOptions.Response.AuthenticatorSelection.UserVerification, protocol.VerificationRequired)
|
assert.Equal(t, creationOptions.Response.AuthenticatorSelection.UserVerification, protocol.VerificationRequired)
|
||||||
assert.True(t, *creationOptions.Response.AuthenticatorSelection.RequireResidentKey)
|
assert.True(t, *creationOptions.Response.AuthenticatorSelection.RequireResidentKey)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,6 +43,11 @@ const LoginEmail = () => {
|
|||||||
const [isAuthenticatorSupported, setIsAuthenticatorSupported] =
|
const [isAuthenticatorSupported, setIsAuthenticatorSupported] =
|
||||||
useState<boolean>(null);
|
useState<boolean>(null);
|
||||||
|
|
||||||
|
// isAndroidUserAgent is used to determine whether the "Login with Passkey" button should be visible, as there is
|
||||||
|
// currently no resident key support on Android.
|
||||||
|
const isAndroidUserAgent =
|
||||||
|
window.navigator.userAgent.indexOf("Android") !== -1;
|
||||||
|
|
||||||
const onEmailInput = (event: Event) => {
|
const onEmailInput = (event: Event) => {
|
||||||
if (event.target instanceof HTMLInputElement) {
|
if (event.target instanceof HTMLInputElement) {
|
||||||
setEmail(event.target.value);
|
setEmail(event.target.value);
|
||||||
@ -161,7 +166,7 @@ const LoginEmail = () => {
|
|||||||
/>
|
/>
|
||||||
<Button isLoading={isEmailLoading}>{t("labels.continue")}</Button>
|
<Button isLoading={isEmailLoading}>{t("labels.continue")}</Button>
|
||||||
</Form>
|
</Form>
|
||||||
{isAuthenticatorSupported ? (
|
{isAuthenticatorSupported && !isAndroidUserAgent ? (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<Divider />
|
<Divider />
|
||||||
<Form onSubmit={onWebAuthnSubmit}>
|
<Form onSubmit={onWebAuthnSubmit}>
|
||||||
|
|||||||
Reference in New Issue
Block a user