maca/postgrest-admin-preview/14.0.0

NOTE: the latest version is 15.0.0

Rerouted (regenerated, verified). Same repository and tag, but GitHub now builds the zip with different bytes, so it no longer matches the SHA-1 package.elm-lang.org recorded. The Lamdera package server serves a copy recovered from https://github.com/maca/postgrest-admin-preview.

What we checked: Rebuilt with git archive from commit a4172133f66f of https://github.com/maca/postgrest-admin-preview (zip prefix maca-postgrest-admin-preview-a417213/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 9aec4cc7e375efcaee040afbb8bc6c35e05ebecf.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/maca/postgrest-admin-preview/zipball/14.0.0/

PostgRestAdmin.Config.FormAuth

Configuration for form based authentication.

Tipically user credentials are exchanged for a JWT, to the PostgREST instance or to an external authentication provided.

This module provides configuration functions for defining what is the authentication form POST url, how the credentials are to be encoded and how the JWT is to be decoded. FormAuth configurations are to be used with Config.formAuth.

See PostgREST documentation to get a better understanding of JWT and roles in PostgREST.

Config

type alias FormAuth =
Decoder FormAuth

Basic authentication configuration.

config : FormAuth

Create a authentication configuration.

Host

authUrl : String -> FormAuth -> FormAuth

Set authentication request login url. Credentials are to be exchanged for a JWT via a post request.

authUrl "http://localhost:3000/rpc/login" config

Alternatively the host can be specified using flags, configuring using authUrl. Program flags take precedence.

Elm.Main.init
    { flags = { authUrl = "http://localhost:3000/rpc/login" }
    }

Encode/Decode

encoder : (Dict String String -> Value) -> FormAuth -> FormAuth

Override the credentials JSON encoder to be used when posting to the login url.

encoder
    (\creds ->
        Encode.object
            [ ( "credentials"
              , Encode.dict identity Encode.string creds
              )
            ]
    )
    config
decoder : Decoder String -> FormAuth -> FormAuth

Override the JSON decoder used to obtain the JWT from the login response.

decoder (Decode.at [ "auth", "jwt" ] Decode.string) config