A Clojure library designed to sign and verity tokens using the itsdangerous scheme.
ItsDangerous relies on the following shared knowledge:
These must be decided out of band between signing and verifying parties.
To sign a payload, use the exoscale.itsdangerous/sign function:
(sign {:exoscale.itsdangerous/algorithm :exoscale.itsdangerous/hmac-sha256
:exoscale.itsdangerous/private-key "A-SECRET-KEY"
:exoscale.itsdangerous/salt "session"
:exoscale.itsdangerous/payload "{\"user-id\": 1234}"})
;; => "some-token"
(verify {:exoscale.itsdangerous/algorithm :exoscale.itsdangerous/hmac-sha256
:exoscale.itsdangerous/private-key "A-SECRET-KEY"
:exoscale.itsdangerous/salt "session"
:exoscale.itsdangerous/token some-token})
;; => "{\"user-id\": 1234}"
By default, a produced token contains a timestamp. This timestamp is the UNIX
epoch in seconds and can be overriden by adding a value
to the :exoscale.itsdangerous/timestamp key in the input map to sign.
When verifying, an optional exoscale.itsdangerous/max-age key can be
added to the map. When a token's signature is valid, but has been signed
more than the value given to max-age the verifying process will fail.
exoscale.itsdangerous/verify always yield the payload or throws exceptions.
Can you improve this documentation? These fine people already did:
Yoan Blanc & Pierre-Yves RitschardEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |