License | AGPL-3.0-or-later |
---|---|
Maintainer | monawasensei@gmail.com |
Safe Haskell | None |
Language | GHC2024 |
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
- newtype RunAuthRealm (realm :: Symbol) (m :: Type -> Type) = RunAuthRealm {
- runAuthRealm :: RunAuth m
- data SessionTokenAndClaims where
- pattern SessionTokenAndClaims :: SessionId -> Claims -> SessionTokenAndClaims
- sessionTokenAndClaimsSessionId :: SessionTokenAndClaims -> SessionId
- sessionTokenAndClaimsClaims :: SessionTokenAndClaims -> Claims
- data SessionIdCookie (realm :: Symbol)
- newtype AuthenticationRedirectURL (realm :: k) = AuthenticationRedirectURL Text
- data AuthSessionIdCookie (realm :: k)
- data BasicAuthReqBody = BasicAuthReqBody {
- barbUsername :: Text
- barbPassword :: Text
- setSessionIdCookie :: AddHeader '[Optional, Strict] "Set-Cookie" Text orig new => Token -> Text -> orig -> new
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
sessionTokenAndClaimsSessionId :: SessionTokenAndClaims -> SessionId Source #
Get SessionId
sessionTokenAndClaimsClaims :: SessionTokenAndClaims -> Claims Source #
Get Claims
data SessionIdCookie (realm :: Symbol) Source #
Retrieve a SessionTokenAndClaims
from a cookie sent in the request.
Instances
HasLink api => HasLink (SessionIdCookie realm :> api :: Type) Source # | |
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 # | |
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 # | |
Defined in Monax.Auth.Servant | |
type ServerT (SessionIdCookie realm :> api :: Type) m Source # | |
Defined in Monax.Auth.Servant type ServerT (SessionIdCookie realm :> api :: Type) m = Maybe SessionTokenAndClaims -> ServerT api m |
newtype AuthenticationRedirectURL (realm :: k) Source #
A link to somewhere a user can authenticate and be issued a session token.
Constructors
AuthenticationRedirectURL Text |
Instances
Monoid (AuthenticationRedirectURL realm) Source # | |||||
Defined in Monax.Auth.Servant Methods mempty :: AuthenticationRedirectURL realm # mappend :: AuthenticationRedirectURL realm -> AuthenticationRedirectURL realm -> AuthenticationRedirectURL realm # mconcat :: [AuthenticationRedirectURL realm] -> AuthenticationRedirectURL realm # | |||||
Semigroup (AuthenticationRedirectURL realm) Source # | |||||
Defined in Monax.Auth.Servant Methods (<>) :: AuthenticationRedirectURL realm -> AuthenticationRedirectURL realm -> AuthenticationRedirectURL realm # sconcat :: NonEmpty (AuthenticationRedirectURL realm) -> AuthenticationRedirectURL realm # stimes :: Integral b => b -> AuthenticationRedirectURL realm -> AuthenticationRedirectURL realm # | |||||
IsString (AuthenticationRedirectURL realm) Source # | |||||
Defined in Monax.Auth.Servant Methods fromString :: String -> AuthenticationRedirectURL realm # | |||||
Generic (AuthenticationRedirectURL realm) Source # | |||||
Defined in Monax.Auth.Servant Associated Types
Methods from :: AuthenticationRedirectURL realm -> Rep (AuthenticationRedirectURL realm) x # to :: Rep (AuthenticationRedirectURL realm) x -> AuthenticationRedirectURL realm # | |||||
Show (AuthenticationRedirectURL realm) Source # | |||||
Defined in Monax.Auth.Servant Methods showsPrec :: Int -> AuthenticationRedirectURL realm -> ShowS # show :: AuthenticationRedirectURL realm -> String # showList :: [AuthenticationRedirectURL realm] -> ShowS # | |||||
Eq (AuthenticationRedirectURL realm) Source # | |||||
Defined in Monax.Auth.Servant Methods (==) :: AuthenticationRedirectURL realm -> AuthenticationRedirectURL realm -> Bool # (/=) :: AuthenticationRedirectURL realm -> AuthenticationRedirectURL realm -> Bool # | |||||
type Rep (AuthenticationRedirectURL realm) Source # | |||||
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
HasLink api => HasLink (AuthSessionIdCookie realm :> api :: Type) Source # | |
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 # | |
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 # | |
Defined in Monax.Auth.Servant | |
type ServerT (AuthSessionIdCookie realm :> api :: Type) m Source # | |
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 | |
Fields
|
Instances
Generic BasicAuthReqBody Source # | |||||
Defined in Monax.Auth.Servant Associated Types
Methods from :: BasicAuthReqBody -> Rep BasicAuthReqBody x # to :: Rep BasicAuthReqBody x -> BasicAuthReqBody # | |||||
FromForm BasicAuthReqBody Source # | |||||
Defined in Monax.Auth.Servant | |||||
type Rep BasicAuthReqBody Source # | |||||
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))) |