OfficialSPIAuthenticationActive
keycloak-magic-link
Passwordless magic-link login.マジックリンク(パスワードレス)認証
A COPYING file exists; license type not confirmed.
- ★
- 430
- Forks
- 121
- Contributors
- 39
- Updated
- 2026-10-20
- KC
- 26.8.0
- License
- Other (see repo)
What it can doできること7
- Passwordless login with a magic link sent by email, using an action token so the link also works when opened on another device (e.g. desktop login, phone click).メールのマジックリンクでパスワードレスログイン。Action Tokenを使うため、別端末で開いても有効(PCでログインしてスマホでクリック、など)
- Optionally create the user on first use and force
UPDATE_PROFILE/UPDATE_PASSWORD.初回に自動でユーザーを作成し、UPDATE_PROFILE/UPDATE_PASSWORDを強制することもできる - "Magic link continuation": confirm via email while the original login page polls and completes the login there (10 minute default expiry).「Magic link continuation」では、メールで承認すると元のログイン画面がポーリングしてそこでログインが完了する(有効期限は既定10分)
- Generate magic links through a REST API (
manage-usersrole), with expiry, reusability, PKCE/state/nonce and response mode, and either email them or return them to the caller.REST API(manage-usersロール)でリンクを発行できる。有効期限、再利用可否、PKCE/state/nonce、レスポンスモードを指定でき、メール送信か呼び出し元への返却かを選べる - "Login Token": a variant that runs the normal browser flow, so
acr_values, step-up and TOTP still apply.「Login Token」方式は通常のブラウザフローを通すため、acr_values・ステップアップ・TOTPも効く - Also includes an email OTP (6 digits) authenticator, account-activation authenticators and Cloudflare Turnstile CAPTCHA.メールOTP(6桁)、アカウント有効化用のAuthenticator、Cloudflare Turnstile CAPTCHAも同梱
- Extend the behaviour through an SPI (
MagicLinkCustomizationProvider) instead of forking.フォークせずにSPI(MagicLinkCustomizationProvider)で挙動を拡張できる
What it cannot do / limitsできないこと・制約6
- Licensed under the Elastic License 2.0 — not an OSI open-source license; check the terms before commercial use.ライセンスはElastic License 2.0で、OSI準拠のOSSライセンスではない。商用利用前に条件を確認
- Links from the REST API (action token) log the user in directly and skip the authentication flow, so step-up /
acr_valuesare not evaluated (use Login Token for that).REST APIで発行したリンク(Action Token)はフローを通らず直接ログインするため、ステップアップやacr_valuesは評価されない(必要ならLogin Tokenを使う) - The continuation authenticator cannot be customised through the SPI — email sending and user validation are fixed.continuation方式はSPIでカスタマイズできない(メール送信とユーザー検証は固定)
- Implementation classes are
final; behaviour can only be changed through the SPI.実装クラスはfinalで、挙動の変更はSPI経由でしかできない - With SPAs such as keycloak-js on Keycloak ≥ 26.6.5, links without
state+ a matchingresponse_modefail withInvalid parameter: redirect_uri.keycloak-jsなどのSPAでは、Keycloak 26.6.5以降だとstateと合致するresponse_modeを付けないリンクはInvalid parameter: redirect_uriで失敗する - Login Token requires
prompt=login, otherwise an existing session cookie causes an "already authenticated as different user" error.Login Tokenはprompt=loginが必須。付けないと既存セッションのCookieにより "already authenticated as different user" エラーになる
Requirements前提条件
- Copy the JAR into
providersand rebuild/restart Keycloak (or use the Phase Two image).JARをprovidersに置いてKeycloakを再ビルド/再起動(またはPhase Twoのイメージを使う) - Configured SMTP for sending emails.メール送信用のSMTP設定