Feat: android support (#145)

* chore(backend): use 'ResidentKeyRequirementPreferred' during credential registration
* chore(hanko-js): hide passkey button on android
This commit is contained in:
bjoern-m
2022-07-21 09:58:57 +02:00
committed by GitHub
parent c8e8999ae1
commit e0b51e4df5
3 changed files with 8 additions and 3 deletions

View File

@ -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),

View File

@ -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)
} }

View File

@ -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}>