Liking cljdoc? Tell your friends :D

cljwebauthn.core


*challenges*clj

source

decode-client-dataclj

(decode-client-data data)

Decode the client data by parsing its JSON content.

Decode the client data by parsing its JSON content.
sourceraw docstring

eliptic-curveclj

source

generate-challengeclj

(generate-challenge)

Generate a challenge for both registration and login.

Generate a challenge for both registration and login.
sourceraw docstring

login-userclj

(login-user {:keys [credential-id user-handle authenticator-data client-data
                    signature challenge]}
            {:keys [protocol host port]}
            get-authenticator)

Login a user using Webauthn.

Example:

(clogin-user
  {:credential-id      "ARkFqKfCJaxgXG4m53c2y3zWpxSZGriN0sH...qt57yU="
   :user-handle        "Zm9vQGJhci5jb20="
   :authenticator-data "09CVCOxdEGxTwSc5mFML...3Wl3siTnwk0FXo82Tg=="
   :client-data        "eyJjaGFsbGVuZ2UiOiJabTl2WW1...G4uZ2V0In0="
   :signature          "MEUCIQCkfqWpAhi7CRO0exa2wenWgDaakqJ..gv+gI1roY="
   :challenge          "439cf387-25a9-40bc-a36a-bb84168e5f54"}
 {:site-id   "grison.me",
   :site-name "Stuff and Thoughts about IT Stuff",
   :protocol  "https",
   :port      443,
   :host      "grison.me"}
 (fn [user-id]
    ; retrieve the authenticator associated with user-id
 ))
=> {:user-id "foo@bar.com" :challenge "439cf387-25a9-40bc-a36a-bb84168e5f54"}
Login a user using Webauthn.

  Example:
  ```clojure
  (clogin-user
    {:credential-id      "ARkFqKfCJaxgXG4m53c2y3zWpxSZGriN0sH...qt57yU="
     :user-handle        "Zm9vQGJhci5jb20="
     :authenticator-data "09CVCOxdEGxTwSc5mFML...3Wl3siTnwk0FXo82Tg=="
     :client-data        "eyJjaGFsbGVuZ2UiOiJabTl2WW1...G4uZ2V0In0="
     :signature          "MEUCIQCkfqWpAhi7CRO0exa2wenWgDaakqJ..gv+gI1roY="
     :challenge          "439cf387-25a9-40bc-a36a-bb84168e5f54"}
   {:site-id   "grison.me",
     :site-name "Stuff and Thoughts about IT Stuff",
     :protocol  "https",
     :port      443,
     :host      "grison.me"}
   (fn [user-id]
      ; retrieve the authenticator associated with user-id
   ))
=> {:user-id "foo@bar.com" :challenge "439cf387-25a9-40bc-a36a-bb84168e5f54"}
  ```
sourceraw docstring

prepare-loginclj

(prepare-login user-id get-authenticator)

Prepare user login using WebAuthn.

Returns both a challenge and the credential-id used upon registration.

Example:

(prepare-login
  "foo@bar.com"
  (fn [user-id]
    ; retrieve the authenticator for user-id
  ))
=> {:challenge   #uuid "439cf387-25a9-40bc-a36a-bb84168e5f54"
  :credentials [{:type "public-key"
                 :id   "AWcH5uwgu/phBRUWh6B9A2...tg54nA=="}]}
Prepare user login using WebAuthn.

  Returns both a challenge and the credential-id used upon registration.

  Example:
  ```clojure
  (prepare-login
    "foo@bar.com"
    (fn [user-id]
      ; retrieve the authenticator for user-id
    ))
=> {:challenge   #uuid "439cf387-25a9-40bc-a36a-bb84168e5f54"
    :credentials [{:type "public-key"
                   :id   "AWcH5uwgu/phBRUWh6B9A2...tg54nA=="}]}
  ```
sourceraw docstring

prepare-registrationclj

(prepare-registration user-id properties)
(prepare-registration user-id can-register-user properties)

Prepare a user for registration by generating a challenge and giving the information needed by the browser to follow with the registration process.

The user-id variable can be anything, it's usually an e-mail.

The method will call the given can-register-user function before preparing for registration.

Example:

(prepare-registration
  "foo@bar.com"
  {:site-id   "grison.me",
   :site-name "Stuff and Thoughts about IT Stuff",
   :protocol  "https",
   :port      443,
   :host      "grison.me"})
=> {:rp        {:id  "grison.me"
              :name "Stuff and Thoughts about IT Stuff"}
  :user      {:id "Zm9vQGJhci5jb20="}
  :cred      [{:type "public-key"
               :alg  -7}]
  :challenge #uuid "439cf387-25a9-40bc-a36a-bb84168e5f54"}
Prepare a user for registration by generating a challenge and
  giving the information needed by the browser to follow with the
  registration process.

  The `user-id` variable can be anything, it's usually an e-mail.

  The method will call the given `can-register-user` function before preparing
  for registration.

  Example:
  ```clojure
  (prepare-registration
    "foo@bar.com"
    {:site-id   "grison.me",
     :site-name "Stuff and Thoughts about IT Stuff",
     :protocol  "https",
     :port      443,
     :host      "grison.me"})
=> {:rp        {:id  "grison.me"
                :name "Stuff and Thoughts about IT Stuff"}
    :user      {:id "Zm9vQGJhci5jb20="}
    :cred      [{:type "public-key"
                 :alg  -7}]
    :challenge #uuid "439cf387-25a9-40bc-a36a-bb84168e5f54"}
  ```
sourceraw docstring

register-userclj

(register-user {:keys [attestation client-data challenge]}
               {:keys [protocol host port]}
               save-authenticator)

Register a user given its attestation, client-data and challenge.

The save authenticator function takes both the user-id and the authenticator to be saved so that it can be retrieved during login operation.

Example:

(register-user
  {:attestation "o2NmbXRmcGFja2VkZ2F0dFN0bXSiY2FsZ...dbaqAkCY1nvQuI="
   :client-data "eyJjaGFsbGVuZ2UiOiJabTl2...ZWF0ZSJ9"
   :challenge   "439cf387-25a9-40bc-a36a-bb84168e5f54"}
  {:site-id   "grison.me",
   :site-name "Stuff and Thoughts about IT Stuff",
   :protocol  "https",
   :port      443,
   :host      "grison.me"}
   (fn [user-id authenticator]
     ; save the authenticator for user-id somewhere
   ))
=> {:user-id "foo@bar.com" :challenge "439cf387-25a9-40bc-a36a-bb84168e5f54"}
Register a user given its attestation, client-data and challenge.

  The save authenticator function takes both the user-id and the authenticator
  to be saved so that it can be retrieved during login operation.

  Example:
  ```clojure
  (register-user
    {:attestation "o2NmbXRmcGFja2VkZ2F0dFN0bXSiY2FsZ...dbaqAkCY1nvQuI="
     :client-data "eyJjaGFsbGVuZ2UiOiJabTl2...ZWF0ZSJ9"
     :challenge   "439cf387-25a9-40bc-a36a-bb84168e5f54"}
    {:site-id   "grison.me",
     :site-name "Stuff and Thoughts about IT Stuff",
     :protocol  "https",
     :port      443,
     :host      "grison.me"}
     (fn [user-id authenticator]
       ; save the authenticator for user-id somewhere
     ))
=> {:user-id "foo@bar.com" :challenge "439cf387-25a9-40bc-a36a-bb84168e5f54"}
   ```
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close