postgrest- REST API for any Postgres database

Safe HaskellNone



This module provides functions to deal with the JWT authorization ( It also can be used to define other authorization functions, in the future Oauth, LDAP and similar integrations can be coded here.

Authentication should always be implemented in an external service. In the test suite there is an example of simple login function that can be used for a very simple authentication system inside the PostgreSQL database.



claimsToSQL :: HashMap Text Value -> [ByteString] Source #

Receives a map of JWT claims and returns a list of PostgreSQL statements to set the claims as user defined GUCs. Except if we have a claim called role, this one is mapped to a SET ROLE statement.

containsRole :: Either Text (HashMap Text Value) -> Bool Source #

Whether a response from jwtClaims contains a role claim

jwtClaims :: Secret -> Text -> NominalDiffTime -> Either Text (HashMap Text Value) Source #

Receives the JWT secret (from config) and a JWT and returns a map of JWT claims In case there is any problem decoding the JWT it returns an error Text

tokenJWT :: Secret -> Value -> Text Source #

Receives the JWT secret (from config) and a JWT and a JSON value and returns a signed JWT.