@oussemasahbeni/keycloakify-login-shadcn 250004.0.2 → 250004.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/keycloak-theme/components/ui/alert.tsx +4 -4
- package/keycloak-theme/components/ui/dropdown-menu.tsx +5 -5
- package/keycloak-theme/components/ui/input.tsx +1 -1
- package/keycloak-theme/components/ui/select.tsx +4 -4
- package/keycloak-theme/components/ui/separator.tsx +1 -1
- package/keycloak-theme/login/KcContext.ts +23 -19
- package/keycloak-theme/login/KcPage.tsx +47 -60
- package/keycloak-theme/login/assets/img/auth-logo.svg +100 -100
- package/keycloak-theme/login/assets/img/shape.svg +71 -71
- package/keycloak-theme/login/components/LogoutOtherSessions.tsx +26 -26
- package/keycloak-theme/login/components/PasswordWrapper.tsx +35 -35
- package/keycloak-theme/login/components/Template/Template.tsx +227 -226
- package/keycloak-theme/login/components/Template/index.ts +1 -1
- package/keycloak-theme/login/components/Template/useInitializeTemplate.ts +61 -61
- package/keycloak-theme/login/components/UserProfileFormFields/AddRemoveButtonsMultiValuedAttribute.tsx +61 -61
- package/keycloak-theme/login/components/UserProfileFormFields/DO_MAKE_USER_CONFIRM_PASSWORD.ts +2 -2
- package/keycloak-theme/login/components/UserProfileFormFields/FieldErrors.tsx +28 -28
- package/keycloak-theme/login/components/UserProfileFormFields/GroupLabel.tsx +70 -70
- package/keycloak-theme/login/components/UserProfileFormFields/InputFieldByType.tsx +58 -58
- package/keycloak-theme/login/components/UserProfileFormFields/InputTag.tsx +116 -116
- package/keycloak-theme/login/components/UserProfileFormFields/InputTagSelects.tsx +135 -135
- package/keycloak-theme/login/components/UserProfileFormFields/SelectTag.tsx +114 -114
- package/keycloak-theme/login/components/UserProfileFormFields/TextareaTag.tsx +42 -42
- package/keycloak-theme/login/components/UserProfileFormFields/UserProfileFormFields.tsx +127 -127
- package/keycloak-theme/login/components/UserProfileFormFields/index.ts +1 -1
- package/keycloak-theme/login/i18n.ts +47 -51
- package/keycloak-theme/login/mocks/getKcContextMock.ts +22 -18
- package/keycloak-theme/login/pages/PageIndex.tsx +134 -134
- package/keycloak-theme/login/pages/code/Page.stories.tsx +62 -78
- package/keycloak-theme/login/pages/code/Page.tsx +89 -89
- package/keycloak-theme/login/pages/code/index.ts +3 -3
- package/keycloak-theme/login/pages/delete-account-confirm/Page.stories.tsx +39 -46
- package/keycloak-theme/login/pages/delete-account-confirm/Page.tsx +63 -63
- package/keycloak-theme/login/pages/delete-account-confirm/index.ts +3 -3
- package/keycloak-theme/login/pages/delete-credential/Page.stories.tsx +26 -30
- package/keycloak-theme/login/pages/delete-credential/Page.tsx +51 -51
- package/keycloak-theme/login/pages/delete-credential/index.ts +3 -3
- package/keycloak-theme/login/pages/error/Page.stories.tsx +47 -58
- package/keycloak-theme/login/pages/error/Page.tsx +42 -42
- package/keycloak-theme/login/pages/error/index.ts +3 -3
- package/keycloak-theme/login/pages/frontchannel-logout/Page.stories.tsx +25 -32
- package/keycloak-theme/login/pages/frontchannel-logout/Page.tsx +84 -84
- package/keycloak-theme/login/pages/frontchannel-logout/index.ts +3 -3
- package/keycloak-theme/login/pages/idp-review-user-profile/Page.stories.tsx +46 -58
- package/keycloak-theme/login/pages/idp-review-user-profile/Page.tsx +52 -52
- package/keycloak-theme/login/pages/idp-review-user-profile/index.ts +3 -3
- package/keycloak-theme/login/pages/info/Page.stories.tsx +50 -60
- package/keycloak-theme/login/pages/info/Page.tsx +92 -92
- package/keycloak-theme/login/pages/link-idp-action/Page.stories.tsx +32 -16
- package/keycloak-theme/login/pages/link-idp-action/Page.tsx +43 -43
- package/keycloak-theme/login/pages/link-idp-action/index.ts +3 -3
- package/keycloak-theme/login/pages/login/Form.tsx +242 -242
- package/keycloak-theme/login/pages/login/Info.tsx +29 -29
- package/keycloak-theme/login/pages/login/Page.stories.tsx +345 -365
- package/keycloak-theme/login/pages/login/Page.tsx +44 -44
- package/keycloak-theme/login/pages/login/SocialProviders.tsx +107 -107
- package/keycloak-theme/login/pages/login/index.ts +3 -3
- package/keycloak-theme/login/pages/login/providers/apple.svg +3 -3
- package/keycloak-theme/login/pages/login/providers/bitbucket.svg +11 -11
- package/keycloak-theme/login/pages/login/providers/discord.svg +4 -4
- package/keycloak-theme/login/pages/login/providers/facebook.svg +5 -5
- package/keycloak-theme/login/pages/login/providers/github.svg +3 -3
- package/keycloak-theme/login/pages/login/providers/gitlab.svg +7 -7
- package/keycloak-theme/login/pages/login/providers/google.svg +7 -7
- package/keycloak-theme/login/pages/login/providers/instagram.svg +31 -31
- package/keycloak-theme/login/pages/login/providers/linkedin.svg +3 -3
- package/keycloak-theme/login/pages/login/providers/microsoft.svg +6 -6
- package/keycloak-theme/login/pages/login/providers/oidc.svg +5 -5
- package/keycloak-theme/login/pages/login/providers/openshift.svg +7 -7
- package/keycloak-theme/login/pages/login/providers/paypal.svg +6 -6
- package/keycloak-theme/login/pages/login/providers/slack.svg +11 -11
- package/keycloak-theme/login/pages/login/providers/stackoverflow.svg +5 -5
- package/keycloak-theme/login/pages/login/providers/x.svg +3 -3
- package/keycloak-theme/login/pages/login/useProviderLogos.tsx +39 -39
- package/keycloak-theme/login/pages/login/useScript.tsx +62 -62
- package/keycloak-theme/login/pages/login-config-totp/Page.stories.tsx +45 -59
- package/keycloak-theme/login/pages/login-config-totp/Page.tsx +240 -240
- package/keycloak-theme/login/pages/login-config-totp/index.ts +3 -3
- package/keycloak-theme/login/pages/login-idp-link-confirm/Page.stories.tsx +30 -34
- package/keycloak-theme/login/pages/login-idp-link-confirm/Page.tsx +43 -43
- package/keycloak-theme/login/pages/login-idp-link-confirm/index.ts +3 -3
- package/keycloak-theme/login/pages/login-idp-link-confirm-override/Page.stories.tsx +16 -22
- package/keycloak-theme/login/pages/login-idp-link-confirm-override/Page.tsx +47 -47
- package/keycloak-theme/login/pages/login-idp-link-confirm-override/index.ts +3 -3
- package/keycloak-theme/login/pages/login-idp-link-email/Page.stories.tsx +54 -62
- package/keycloak-theme/login/pages/login-idp-link-email/Page.tsx +54 -54
- package/keycloak-theme/login/pages/login-idp-link-email/index.ts +3 -3
- package/keycloak-theme/login/pages/login-oauth-grant/Page.stories.tsx +39 -45
- package/keycloak-theme/login/pages/login-oauth-grant/Page.tsx +126 -126
- package/keycloak-theme/login/pages/login-oauth-grant/index.ts +3 -3
- package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/Page.stories.tsx +38 -48
- package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/Page.tsx +58 -58
- package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/index.ts +3 -3
- package/keycloak-theme/login/pages/login-otp/Page.stories.tsx +82 -96
- package/keycloak-theme/login/pages/login-otp/Page.tsx +108 -108
- package/keycloak-theme/login/pages/login-otp/index.ts +3 -3
- package/keycloak-theme/login/pages/login-page-expired/Page.stories.tsx +28 -36
- package/keycloak-theme/login/pages/login-page-expired/Page.tsx +47 -47
- package/keycloak-theme/login/pages/login-page-expired/index.ts +3 -3
- package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/Page.stories.tsx +20 -0
- package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/Page.tsx +233 -233
- package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/index.ts +3 -3
- package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/useScript.tsx +63 -63
- package/keycloak-theme/login/pages/login-password/Page.stories.tsx +55 -56
- package/keycloak-theme/login/pages/login-password/Page.tsx +149 -149
- package/keycloak-theme/login/pages/login-password/index.ts +3 -3
- package/keycloak-theme/login/pages/login-password/useScript.tsx +63 -63
- package/keycloak-theme/login/pages/login-recovery-authn-code-config/Page.stories.tsx +28 -36
- package/keycloak-theme/login/pages/login-recovery-authn-code-config/Page.tsx +181 -181
- package/keycloak-theme/login/pages/login-recovery-authn-code-config/index.ts +3 -3
- package/keycloak-theme/login/pages/login-recovery-authn-code-config/useScript.tsx +145 -145
- package/keycloak-theme/login/pages/login-recovery-authn-code-input/Page.stories.tsx +16 -22
- package/keycloak-theme/login/pages/login-recovery-authn-code-input/Page.tsx +70 -70
- package/keycloak-theme/login/pages/login-recovery-authn-code-input/index.ts +3 -3
- package/keycloak-theme/login/pages/login-reset-otp/Page.stories.tsx +62 -74
- package/keycloak-theme/login/pages/login-reset-otp/Page.tsx +86 -86
- package/keycloak-theme/login/pages/login-reset-otp/index.ts +3 -3
- package/keycloak-theme/login/pages/login-reset-password/Form.tsx +68 -68
- package/keycloak-theme/login/pages/login-reset-password/Page.stories.tsx +44 -54
- package/keycloak-theme/login/pages/login-reset-password/Page.tsx +27 -27
- package/keycloak-theme/login/pages/login-reset-password/index.ts +3 -3
- package/keycloak-theme/login/pages/login-update-password/Page.stories.tsx +40 -50
- package/keycloak-theme/login/pages/login-update-password/Page.tsx +111 -111
- package/keycloak-theme/login/pages/login-update-password/index.ts +3 -3
- package/keycloak-theme/login/pages/login-update-profile/Page.stories.tsx +28 -36
- package/keycloak-theme/login/pages/login-update-profile/Page.tsx +68 -68
- package/keycloak-theme/login/pages/login-update-profile/index.ts +3 -3
- package/keycloak-theme/login/pages/login-username/Page.stories.tsx +32 -42
- package/keycloak-theme/login/pages/login-username/Page.tsx +246 -246
- package/keycloak-theme/login/pages/login-username/index.ts +3 -3
- package/keycloak-theme/login/pages/login-username/useScript.tsx +62 -62
- package/keycloak-theme/login/pages/login-verify-email/Page.stories.tsx +68 -80
- package/keycloak-theme/login/pages/login-verify-email/Page.tsx +38 -38
- package/keycloak-theme/login/pages/login-verify-email/index.ts +3 -3
- package/keycloak-theme/login/pages/login-x509-info/Page.stories.tsx +29 -37
- package/keycloak-theme/login/pages/login-x509-info/Page.tsx +75 -75
- package/keycloak-theme/login/pages/login-x509-info/index.ts +3 -3
- package/keycloak-theme/login/pages/logout-confirm/Page.stories.tsx +34 -42
- package/keycloak-theme/login/pages/logout-confirm/Page.tsx +53 -53
- package/keycloak-theme/login/pages/logout-confirm/index.ts +3 -3
- package/keycloak-theme/login/pages/register/Form.tsx +106 -106
- package/keycloak-theme/login/pages/register/Page.stories.tsx +23 -6
- package/keycloak-theme/login/pages/register/Page.tsx +26 -26
- package/keycloak-theme/login/pages/register/TermsAcceptance.tsx +56 -56
- package/keycloak-theme/login/pages/register/index.ts +3 -3
- package/keycloak-theme/login/pages/saml-post-form/Page.stories.tsx +16 -22
- package/keycloak-theme/login/pages/saml-post-form/Page.tsx +66 -66
- package/keycloak-theme/login/pages/saml-post-form/index.ts +3 -3
- package/keycloak-theme/login/pages/select-authenticator/Page.stories.tsx +83 -95
- package/keycloak-theme/login/pages/select-authenticator/Page.tsx +100 -100
- package/keycloak-theme/login/pages/select-authenticator/index.ts +3 -3
- package/keycloak-theme/login/pages/select-organization/Page.stories.tsx +62 -49
- package/keycloak-theme/login/pages/select-organization/Page.tsx +126 -126
- package/keycloak-theme/login/pages/select-organization/index.ts +3 -3
- package/keycloak-theme/login/pages/terms/Page.stories.tsx +15 -0
- package/keycloak-theme/login/pages/terms/Page.tsx +51 -51
- package/keycloak-theme/login/pages/terms/index.ts +3 -3
- package/keycloak-theme/login/pages/update-email/Page.stories.tsx +27 -35
- package/keycloak-theme/login/pages/update-email/Page.tsx +62 -62
- package/keycloak-theme/login/pages/update-email/index.ts +3 -3
- package/keycloak-theme/login/pages/webauthn-authenticate/Page.stories.tsx +112 -126
- package/keycloak-theme/login/pages/webauthn-authenticate/Page.tsx +202 -202
- package/keycloak-theme/login/pages/webauthn-authenticate/index.ts +3 -3
- package/keycloak-theme/login/pages/webauthn-authenticate/useScript.tsx +55 -55
- package/keycloak-theme/login/pages/webauthn-error/Page.stories.tsx +54 -66
- package/keycloak-theme/login/pages/webauthn-error/Page.tsx +73 -73
- package/keycloak-theme/login/pages/webauthn-error/index.ts +3 -3
- package/keycloak-theme/login/pages/webauthn-register/Page.stories.tsx +39 -49
- package/keycloak-theme/login/pages/webauthn-register/Page.tsx +78 -78
- package/keycloak-theme/login/pages/webauthn-register/index.ts +3 -3
- package/keycloak-theme/login/pages/webauthn-register/useScript.tsx +62 -62
- package/keycloak-theme/login/shared/getColorScheme.ts +45 -0
- package/keycloak-theme/login/styleLevelCustomization.tsx +36 -17
- package/package.json +6 -5
|
@@ -1,202 +1,202 @@
|
|
|
1
|
-
import { Button } from "@/components/ui/button";
|
|
2
|
-
import { Input } from "@/components/ui/input";
|
|
3
|
-
import { useI18n } from '@/login/i18n';
|
|
4
|
-
import { useKcContext } from '@/login/KcContext';
|
|
5
|
-
import { useKcClsx } from '@keycloakify/login-ui/useKcClsx';
|
|
6
|
-
import { clsx } from "keycloakify/tools/clsx";
|
|
7
|
-
import { Fingerprint, Shield } from "lucide-react";
|
|
8
|
-
import { Fragment } from "react";
|
|
9
|
-
import { assert } from "tsafe/assert";
|
|
10
|
-
import { Template } from "../../components/Template";
|
|
11
|
-
import { useScript } from './useScript';
|
|
12
|
-
|
|
13
|
-
export function Page() {
|
|
14
|
-
|
|
15
|
-
const { kcContext } = useKcContext();
|
|
16
|
-
assert(kcContext.pageId === "webauthn-authenticate.ftl");
|
|
17
|
-
|
|
18
|
-
const { kcClsx } = useKcClsx();
|
|
19
|
-
|
|
20
|
-
const { url, realm, registrationDisabled, authenticators, shouldDisplayAuthenticators } = kcContext;
|
|
21
|
-
|
|
22
|
-
const { msg, msgStr, advancedMsg } = useI18n();
|
|
23
|
-
|
|
24
|
-
const webAuthnButtonId = "authenticateWebAuthnButton";
|
|
25
|
-
|
|
26
|
-
useScript({ webAuthnButtonId });
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<Template
|
|
31
|
-
displayInfo={realm.registrationAllowed && !registrationDisabled}
|
|
32
|
-
infoNode={
|
|
33
|
-
<div id="kc-registration" className="text-center text-sm">
|
|
34
|
-
<span>
|
|
35
|
-
{msg("noAccount")}{" "}
|
|
36
|
-
<a
|
|
37
|
-
tabIndex={6}
|
|
38
|
-
href={url.registrationUrl}
|
|
39
|
-
className="text-primary dark:text-white hover:text-primary/80 underline underline-offset-4"
|
|
40
|
-
>
|
|
41
|
-
{msg("doRegister")}
|
|
42
|
-
</a>
|
|
43
|
-
</span>
|
|
44
|
-
</div>
|
|
45
|
-
}
|
|
46
|
-
headerNode={msg("webauthn-login-title")}
|
|
47
|
-
>
|
|
48
|
-
<div className="space-y-6">
|
|
49
|
-
<form id="webauth" action={url.loginAction} method="post">
|
|
50
|
-
<input type="hidden" id="clientDataJSON" name="clientDataJSON" />
|
|
51
|
-
<input
|
|
52
|
-
type="hidden"
|
|
53
|
-
id="authenticatorData"
|
|
54
|
-
name="authenticatorData"
|
|
55
|
-
/>
|
|
56
|
-
<input type="hidden" id="signature" name="signature" />
|
|
57
|
-
<input type="hidden" id="credentialId" name="credentialId" />
|
|
58
|
-
<input type="hidden" id="userHandle" name="userHandle" />
|
|
59
|
-
<input type="hidden" id="error" name="error" />
|
|
60
|
-
</form>
|
|
61
|
-
|
|
62
|
-
{authenticators && (
|
|
63
|
-
<>
|
|
64
|
-
<form id="authn_select">
|
|
65
|
-
{authenticators.authenticators.map(authenticator => (
|
|
66
|
-
<Input
|
|
67
|
-
key={authenticator.credentialId}
|
|
68
|
-
type="hidden"
|
|
69
|
-
name="authn_use_chk"
|
|
70
|
-
value={authenticator.credentialId}
|
|
71
|
-
/>
|
|
72
|
-
))}
|
|
73
|
-
</form>
|
|
74
|
-
|
|
75
|
-
{shouldDisplayAuthenticators && (
|
|
76
|
-
<div className="space-y-4">
|
|
77
|
-
{authenticators.authenticators.length > 1 && (
|
|
78
|
-
<h3 className="text-sm font-medium text-center">
|
|
79
|
-
{msg("webauthn-available-authenticators")}
|
|
80
|
-
</h3>
|
|
81
|
-
)}
|
|
82
|
-
|
|
83
|
-
<div className="space-y-2">
|
|
84
|
-
{authenticators.authenticators.map(
|
|
85
|
-
(authenticator, i) => (
|
|
86
|
-
<div
|
|
87
|
-
key={i}
|
|
88
|
-
id={`kc-webauthn-authenticator-item-${i}`}
|
|
89
|
-
className="flex items-center gap-3 p-3 border rounded-lg bg-muted/50"
|
|
90
|
-
>
|
|
91
|
-
<div className="shrink-0">
|
|
92
|
-
{(() => {
|
|
93
|
-
const className = kcClsx(
|
|
94
|
-
authenticator.transports
|
|
95
|
-
.iconClass as any
|
|
96
|
-
);
|
|
97
|
-
const isDefaultIcon =
|
|
98
|
-
className ===
|
|
99
|
-
authenticator.transports
|
|
100
|
-
.iconClass;
|
|
101
|
-
|
|
102
|
-
if (isDefaultIcon) {
|
|
103
|
-
return (
|
|
104
|
-
<Shield className="w-5 h-5 text-muted-foreground" />
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<i
|
|
110
|
-
className={clsx(
|
|
111
|
-
className,
|
|
112
|
-
"text-muted-foreground"
|
|
113
|
-
)}
|
|
114
|
-
/>
|
|
115
|
-
);
|
|
116
|
-
})()}
|
|
117
|
-
</div>
|
|
118
|
-
|
|
119
|
-
<div className="flex-1 min-w-0">
|
|
120
|
-
<div
|
|
121
|
-
id={`kc-webauthn-authenticator-label-${i}`}
|
|
122
|
-
className="font-medium text-sm"
|
|
123
|
-
>
|
|
124
|
-
{advancedMsg(authenticator.label)}
|
|
125
|
-
</div>
|
|
126
|
-
|
|
127
|
-
{authenticator.transports
|
|
128
|
-
.displayNameProperties
|
|
129
|
-
?.length && (
|
|
130
|
-
<div
|
|
131
|
-
id={`kc-webauthn-authenticator-transport-${i}`}
|
|
132
|
-
className="text-xs text-muted-foreground mt-1"
|
|
133
|
-
>
|
|
134
|
-
{authenticator.transports.displayNameProperties
|
|
135
|
-
.map(
|
|
136
|
-
(
|
|
137
|
-
displayNameProperty,
|
|
138
|
-
i,
|
|
139
|
-
arr
|
|
140
|
-
) => ({
|
|
141
|
-
displayNameProperty,
|
|
142
|
-
hasNext:
|
|
143
|
-
i !==
|
|
144
|
-
arr.length - 1
|
|
145
|
-
})
|
|
146
|
-
)
|
|
147
|
-
.map(
|
|
148
|
-
({
|
|
149
|
-
displayNameProperty,
|
|
150
|
-
hasNext
|
|
151
|
-
}) => (
|
|
152
|
-
<Fragment
|
|
153
|
-
key={
|
|
154
|
-
displayNameProperty
|
|
155
|
-
}
|
|
156
|
-
>
|
|
157
|
-
{advancedMsg(
|
|
158
|
-
displayNameProperty
|
|
159
|
-
)}
|
|
160
|
-
{hasNext && (
|
|
161
|
-
<span>
|
|
162
|
-
,{" "}
|
|
163
|
-
</span>
|
|
164
|
-
)}
|
|
165
|
-
</Fragment>
|
|
166
|
-
)
|
|
167
|
-
)}
|
|
168
|
-
</div>
|
|
169
|
-
)}
|
|
170
|
-
|
|
171
|
-
<div className="text-xs text-muted-foreground mt-1">
|
|
172
|
-
<span
|
|
173
|
-
id={`kc-webauthn-authenticator-createdlabel-${i}`}
|
|
174
|
-
>
|
|
175
|
-
{msg(
|
|
176
|
-
"webauthn-createdAt-label"
|
|
177
|
-
)}
|
|
178
|
-
</span>{" "}
|
|
179
|
-
<span
|
|
180
|
-
id={`kc-webauthn-authenticator-created-${i}`}
|
|
181
|
-
>
|
|
182
|
-
{authenticator.createdAt}
|
|
183
|
-
</span>
|
|
184
|
-
</div>
|
|
185
|
-
</div>
|
|
186
|
-
</div>
|
|
187
|
-
)
|
|
188
|
-
)}
|
|
189
|
-
</div>
|
|
190
|
-
</div>
|
|
191
|
-
)}
|
|
192
|
-
</>
|
|
193
|
-
)}
|
|
194
|
-
|
|
195
|
-
<Button id={webAuthnButtonId} type="button" autoFocus className="w-full">
|
|
196
|
-
<Fingerprint className="w-4 h-4" />
|
|
197
|
-
{msgStr("webauthn-doAuthenticate")}
|
|
198
|
-
</Button>
|
|
199
|
-
</div>
|
|
200
|
-
</Template>
|
|
201
|
-
);
|
|
202
|
-
}
|
|
1
|
+
import { Button } from "@/components/ui/button";
|
|
2
|
+
import { Input } from "@/components/ui/input";
|
|
3
|
+
import { useI18n } from '@/login/i18n';
|
|
4
|
+
import { useKcContext } from '@/login/KcContext';
|
|
5
|
+
import { useKcClsx } from '@keycloakify/login-ui/useKcClsx';
|
|
6
|
+
import { clsx } from "keycloakify/tools/clsx";
|
|
7
|
+
import { Fingerprint, Shield } from "lucide-react";
|
|
8
|
+
import { Fragment } from "react";
|
|
9
|
+
import { assert } from "tsafe/assert";
|
|
10
|
+
import { Template } from "../../components/Template";
|
|
11
|
+
import { useScript } from './useScript';
|
|
12
|
+
|
|
13
|
+
export function Page() {
|
|
14
|
+
|
|
15
|
+
const { kcContext } = useKcContext();
|
|
16
|
+
assert(kcContext.pageId === "webauthn-authenticate.ftl");
|
|
17
|
+
|
|
18
|
+
const { kcClsx } = useKcClsx();
|
|
19
|
+
|
|
20
|
+
const { url, realm, registrationDisabled, authenticators, shouldDisplayAuthenticators } = kcContext;
|
|
21
|
+
|
|
22
|
+
const { msg, msgStr, advancedMsg } = useI18n();
|
|
23
|
+
|
|
24
|
+
const webAuthnButtonId = "authenticateWebAuthnButton";
|
|
25
|
+
|
|
26
|
+
useScript({ webAuthnButtonId });
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Template
|
|
31
|
+
displayInfo={realm.registrationAllowed && !registrationDisabled}
|
|
32
|
+
infoNode={
|
|
33
|
+
<div id="kc-registration" className="text-center text-sm">
|
|
34
|
+
<span>
|
|
35
|
+
{msg("noAccount")}{" "}
|
|
36
|
+
<a
|
|
37
|
+
tabIndex={6}
|
|
38
|
+
href={url.registrationUrl}
|
|
39
|
+
className="text-primary dark:text-white hover:text-primary/80 underline underline-offset-4"
|
|
40
|
+
>
|
|
41
|
+
{msg("doRegister")}
|
|
42
|
+
</a>
|
|
43
|
+
</span>
|
|
44
|
+
</div>
|
|
45
|
+
}
|
|
46
|
+
headerNode={msg("webauthn-login-title")}
|
|
47
|
+
>
|
|
48
|
+
<div className="space-y-6">
|
|
49
|
+
<form id="webauth" action={url.loginAction} method="post">
|
|
50
|
+
<input type="hidden" id="clientDataJSON" name="clientDataJSON" />
|
|
51
|
+
<input
|
|
52
|
+
type="hidden"
|
|
53
|
+
id="authenticatorData"
|
|
54
|
+
name="authenticatorData"
|
|
55
|
+
/>
|
|
56
|
+
<input type="hidden" id="signature" name="signature" />
|
|
57
|
+
<input type="hidden" id="credentialId" name="credentialId" />
|
|
58
|
+
<input type="hidden" id="userHandle" name="userHandle" />
|
|
59
|
+
<input type="hidden" id="error" name="error" />
|
|
60
|
+
</form>
|
|
61
|
+
|
|
62
|
+
{authenticators && (
|
|
63
|
+
<>
|
|
64
|
+
<form id="authn_select">
|
|
65
|
+
{authenticators.authenticators.map(authenticator => (
|
|
66
|
+
<Input
|
|
67
|
+
key={authenticator.credentialId}
|
|
68
|
+
type="hidden"
|
|
69
|
+
name="authn_use_chk"
|
|
70
|
+
value={authenticator.credentialId}
|
|
71
|
+
/>
|
|
72
|
+
))}
|
|
73
|
+
</form>
|
|
74
|
+
|
|
75
|
+
{shouldDisplayAuthenticators && (
|
|
76
|
+
<div className="space-y-4">
|
|
77
|
+
{authenticators.authenticators.length > 1 && (
|
|
78
|
+
<h3 className="text-sm font-medium text-center">
|
|
79
|
+
{msg("webauthn-available-authenticators")}
|
|
80
|
+
</h3>
|
|
81
|
+
)}
|
|
82
|
+
|
|
83
|
+
<div className="space-y-2">
|
|
84
|
+
{authenticators.authenticators.map(
|
|
85
|
+
(authenticator, i) => (
|
|
86
|
+
<div
|
|
87
|
+
key={i}
|
|
88
|
+
id={`kc-webauthn-authenticator-item-${i}`}
|
|
89
|
+
className="flex items-center gap-3 p-3 border rounded-lg bg-muted/50"
|
|
90
|
+
>
|
|
91
|
+
<div className="shrink-0">
|
|
92
|
+
{(() => {
|
|
93
|
+
const className = kcClsx(
|
|
94
|
+
authenticator.transports
|
|
95
|
+
.iconClass as any
|
|
96
|
+
);
|
|
97
|
+
const isDefaultIcon =
|
|
98
|
+
className ===
|
|
99
|
+
authenticator.transports
|
|
100
|
+
.iconClass;
|
|
101
|
+
|
|
102
|
+
if (isDefaultIcon) {
|
|
103
|
+
return (
|
|
104
|
+
<Shield className="w-5 h-5 text-muted-foreground" />
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<i
|
|
110
|
+
className={clsx(
|
|
111
|
+
className,
|
|
112
|
+
"text-muted-foreground"
|
|
113
|
+
)}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
})()}
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<div className="flex-1 min-w-0">
|
|
120
|
+
<div
|
|
121
|
+
id={`kc-webauthn-authenticator-label-${i}`}
|
|
122
|
+
className="font-medium text-sm"
|
|
123
|
+
>
|
|
124
|
+
{advancedMsg(authenticator.label)}
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
{authenticator.transports
|
|
128
|
+
.displayNameProperties
|
|
129
|
+
?.length && (
|
|
130
|
+
<div
|
|
131
|
+
id={`kc-webauthn-authenticator-transport-${i}`}
|
|
132
|
+
className="text-xs text-muted-foreground mt-1"
|
|
133
|
+
>
|
|
134
|
+
{authenticator.transports.displayNameProperties
|
|
135
|
+
.map(
|
|
136
|
+
(
|
|
137
|
+
displayNameProperty,
|
|
138
|
+
i,
|
|
139
|
+
arr
|
|
140
|
+
) => ({
|
|
141
|
+
displayNameProperty,
|
|
142
|
+
hasNext:
|
|
143
|
+
i !==
|
|
144
|
+
arr.length - 1
|
|
145
|
+
})
|
|
146
|
+
)
|
|
147
|
+
.map(
|
|
148
|
+
({
|
|
149
|
+
displayNameProperty,
|
|
150
|
+
hasNext
|
|
151
|
+
}) => (
|
|
152
|
+
<Fragment
|
|
153
|
+
key={
|
|
154
|
+
displayNameProperty
|
|
155
|
+
}
|
|
156
|
+
>
|
|
157
|
+
{advancedMsg(
|
|
158
|
+
displayNameProperty
|
|
159
|
+
)}
|
|
160
|
+
{hasNext && (
|
|
161
|
+
<span>
|
|
162
|
+
,{" "}
|
|
163
|
+
</span>
|
|
164
|
+
)}
|
|
165
|
+
</Fragment>
|
|
166
|
+
)
|
|
167
|
+
)}
|
|
168
|
+
</div>
|
|
169
|
+
)}
|
|
170
|
+
|
|
171
|
+
<div className="text-xs text-muted-foreground mt-1">
|
|
172
|
+
<span
|
|
173
|
+
id={`kc-webauthn-authenticator-createdlabel-${i}`}
|
|
174
|
+
>
|
|
175
|
+
{msg(
|
|
176
|
+
"webauthn-createdAt-label"
|
|
177
|
+
)}
|
|
178
|
+
</span>{" "}
|
|
179
|
+
<span
|
|
180
|
+
id={`kc-webauthn-authenticator-created-${i}`}
|
|
181
|
+
>
|
|
182
|
+
{authenticator.createdAt}
|
|
183
|
+
</span>
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
)
|
|
188
|
+
)}
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
)}
|
|
192
|
+
</>
|
|
193
|
+
)}
|
|
194
|
+
|
|
195
|
+
<Button id={webAuthnButtonId} type="button" autoFocus className="w-full">
|
|
196
|
+
<Fingerprint className="w-4 h-4" />
|
|
197
|
+
{msgStr("webauthn-doAuthenticate")}
|
|
198
|
+
</Button>
|
|
199
|
+
</div>
|
|
200
|
+
</Template>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Page } from "./Page";
|
|
2
|
-
|
|
3
|
-
export default Page;
|
|
1
|
+
import { Page } from "./Page";
|
|
2
|
+
|
|
3
|
+
export default Page;
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { useInsertScriptTags } from "@keycloakify/login-ui/tools/useInsertScriptTags";
|
|
2
|
-
import { waitForElementMountedOnDom } from "@keycloakify/login-ui/tools/waitForElementMountedOnDom";
|
|
3
|
-
import { useEffect } from "react";
|
|
4
|
-
import { assert } from "tsafe/assert";
|
|
5
|
-
|
|
6
|
-
import { useKcContext } from "../../KcContext";
|
|
7
|
-
import { useI18n } from "../../i18n";
|
|
8
|
-
|
|
9
|
-
export function useScript(params: { webAuthnButtonId: string }) {
|
|
10
|
-
const { webAuthnButtonId } = params;
|
|
11
|
-
|
|
12
|
-
const { kcContext } = useKcContext();
|
|
13
|
-
assert(kcContext.pageId === "webauthn-authenticate.ftl");
|
|
14
|
-
|
|
15
|
-
const { msgStr, isFetchingTranslations } = useI18n();
|
|
16
|
-
|
|
17
|
-
const { insertScriptTags } = useInsertScriptTags({
|
|
18
|
-
effectId: "WebauthnAuthenticate",
|
|
19
|
-
scriptTags: [
|
|
20
|
-
{
|
|
21
|
-
type: "module",
|
|
22
|
-
textContent: () => `
|
|
23
|
-
|
|
24
|
-
import { authenticateByWebAuthn } from "${import.meta.env.BASE_URL}keycloak-theme/login/js/webauthnAuthenticate.js";
|
|
25
|
-
const authButton = document.getElementById('${webAuthnButtonId}');
|
|
26
|
-
authButton.addEventListener("click", function() {
|
|
27
|
-
const input = {
|
|
28
|
-
isUserIdentified : ${kcContext.isUserIdentified},
|
|
29
|
-
challenge : '${kcContext.challenge}',
|
|
30
|
-
userVerification : '${kcContext.userVerification}',
|
|
31
|
-
rpId : '${kcContext.rpId}',
|
|
32
|
-
createTimeout : ${kcContext.createTimeout},
|
|
33
|
-
errmsg : ${JSON.stringify(msgStr("webauthn-unsupported-browser-text"))}
|
|
34
|
-
};
|
|
35
|
-
authenticateByWebAuthn(input);
|
|
36
|
-
});
|
|
37
|
-
`
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (isFetchingTranslations) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
(async () => {
|
|
48
|
-
await waitForElementMountedOnDom({
|
|
49
|
-
elementId: webAuthnButtonId
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
insertScriptTags();
|
|
53
|
-
})();
|
|
54
|
-
}, [isFetchingTranslations]);
|
|
55
|
-
}
|
|
1
|
+
import { useInsertScriptTags } from "@keycloakify/login-ui/tools/useInsertScriptTags";
|
|
2
|
+
import { waitForElementMountedOnDom } from "@keycloakify/login-ui/tools/waitForElementMountedOnDom";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { assert } from "tsafe/assert";
|
|
5
|
+
|
|
6
|
+
import { useKcContext } from "../../KcContext";
|
|
7
|
+
import { useI18n } from "../../i18n";
|
|
8
|
+
|
|
9
|
+
export function useScript(params: { webAuthnButtonId: string }) {
|
|
10
|
+
const { webAuthnButtonId } = params;
|
|
11
|
+
|
|
12
|
+
const { kcContext } = useKcContext();
|
|
13
|
+
assert(kcContext.pageId === "webauthn-authenticate.ftl");
|
|
14
|
+
|
|
15
|
+
const { msgStr, isFetchingTranslations } = useI18n();
|
|
16
|
+
|
|
17
|
+
const { insertScriptTags } = useInsertScriptTags({
|
|
18
|
+
effectId: "WebauthnAuthenticate",
|
|
19
|
+
scriptTags: [
|
|
20
|
+
{
|
|
21
|
+
type: "module",
|
|
22
|
+
textContent: () => `
|
|
23
|
+
|
|
24
|
+
import { authenticateByWebAuthn } from "${import.meta.env.BASE_URL}keycloak-theme/login/js/webauthnAuthenticate.js";
|
|
25
|
+
const authButton = document.getElementById('${webAuthnButtonId}');
|
|
26
|
+
authButton.addEventListener("click", function() {
|
|
27
|
+
const input = {
|
|
28
|
+
isUserIdentified : ${kcContext.isUserIdentified},
|
|
29
|
+
challenge : '${kcContext.challenge}',
|
|
30
|
+
userVerification : '${kcContext.userVerification}',
|
|
31
|
+
rpId : '${kcContext.rpId}',
|
|
32
|
+
createTimeout : ${kcContext.createTimeout},
|
|
33
|
+
errmsg : ${JSON.stringify(msgStr("webauthn-unsupported-browser-text"))}
|
|
34
|
+
};
|
|
35
|
+
authenticateByWebAuthn(input);
|
|
36
|
+
});
|
|
37
|
+
`
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (isFetchingTranslations) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
(async () => {
|
|
48
|
+
await waitForElementMountedOnDom({
|
|
49
|
+
elementId: webAuthnButtonId
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
insertScriptTags();
|
|
53
|
+
})();
|
|
54
|
+
}, [isFetchingTranslations]);
|
|
55
|
+
}
|