graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.Server.Auth

Synopsis

Documentation

class Monad m => UserAuthentication m where Source #

Typeclass representing the UserInfo authorization and resolving effect

Methods

resolveUserInfo Source #

Arguments

:: Logger Hasura 
-> Manager 
-> [Header]

request headers

-> AuthMode 
-> Maybe ReqsText 
-> m (Either QErr (UserInfo, Maybe UTCTime, [Header])) 

Instances

Instances details
(MonadIO m, MonadBaseControl IO m) => UserAuthentication (TraceT (PGMetadataStorageAppT m)) Source # 
Instance details

Defined in Hasura.App

Methods

resolveUserInfo :: Logger Hasura -> Manager -> [Header] -> AuthMode -> Maybe ReqsText -> TraceT (PGMetadataStorageAppT m) (Either QErr (UserInfo, Maybe UTCTime, [Header])) Source #

newtype AdminSecretHash Source #

The hashed admin password. hashAdminSecret is our public interface for constructing the secret.

To prevent misuse and leaking we keep this opaque and don't provide instances that could leak information. Likewise for AuthMode.

Although this exists only in memory we store only a hash of the admin secret primarily in order to:

  • prevent theoretical timing attacks from a naive == check
  • prevent misuse or inadvertent leaking of the secret

Constructors

AdminSecretHash (Digest SHA512) 

data AuthMode Source #

The methods we'll use to derive roles for authenticating requests.

Maybe RoleName below is the optionally-defined role for the unauthenticated (anonymous) user.

See: https://hasura.io/docs/latest/graphql/core/auth/authentication/unauthenticated-access.html

Instances

Instances details
Eq AuthMode Source # 
Instance details

Defined in Hasura.Server.Auth

Show AuthMode Source # 
Instance details

Defined in Hasura.Server.Auth

setupAuthMode :: (ForkableMonadIO m, HasReporter m) => HashSet AdminSecretHash -> Maybe AuthHook -> [JWTConfig] -> Maybe RoleName -> Manager -> Logger Hasura -> ExceptT Text (ManagedT m) AuthMode Source #

Validate the user's requested authentication configuration, launching any required maintenance threads for JWT etc.

This must only be run once, on launch.

getUserInfoWithExpTime :: forall m. (MonadIO m, MonadBaseControl IO m, MonadError QErr m, MonadTrace m) => Logger Hasura -> Manager -> [Header] -> AuthMode -> Maybe ReqsText -> m (UserInfo, Maybe UTCTime, [Header]) Source #

Authenticate the request using the headers and the configured AuthMode.

getUserInfoWithExpTime_ Source #

Arguments

:: forall m mgr logger. (MonadIO m, MonadError QErr m) 
=> (logger -> mgr -> AuthHook -> [Header] -> Maybe ReqsText -> m (UserInfo, Maybe UTCTime, [Header]))

mock userInfoFromAuthHook

-> ([JWTCtx] -> [Header] -> Maybe RoleName -> m (UserInfo, Maybe UTCTime, [Header]))

mock processJwt

-> logger 
-> mgr 
-> [Header] 
-> AuthMode 
-> Maybe ReqsText 
-> m (UserInfo, Maybe UTCTime, [Header])