Liking cljdoc? Tell your friends :D

flybot.oie.magic-link


(create-magic-link-token {:keys [secret email nonce expires-at]})

Creates an HMAC-signed magic link token. secret — HMAC key string. email — the user's email. nonce — random single-use nonce (caller generates and stores this). expires-at — expiry as epoch ms. Returns a URL-safe token string: base64url(email|nonce|expires-at).base64url(signature).

Creates an HMAC-signed magic link token.
`secret` — HMAC key string.
`email` — the user's email.
`nonce` — random single-use nonce (caller generates and stores this).
`expires-at` — expiry as epoch ms.
Returns a URL-safe token string: `base64url(email|nonce|expires-at).base64url(signature)`.
sourceraw docstring

(wrap-magic-link handler
                 {:keys [verify-uri request-uri token-param request-param clock]
                  :or {token-param "token"
                       request-param "email"
                       clock (fn* [] (System/currentTimeMillis))}
                  :as config})

Ring middleware for magic link authentication. Intercepts verify-uri (GET) to verify tokens and create sessions, and request-uri (POST) to create and deliver tokens. All other requests pass through.

Config:

  • verify-uri — URI path to intercept for verification
  • request-uri — URI path to intercept for token creation (POST)
  • secret — HMAC key string
  • consume-nonce(fn [nonce] -> truthy | nil), atomically consume nonce
  • store-nonce(fn [nonce email expires-at]), persist nonce
  • send-fn(fn [email token]), deliver the token to the user
  • login-fn(fn [profile] -> identity | nil), app-level authorization
  • success-redirect-uri — string or (fn [req] -> uri) Identity is stored in session under ::session/user.
  • token-ttl — token lifetime in ms
  • token-param — query param name, defaults to "token"
  • request-param — param name for email, defaults to "email"
  • clock(fn [] -> epoch-ms), defaults to System/currentTimeMillis
Ring middleware for magic link authentication.
Intercepts `verify-uri` (GET) to verify tokens and create sessions,
and `request-uri` (POST) to create and deliver tokens.
All other requests pass through.

Config:
- `verify-uri` — URI path to intercept for verification
- `request-uri` — URI path to intercept for token creation (POST)
- `secret` — HMAC key string
- `consume-nonce` — `(fn [nonce] -> truthy | nil)`, atomically consume nonce
- `store-nonce` — `(fn [nonce email expires-at])`, persist nonce
- `send-fn` — `(fn [email token])`, deliver the token to the user
- `login-fn` — `(fn [profile] -> identity | nil)`, app-level authorization
- `success-redirect-uri` — string or `(fn [req] -> uri)`
Identity is stored in session under `::session/user`.
- `token-ttl` — token lifetime in ms
- `token-param` — query param name, defaults to `"token"`
- `request-param` — param name for email, defaults to `"email"`
- `clock` — `(fn [] -> epoch-ms)`, defaults to `System/currentTimeMillis`
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close