package jwto
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=d77316759763070495e6484eb1226d936eb6d3d1aa1126187f512f2efdc86ca3
sha512=4daa12af774b69bf46fe1d61982c3ceba8c4cef08319926b9f639334f12c1624ea1eebe51208f8d5d8d32ea48935eb48e0db1d8679242479e5565e0b2626dcce
Description
JWT encoding, decoding and verification
Added to opam-repository:
README
Ocaml JWT
Create and encode a signed token
A payload is a list of tuples (string, string):
let payload =
[
("user", "sam");
("age", "17");
]For the signature algorithm, Jwto supports HMAC applied to SHA-256 or SHA-512.
We can sign and encode the payload in one go by doing:
Jwto.encode Jwto.HS256 "secret" payload
-->
"eyJhbGciOiJIUzI1NiJ9..."Decode token
To decode the token without verifying it, and get a Jwto.t:
let signed_token =
match Jwto.decode "eyJhbGciOiJIUzI1NiJ9..." with
| Ok t -> t
| Error err -> failwith err
-->
{ header = ...; payload = [...]; signature = ... } Verify token
Jwto.is_valid "secret" signed_token
-->
trueDecode and verify
To decode and verify the token in one go:
Jwto.decode_and_verify "secret" "eyJhbGciOiJIUzI1NiJ9..."
-->
Ok { header = ...; payload = [...]; signature = ... }If the verification fails, you will get an Error.
Dependencies (8)
Optional Dependencies
None
Conflicts
None
Build status
Results of building jwto with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 0.4.0 (this version) | good | good | good | good | good |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure