package jwto

  1. Overview
  2. Docs
JWT encoding, decoding and verification

Install

Dune Dependency

Authors

Maintainers

Sources

0.3.0.tar.gz
md5=cc238a4a7d319d37579a930912a68d04
sha512=cd89bc9d2fedc483329ca328fd8895bd49b24f171d8cef27fe34a28612cbbdc88eff7babc810c7967c310aa8056fdfef08bf0693c27e6541a649507b8c7963bb

README.md.html

Ocaml JWT

Create a token

A payload is a list of tuples (string, string):

let payload =
  [
    ("user", "sam);
    ("age", "17");
  ]

Jwto.make Jwto.HS256 "secret" payload

Jwto.make returns a signed token (type Jwto.t):

{
  header = ...;
  payload = [...]; 
  signature = ...;
}

Encode token

Jwto.encode Jwto.HS256 "secret" payload

-->

"eyJhbGciOiJIUzI1NiJ9...."

Decode token

Just decode the token, doesn't verify.

Jwto.decode "eyJhbGciOiJIUzI1NiJ9...."

-->

Ok { header = ...; payload = [...]; signature = ... }	

Decode and verify

Verify and decode. If the verification fails you will get an Error.

Jwto.decode_and_verify "secret" "eyJhbGciOiJIUzI1NiJ9...."

-->

Ok { header = ...; payload = [...]; signature = ... }

Verify only

Jwto.is_valid "secet" "eyJhbGciOiJIUzI1NiJ9...."

-->

true
OCaml

Innovation. Community. Security.