Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
include Sihl_contract.Token.Sig
include Sihl_core.Container.Service.Sig
val create :
?secret:string ->
?expires_in:Sihl_core.Time.duration ->
(string * string) list ->
string Lwt.t
create ?expires_in ?secret data
returns a token that expires in expires_in
with the associated data data
. If no expires_in
is set, the default is 7 days. An optional secret secret
can be provided for the token signature, by default `SIHL_SECRET` is used.
read ?secret ?force token k
returns the value that is associated with the key k
in the token token
. If force
is set, the value is read and returned even if the token is expired, deactivated and the signature is invalid. If the token is completely invalid and can not be read, no value is returned. An optional secret secret
can be provided to override the default `SIHL_SECRET`.
read_all ?secret ?force token
returns all key-value pairs associated with the token token
. If force
is set, the values are read and returned even if the token is expired, deactivated and the signature is invalid. If the token is completely invalid and can not be read, no value is returned. An optional secret secret
can be provided to override the default `SIHL_SECRET`.
verify ?secret token
returns true if the token has a valid structure and the signature is valid, false otherwise. An optional secret secret
can be provided to override the default `SIHL_SECRET`.
deactivate token
deactivates the token. Depending on the backend of the token service a blacklist is used to store the token.
activate token
re-activates the token. Depending on the backend of the token service a blacklist is used to store the token.
is_active token
returns true if the token is active, false if the token was deactivated. An expired token or a token that has an invalid signature is not necessarily inactive.
is_expired token
returns true if the token is expired, false otherwise. An optional secret secret
can be provided to override the default `SIHL_SECRET`.
val lifecycle : unit -> Sihl_core.Container.Lifecycle.t
val register :
(module Sihl_contract.Token.Sig) ->
Sihl_core.Container.Service.t