monax-auth-api-0.1.0.0: Servant API types
LicenseAGPL-3.0-or-later
Maintainermonawasensei@gmail.com
Safe HaskellNone
LanguageGHC2024

Monax.Auth.Servant

Description

This module primarily defines SessionIdCookie and AuthSessionIdCookie for identifying and authorizing user sessions for a given operation.

Included are some helper types for form-based authenticate (rather than Basic) to issue tokens and the setSessionIdCookie function for attaching a session token to an http response so that a user can use the session.

Synopsis

Documentation

newtype RunAuthRealm (realm :: Symbol) (m :: Type -> Type) Source #

RunAuth scoped over a certain authorization realm.

Constructors

RunAuthRealm 

Fields

data SessionTokenAndClaims where Source #

A SessionId and the corresponding Claims that that session represents.

Bundled Patterns

pattern SessionTokenAndClaims :: SessionId -> Claims -> SessionTokenAndClaims 

Instances

Instances details
Generic SessionTokenAndClaims Source # 
Instance details

Defined in Monax.Auth.Servant

Associated Types

type Rep SessionTokenAndClaims 
Instance details

Defined in Monax.Auth.Servant

type Rep SessionTokenAndClaims = D1 ('MetaData "SessionTokenAndClaims" "Monax.Auth.Servant" "monax-auth-api-0.1.0.0-inplace" 'False) (C1 ('MetaCons "SessionTokenAndClaims'" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SessionId) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Claims)))
Show SessionTokenAndClaims Source # 
Instance details

Defined in Monax.Auth.Servant

Eq SessionTokenAndClaims Source # 
Instance details

Defined in Monax.Auth.Servant

type Rep SessionTokenAndClaims Source # 
Instance details

Defined in Monax.Auth.Servant

type Rep SessionTokenAndClaims = D1 ('MetaData "SessionTokenAndClaims" "Monax.Auth.Servant" "monax-auth-api-0.1.0.0-inplace" 'False) (C1 ('MetaCons "SessionTokenAndClaims'" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SessionId) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Claims)))

data SessionIdCookie (realm :: Symbol) Source #

Retrieve a SessionTokenAndClaims from a cookie sent in the request.

Instances

Instances details
HasLink api => HasLink (SessionIdCookie realm :> api :: Type) Source # 
Instance details

Defined in Monax.Auth.Servant

Methods

toLink :: (Link -> a) -> Proxy (SessionIdCookie realm :> api) -> Link -> MkLink (SessionIdCookie realm :> api) a #

(HasServer api context, HasContextEntry context (RunAuthRealm realm IO)) => HasServer (SessionIdCookie realm :> api :: Type) context Source # 
Instance details

Defined in Monax.Auth.Servant

Methods

route :: Proxy (SessionIdCookie realm :> api) -> Context context -> Delayed env (Server (SessionIdCookie realm :> api)) -> Router env #

hoistServerWithContext :: Proxy (SessionIdCookie realm :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (SessionIdCookie realm :> api) m -> ServerT (SessionIdCookie realm :> api) n #

type MkLink (SessionIdCookie realm :> api :: Type) a Source # 
Instance details

Defined in Monax.Auth.Servant

type MkLink (SessionIdCookie realm :> api :: Type) a = MkLink api a
type ServerT (SessionIdCookie realm :> api :: Type) m Source # 
Instance details

Defined in Monax.Auth.Servant

newtype AuthenticationRedirectURL (realm :: k) Source #

A link to somewhere a user can authenticate and be issued a session token.

Instances

Instances details
Monoid (AuthenticationRedirectURL realm) Source # 
Instance details

Defined in Monax.Auth.Servant

Semigroup (AuthenticationRedirectURL realm) Source # 
Instance details

Defined in Monax.Auth.Servant

IsString (AuthenticationRedirectURL realm) Source # 
Instance details

Defined in Monax.Auth.Servant

Generic (AuthenticationRedirectURL realm) Source # 
Instance details

Defined in Monax.Auth.Servant

Associated Types

type Rep (AuthenticationRedirectURL realm) 
Instance details

Defined in Monax.Auth.Servant

type Rep (AuthenticationRedirectURL realm) = D1 ('MetaData "AuthenticationRedirectURL" "Monax.Auth.Servant" "monax-auth-api-0.1.0.0-inplace" 'True) (C1 ('MetaCons "AuthenticationRedirectURL" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))
Show (AuthenticationRedirectURL realm) Source # 
Instance details

Defined in Monax.Auth.Servant

Eq (AuthenticationRedirectURL realm) Source # 
Instance details

Defined in Monax.Auth.Servant

type Rep (AuthenticationRedirectURL realm) Source # 
Instance details

Defined in Monax.Auth.Servant

type Rep (AuthenticationRedirectURL realm) = D1 ('MetaData "AuthenticationRedirectURL" "Monax.Auth.Servant" "monax-auth-api-0.1.0.0-inplace" 'True) (C1 ('MetaCons "AuthenticationRedirectURL" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

data AuthSessionIdCookie (realm :: k) Source #

Like SessionIdCookie but throws an auth error if a valid token is not found.

Instances

Instances details
HasLink api => HasLink (AuthSessionIdCookie realm :> api :: Type) Source # 
Instance details

Defined in Monax.Auth.Servant

Methods

toLink :: (Link -> a) -> Proxy (AuthSessionIdCookie realm :> api) -> Link -> MkLink (AuthSessionIdCookie realm :> api) a #

(HasServer api context, KnownSymbol realm, HasContextEntry context (RunAuthRealm realm IO), HasContextEntry context (AuthenticationRedirectURL realm)) => HasServer (AuthSessionIdCookie realm :> api :: Type) context Source # 
Instance details

Defined in Monax.Auth.Servant

Methods

route :: Proxy (AuthSessionIdCookie realm :> api) -> Context context -> Delayed env (Server (AuthSessionIdCookie realm :> api)) -> Router env #

hoistServerWithContext :: Proxy (AuthSessionIdCookie realm :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (AuthSessionIdCookie realm :> api) m -> ServerT (AuthSessionIdCookie realm :> api) n #

type MkLink (AuthSessionIdCookie realm :> api :: Type) a Source # 
Instance details

Defined in Monax.Auth.Servant

type MkLink (AuthSessionIdCookie realm :> api :: Type) a = MkLink api a
type ServerT (AuthSessionIdCookie realm :> api :: Type) m Source # 
Instance details

Defined in Monax.Auth.Servant

data BasicAuthReqBody Source #

A form with "username" and "password" for a user to authenticate with.

Place in front of a POST endpoint.

type AuthenticateAndIssueToken =
    ReqBody '[FormUrlEncoded] BasicAuthReqBody
      :> Post '[JSON] (Headers '[Header "Set-Cookie" Text] Token)

Constructors

BasicAuthReqBody 

Instances

Instances details
Generic BasicAuthReqBody Source # 
Instance details

Defined in Monax.Auth.Servant

Associated Types

type Rep BasicAuthReqBody 
Instance details

Defined in Monax.Auth.Servant

type Rep BasicAuthReqBody = D1 ('MetaData "BasicAuthReqBody" "Monax.Auth.Servant" "monax-auth-api-0.1.0.0-inplace" 'False) (C1 ('MetaCons "BasicAuthReqBody" 'PrefixI 'True) (S1 ('MetaSel ('Just "barbUsername") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "barbPassword") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))
FromForm BasicAuthReqBody Source # 
Instance details

Defined in Monax.Auth.Servant

type Rep BasicAuthReqBody Source # 
Instance details

Defined in Monax.Auth.Servant

type Rep BasicAuthReqBody = D1 ('MetaData "BasicAuthReqBody" "Monax.Auth.Servant" "monax-auth-api-0.1.0.0-inplace" 'False) (C1 ('MetaCons "BasicAuthReqBody" 'PrefixI 'True) (S1 ('MetaSel ('Just "barbUsername") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "barbPassword") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

setSessionIdCookie :: AddHeader '[Optional, Strict] "Set-Cookie" Text orig new => Token -> Text -> orig -> new Source #

Set the "session-token"" cookie value given a Token. Also sets the Path attribute to the given Text. "/" is a fine default.