servant-auth-token-0.5.4.0: Servant based API and server for token based authorisation

Copyright(c) Anton Gushcha 2016
LicenseMIT
Maintainerncrashed@gmail.com
Stabilityexperimental
PortabilityPortable
Safe HaskellNone
LanguageHaskell2010

Servant.Server.Auth.Token

Contents

Description

The module is server side implementation of Servant.API.Auth.Token API and intended to be used as drop in module for user servers or as external micro service.

Use guardAuthToken to check authorisation headers in endpoints of your server:

-- | Read a single customer from DB
customerGet :: CustomerId -- ^ Customer unique id
  -> MToken' '["customer-read"] -- ^ Required permissions for auth token
  -> ServerM Customer -- ^ Customer data
customerGet i token = do
  guardAuthToken token
  guard404 "customer" $ getCustomer i
Synopsis

Implementation

authServer :: AuthHandler m => ServerT AuthAPI m Source #

Implementation of AuthAPI

Server API

class MonadIO m => HasStorage m where Source #

Abstract storage interface. External libraries can implement this in terms of PostgreSQL or acid-state.

Methods

getUserImpl :: UserImplId -> m (Maybe UserImpl) Source #

Getting user from storage

getUserImpl :: (m ~ t n, MonadTrans t, HasStorage n) => UserImplId -> m (Maybe UserImpl) Source #

Getting user from storage

getUserImplByLogin :: Login -> m (Maybe (WithId UserImplId UserImpl)) Source #

Getting user from storage by login

getUserImplByLogin :: (m ~ t n, MonadTrans t, HasStorage n) => Login -> m (Maybe (WithId UserImplId UserImpl)) Source #

Getting user from storage by login

listUsersPaged :: Page -> PageSize -> m ([WithId UserImplId UserImpl], Word) Source #

Get paged list of users and total count of users

listUsersPaged :: (m ~ t n, MonadTrans t, HasStorage n) => Page -> PageSize -> m ([WithId UserImplId UserImpl], Word) Source #

Get paged list of users and total count of users

getUserImplPermissions :: UserImplId -> m [WithId UserPermId UserPerm] Source #

Get user permissions, ascending by tag

getUserImplPermissions :: (m ~ t n, MonadTrans t, HasStorage n) => UserImplId -> m [WithId UserPermId UserPerm] Source #

Get user permissions, ascending by tag

deleteUserPermissions :: UserImplId -> m () Source #

Delete user permissions

deleteUserPermissions :: (m ~ t n, MonadTrans t, HasStorage n) => UserImplId -> m () Source #

Delete user permissions

insertUserPerm :: UserPerm -> m UserPermId Source #

Insertion of new user permission

insertUserPerm :: (m ~ t n, MonadTrans t, HasStorage n) => UserPerm -> m UserPermId Source #

Insertion of new user permission

insertUserImpl :: UserImpl -> m UserImplId Source #

Insertion of new user

insertUserImpl :: (m ~ t n, MonadTrans t, HasStorage n) => UserImpl -> m UserImplId Source #

Insertion of new user

replaceUserImpl :: UserImplId -> UserImpl -> m () Source #

Replace user with new value

replaceUserImpl :: (m ~ t n, MonadTrans t, HasStorage n) => UserImplId -> UserImpl -> m () Source #

Replace user with new value

deleteUserImpl :: UserImplId -> m () Source #

Delete user by id

deleteUserImpl :: (m ~ t n, MonadTrans t, HasStorage n) => UserImplId -> m () Source #

Delete user by id

hasPerm :: UserImplId -> Permission -> m Bool Source #

Check whether the user has particular permission

hasPerm :: (m ~ t n, MonadTrans t, HasStorage n) => UserImplId -> Permission -> m Bool Source #

Check whether the user has particular permission

getFirstUserByPerm :: Permission -> m (Maybe (WithId UserImplId UserImpl)) Source #

Get any user with given permission

getFirstUserByPerm :: (m ~ t n, MonadTrans t, HasStorage n) => Permission -> m (Maybe (WithId UserImplId UserImpl)) Source #

Get any user with given permission

selectUserImplGroups :: UserImplId -> m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

Select user groups and sort them by ascending name

selectUserImplGroups :: (m ~ t n, MonadTrans t, HasStorage n) => UserImplId -> m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

Select user groups and sort them by ascending name

clearUserImplGroups :: UserImplId -> m () Source #

Remove user from all groups

clearUserImplGroups :: (m ~ t n, MonadTrans t, HasStorage n) => UserImplId -> m () Source #

Remove user from all groups

insertAuthUserGroup :: AuthUserGroup -> m AuthUserGroupId Source #

Add new user group

insertAuthUserGroup :: (m ~ t n, MonadTrans t, HasStorage n) => AuthUserGroup -> m AuthUserGroupId Source #

Add new user group

insertAuthUserGroupUsers :: AuthUserGroupUsers -> m AuthUserGroupUsersId Source #

Add user to given group

insertAuthUserGroupUsers :: (m ~ t n, MonadTrans t, HasStorage n) => AuthUserGroupUsers -> m AuthUserGroupUsersId Source #

Add user to given group

insertAuthUserGroupPerms :: AuthUserGroupPerms -> m AuthUserGroupPermsId Source #

Add permission to given group

insertAuthUserGroupPerms :: (m ~ t n, MonadTrans t, HasStorage n) => AuthUserGroupPerms -> m AuthUserGroupPermsId Source #

Add permission to given group

getAuthUserGroup :: AuthUserGroupId -> m (Maybe AuthUserGroup) Source #

Find user group by id

getAuthUserGroup :: (m ~ t n, MonadTrans t, HasStorage n) => AuthUserGroupId -> m (Maybe AuthUserGroup) Source #

Find user group by id

listAuthUserGroupPermissions :: AuthUserGroupId -> m [WithId AuthUserGroupPermsId AuthUserGroupPerms] Source #

Get list of permissions of given group

listAuthUserGroupPermissions :: (m ~ t n, MonadTrans t, HasStorage n) => AuthUserGroupId -> m [WithId AuthUserGroupPermsId AuthUserGroupPerms] Source #

Get list of permissions of given group

listAuthUserGroupUsers :: AuthUserGroupId -> m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

Get list of all users of the group

listAuthUserGroupUsers :: (m ~ t n, MonadTrans t, HasStorage n) => AuthUserGroupId -> m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

Get list of all users of the group

replaceAuthUserGroup :: AuthUserGroupId -> AuthUserGroup -> m () Source #

Replace record of user group

replaceAuthUserGroup :: (m ~ t n, MonadTrans t, HasStorage n) => AuthUserGroupId -> AuthUserGroup -> m () Source #

Replace record of user group

clearAuthUserGroupUsers :: AuthUserGroupId -> m () Source #

Remove all users from group

clearAuthUserGroupUsers :: (m ~ t n, MonadTrans t, HasStorage n) => AuthUserGroupId -> m () Source #

Remove all users from group

clearAuthUserGroupPerms :: AuthUserGroupId -> m () Source #

Remove all permissions from group

clearAuthUserGroupPerms :: (m ~ t n, MonadTrans t, HasStorage n) => AuthUserGroupId -> m () Source #

Remove all permissions from group

deleteAuthUserGroup :: AuthUserGroupId -> m () Source #

Delete user group from storage

deleteAuthUserGroup :: (m ~ t n, MonadTrans t, HasStorage n) => AuthUserGroupId -> m () Source #

Delete user group from storage

listGroupsPaged :: Page -> PageSize -> m ([WithId AuthUserGroupId AuthUserGroup], Word) Source #

Get paged list of user groups with total count

listGroupsPaged :: (m ~ t n, MonadTrans t, HasStorage n) => Page -> PageSize -> m ([WithId AuthUserGroupId AuthUserGroup], Word) Source #

Get paged list of user groups with total count

setAuthUserGroupName :: AuthUserGroupId -> Text -> m () Source #

Set group name

setAuthUserGroupName :: (m ~ t n, MonadTrans t, HasStorage n) => AuthUserGroupId -> Text -> m () Source #

Set group name

setAuthUserGroupParent :: AuthUserGroupId -> Maybe AuthUserGroupId -> m () Source #

Set group parent

setAuthUserGroupParent :: (m ~ t n, MonadTrans t, HasStorage n) => AuthUserGroupId -> Maybe AuthUserGroupId -> m () Source #

Set group parent

insertSingleUseCode :: UserSingleUseCode -> m UserSingleUseCodeId Source #

Add new single use code

insertSingleUseCode :: (m ~ t n, MonadTrans t, HasStorage n) => UserSingleUseCode -> m UserSingleUseCodeId Source #

Add new single use code

setSingleUseCodeUsed :: UserSingleUseCodeId -> Maybe UTCTime -> m () Source #

Set usage time of the single use code

setSingleUseCodeUsed :: (m ~ t n, MonadTrans t, HasStorage n) => UserSingleUseCodeId -> Maybe UTCTime -> m () Source #

Set usage time of the single use code

getUnusedCode :: SingleUseCode -> UserImplId -> UTCTime -> m (Maybe (WithId UserSingleUseCodeId UserSingleUseCode)) Source #

Find unused code for the user and expiration time greater than the given time

getUnusedCode :: (m ~ t n, MonadTrans t, HasStorage n) => SingleUseCode -> UserImplId -> UTCTime -> m (Maybe (WithId UserSingleUseCodeId UserSingleUseCode)) Source #

Find unused code for the user and expiration time greater than the given time

invalidatePermanentCodes :: UserImplId -> UTCTime -> m () Source #

Invalidate all permanent codes for user and set use time for them

invalidatePermanentCodes :: (m ~ t n, MonadTrans t, HasStorage n) => UserImplId -> UTCTime -> m () Source #

Invalidate all permanent codes for user and set use time for them

selectLastRestoreCode :: UserImplId -> UTCTime -> m (Maybe (WithId UserRestoreId UserRestore)) Source #

Select last valid restoration code by the given current time

selectLastRestoreCode :: (m ~ t n, MonadTrans t, HasStorage n) => UserImplId -> UTCTime -> m (Maybe (WithId UserRestoreId UserRestore)) Source #

Select last valid restoration code by the given current time

insertUserRestore :: UserRestore -> m UserRestoreId Source #

Insert new restore code

insertUserRestore :: (m ~ t n, MonadTrans t, HasStorage n) => UserRestore -> m UserRestoreId Source #

Insert new restore code

findRestoreCode :: UserImplId -> RestoreCode -> UTCTime -> m (Maybe (WithId UserRestoreId UserRestore)) Source #

Find unexpired by the time restore code

findRestoreCode :: (m ~ t n, MonadTrans t, HasStorage n) => UserImplId -> RestoreCode -> UTCTime -> m (Maybe (WithId UserRestoreId UserRestore)) Source #

Find unexpired by the time restore code

replaceRestoreCode :: UserRestoreId -> UserRestore -> m () Source #

Replace restore code with new value

replaceRestoreCode :: (m ~ t n, MonadTrans t, HasStorage n) => UserRestoreId -> UserRestore -> m () Source #

Replace restore code with new value

findAuthToken :: UserImplId -> UTCTime -> m (Maybe (WithId AuthTokenId AuthToken)) Source #

Find first non-expired by the time token for user

findAuthToken :: (m ~ t n, MonadTrans t, HasStorage n) => UserImplId -> UTCTime -> m (Maybe (WithId AuthTokenId AuthToken)) Source #

Find first non-expired by the time token for user

findAuthTokenByValue :: SimpleToken -> m (Maybe (WithId AuthTokenId AuthToken)) Source #

Find token by value

findAuthTokenByValue :: (m ~ t n, MonadTrans t, HasStorage n) => SimpleToken -> m (Maybe (WithId AuthTokenId AuthToken)) Source #

Find token by value

insertAuthToken :: AuthToken -> m AuthTokenId Source #

Insert new token

insertAuthToken :: (m ~ t n, MonadTrans t, HasStorage n) => AuthToken -> m AuthTokenId Source #

Insert new token

replaceAuthToken :: AuthTokenId -> AuthToken -> m () Source #

Replace auth token with new value

replaceAuthToken :: (m ~ t n, MonadTrans t, HasStorage n) => AuthTokenId -> AuthToken -> m () Source #

Replace auth token with new value

Instances
HasStorage m => HasStorage (ExceptT e m) Source # 
Instance details

Defined in Servant.Server.Auth.Token.Model

Methods

getUserImpl :: UserImplId -> ExceptT e m (Maybe UserImpl) Source #

getUserImplByLogin :: Login -> ExceptT e m (Maybe (WithId UserImplId UserImpl)) Source #

listUsersPaged :: Page -> PageSize -> ExceptT e m ([WithId UserImplId UserImpl], Word) Source #

getUserImplPermissions :: UserImplId -> ExceptT e m [WithId UserPermId UserPerm] Source #

deleteUserPermissions :: UserImplId -> ExceptT e m () Source #

insertUserPerm :: UserPerm -> ExceptT e m UserPermId Source #

insertUserImpl :: UserImpl -> ExceptT e m UserImplId Source #

replaceUserImpl :: UserImplId -> UserImpl -> ExceptT e m () Source #

deleteUserImpl :: UserImplId -> ExceptT e m () Source #

hasPerm :: UserImplId -> Permission -> ExceptT e m Bool Source #

getFirstUserByPerm :: Permission -> ExceptT e m (Maybe (WithId UserImplId UserImpl)) Source #

selectUserImplGroups :: UserImplId -> ExceptT e m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

clearUserImplGroups :: UserImplId -> ExceptT e m () Source #

insertAuthUserGroup :: AuthUserGroup -> ExceptT e m AuthUserGroupId Source #

insertAuthUserGroupUsers :: AuthUserGroupUsers -> ExceptT e m AuthUserGroupUsersId Source #

insertAuthUserGroupPerms :: AuthUserGroupPerms -> ExceptT e m AuthUserGroupPermsId Source #

getAuthUserGroup :: AuthUserGroupId -> ExceptT e m (Maybe AuthUserGroup) Source #

listAuthUserGroupPermissions :: AuthUserGroupId -> ExceptT e m [WithId AuthUserGroupPermsId AuthUserGroupPerms] Source #

listAuthUserGroupUsers :: AuthUserGroupId -> ExceptT e m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

replaceAuthUserGroup :: AuthUserGroupId -> AuthUserGroup -> ExceptT e m () Source #

clearAuthUserGroupUsers :: AuthUserGroupId -> ExceptT e m () Source #

clearAuthUserGroupPerms :: AuthUserGroupId -> ExceptT e m () Source #

deleteAuthUserGroup :: AuthUserGroupId -> ExceptT e m () Source #

listGroupsPaged :: Page -> PageSize -> ExceptT e m ([WithId AuthUserGroupId AuthUserGroup], Word) Source #

setAuthUserGroupName :: AuthUserGroupId -> Text -> ExceptT e m () Source #

setAuthUserGroupParent :: AuthUserGroupId -> Maybe AuthUserGroupId -> ExceptT e m () Source #

insertSingleUseCode :: UserSingleUseCode -> ExceptT e m UserSingleUseCodeId Source #

setSingleUseCodeUsed :: UserSingleUseCodeId -> Maybe UTCTime -> ExceptT e m () Source #

getUnusedCode :: SingleUseCode -> UserImplId -> UTCTime -> ExceptT e m (Maybe (WithId UserSingleUseCodeId UserSingleUseCode)) Source #

invalidatePermanentCodes :: UserImplId -> UTCTime -> ExceptT e m () Source #

selectLastRestoreCode :: UserImplId -> UTCTime -> ExceptT e m (Maybe (WithId UserRestoreId UserRestore)) Source #

insertUserRestore :: UserRestore -> ExceptT e m UserRestoreId Source #

findRestoreCode :: UserImplId -> RestoreCode -> UTCTime -> ExceptT e m (Maybe (WithId UserRestoreId UserRestore)) Source #

replaceRestoreCode :: UserRestoreId -> UserRestore -> ExceptT e m () Source #

findAuthToken :: UserImplId -> UTCTime -> ExceptT e m (Maybe (WithId AuthTokenId AuthToken)) Source #

findAuthTokenByValue :: SimpleToken -> ExceptT e m (Maybe (WithId AuthTokenId AuthToken)) Source #

insertAuthToken :: AuthToken -> ExceptT e m AuthTokenId Source #

replaceAuthToken :: AuthTokenId -> AuthToken -> ExceptT e m () Source #

(HasStorage m, Monoid w) => HasStorage (WriterT w m) Source # 
Instance details

Defined in Servant.Server.Auth.Token.Model

Methods

getUserImpl :: UserImplId -> WriterT w m (Maybe UserImpl) Source #

getUserImplByLogin :: Login -> WriterT w m (Maybe (WithId UserImplId UserImpl)) Source #

listUsersPaged :: Page -> PageSize -> WriterT w m ([WithId UserImplId UserImpl], Word) Source #

getUserImplPermissions :: UserImplId -> WriterT w m [WithId UserPermId UserPerm] Source #

deleteUserPermissions :: UserImplId -> WriterT w m () Source #

insertUserPerm :: UserPerm -> WriterT w m UserPermId Source #

insertUserImpl :: UserImpl -> WriterT w m UserImplId Source #

replaceUserImpl :: UserImplId -> UserImpl -> WriterT w m () Source #

deleteUserImpl :: UserImplId -> WriterT w m () Source #

hasPerm :: UserImplId -> Permission -> WriterT w m Bool Source #

getFirstUserByPerm :: Permission -> WriterT w m (Maybe (WithId UserImplId UserImpl)) Source #

selectUserImplGroups :: UserImplId -> WriterT w m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

clearUserImplGroups :: UserImplId -> WriterT w m () Source #

insertAuthUserGroup :: AuthUserGroup -> WriterT w m AuthUserGroupId Source #

insertAuthUserGroupUsers :: AuthUserGroupUsers -> WriterT w m AuthUserGroupUsersId Source #

insertAuthUserGroupPerms :: AuthUserGroupPerms -> WriterT w m AuthUserGroupPermsId Source #

getAuthUserGroup :: AuthUserGroupId -> WriterT w m (Maybe AuthUserGroup) Source #

listAuthUserGroupPermissions :: AuthUserGroupId -> WriterT w m [WithId AuthUserGroupPermsId AuthUserGroupPerms] Source #

listAuthUserGroupUsers :: AuthUserGroupId -> WriterT w m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

replaceAuthUserGroup :: AuthUserGroupId -> AuthUserGroup -> WriterT w m () Source #

clearAuthUserGroupUsers :: AuthUserGroupId -> WriterT w m () Source #

clearAuthUserGroupPerms :: AuthUserGroupId -> WriterT w m () Source #

deleteAuthUserGroup :: AuthUserGroupId -> WriterT w m () Source #

listGroupsPaged :: Page -> PageSize -> WriterT w m ([WithId AuthUserGroupId AuthUserGroup], Word) Source #

setAuthUserGroupName :: AuthUserGroupId -> Text -> WriterT w m () Source #

setAuthUserGroupParent :: AuthUserGroupId -> Maybe AuthUserGroupId -> WriterT w m () Source #

insertSingleUseCode :: UserSingleUseCode -> WriterT w m UserSingleUseCodeId Source #

setSingleUseCodeUsed :: UserSingleUseCodeId -> Maybe UTCTime -> WriterT w m () Source #

getUnusedCode :: SingleUseCode -> UserImplId -> UTCTime -> WriterT w m (Maybe (WithId UserSingleUseCodeId UserSingleUseCode)) Source #

invalidatePermanentCodes :: UserImplId -> UTCTime -> WriterT w m () Source #

selectLastRestoreCode :: UserImplId -> UTCTime -> WriterT w m (Maybe (WithId UserRestoreId UserRestore)) Source #

insertUserRestore :: UserRestore -> WriterT w m UserRestoreId Source #

findRestoreCode :: UserImplId -> RestoreCode -> UTCTime -> WriterT w m (Maybe (WithId UserRestoreId UserRestore)) Source #

replaceRestoreCode :: UserRestoreId -> UserRestore -> WriterT w m () Source #

findAuthToken :: UserImplId -> UTCTime -> WriterT w m (Maybe (WithId AuthTokenId AuthToken)) Source #

findAuthTokenByValue :: SimpleToken -> WriterT w m (Maybe (WithId AuthTokenId AuthToken)) Source #

insertAuthToken :: AuthToken -> WriterT w m AuthTokenId Source #

replaceAuthToken :: AuthTokenId -> AuthToken -> WriterT w m () Source #

HasStorage m => HasStorage (StateT s m) Source # 
Instance details

Defined in Servant.Server.Auth.Token.Model

Methods

getUserImpl :: UserImplId -> StateT s m (Maybe UserImpl) Source #

getUserImplByLogin :: Login -> StateT s m (Maybe (WithId UserImplId UserImpl)) Source #

listUsersPaged :: Page -> PageSize -> StateT s m ([WithId UserImplId UserImpl], Word) Source #

getUserImplPermissions :: UserImplId -> StateT s m [WithId UserPermId UserPerm] Source #

deleteUserPermissions :: UserImplId -> StateT s m () Source #

insertUserPerm :: UserPerm -> StateT s m UserPermId Source #

insertUserImpl :: UserImpl -> StateT s m UserImplId Source #

replaceUserImpl :: UserImplId -> UserImpl -> StateT s m () Source #

deleteUserImpl :: UserImplId -> StateT s m () Source #

hasPerm :: UserImplId -> Permission -> StateT s m Bool Source #

getFirstUserByPerm :: Permission -> StateT s m (Maybe (WithId UserImplId UserImpl)) Source #

selectUserImplGroups :: UserImplId -> StateT s m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

clearUserImplGroups :: UserImplId -> StateT s m () Source #

insertAuthUserGroup :: AuthUserGroup -> StateT s m AuthUserGroupId Source #

insertAuthUserGroupUsers :: AuthUserGroupUsers -> StateT s m AuthUserGroupUsersId Source #

insertAuthUserGroupPerms :: AuthUserGroupPerms -> StateT s m AuthUserGroupPermsId Source #

getAuthUserGroup :: AuthUserGroupId -> StateT s m (Maybe AuthUserGroup) Source #

listAuthUserGroupPermissions :: AuthUserGroupId -> StateT s m [WithId AuthUserGroupPermsId AuthUserGroupPerms] Source #

listAuthUserGroupUsers :: AuthUserGroupId -> StateT s m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

replaceAuthUserGroup :: AuthUserGroupId -> AuthUserGroup -> StateT s m () Source #

clearAuthUserGroupUsers :: AuthUserGroupId -> StateT s m () Source #

clearAuthUserGroupPerms :: AuthUserGroupId -> StateT s m () Source #

deleteAuthUserGroup :: AuthUserGroupId -> StateT s m () Source #

listGroupsPaged :: Page -> PageSize -> StateT s m ([WithId AuthUserGroupId AuthUserGroup], Word) Source #

setAuthUserGroupName :: AuthUserGroupId -> Text -> StateT s m () Source #

setAuthUserGroupParent :: AuthUserGroupId -> Maybe AuthUserGroupId -> StateT s m () Source #

insertSingleUseCode :: UserSingleUseCode -> StateT s m UserSingleUseCodeId Source #

setSingleUseCodeUsed :: UserSingleUseCodeId -> Maybe UTCTime -> StateT s m () Source #

getUnusedCode :: SingleUseCode -> UserImplId -> UTCTime -> StateT s m (Maybe (WithId UserSingleUseCodeId UserSingleUseCode)) Source #

invalidatePermanentCodes :: UserImplId -> UTCTime -> StateT s m () Source #

selectLastRestoreCode :: UserImplId -> UTCTime -> StateT s m (Maybe (WithId UserRestoreId UserRestore)) Source #

insertUserRestore :: UserRestore -> StateT s m UserRestoreId Source #

findRestoreCode :: UserImplId -> RestoreCode -> UTCTime -> StateT s m (Maybe (WithId UserRestoreId UserRestore)) Source #

replaceRestoreCode :: UserRestoreId -> UserRestore -> StateT s m () Source #

findAuthToken :: UserImplId -> UTCTime -> StateT s m (Maybe (WithId AuthTokenId AuthToken)) Source #

findAuthTokenByValue :: SimpleToken -> StateT s m (Maybe (WithId AuthTokenId AuthToken)) Source #

insertAuthToken :: AuthToken -> StateT s m AuthTokenId Source #

replaceAuthToken :: AuthTokenId -> AuthToken -> StateT s m () Source #

HasStorage m => HasStorage (StateT s m) Source # 
Instance details

Defined in Servant.Server.Auth.Token.Model

Methods

getUserImpl :: UserImplId -> StateT s m (Maybe UserImpl) Source #

getUserImplByLogin :: Login -> StateT s m (Maybe (WithId UserImplId UserImpl)) Source #

listUsersPaged :: Page -> PageSize -> StateT s m ([WithId UserImplId UserImpl], Word) Source #

getUserImplPermissions :: UserImplId -> StateT s m [WithId UserPermId UserPerm] Source #

deleteUserPermissions :: UserImplId -> StateT s m () Source #

insertUserPerm :: UserPerm -> StateT s m UserPermId Source #

insertUserImpl :: UserImpl -> StateT s m UserImplId Source #

replaceUserImpl :: UserImplId -> UserImpl -> StateT s m () Source #

deleteUserImpl :: UserImplId -> StateT s m () Source #

hasPerm :: UserImplId -> Permission -> StateT s m Bool Source #

getFirstUserByPerm :: Permission -> StateT s m (Maybe (WithId UserImplId UserImpl)) Source #

selectUserImplGroups :: UserImplId -> StateT s m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

clearUserImplGroups :: UserImplId -> StateT s m () Source #

insertAuthUserGroup :: AuthUserGroup -> StateT s m AuthUserGroupId Source #

insertAuthUserGroupUsers :: AuthUserGroupUsers -> StateT s m AuthUserGroupUsersId Source #

insertAuthUserGroupPerms :: AuthUserGroupPerms -> StateT s m AuthUserGroupPermsId Source #

getAuthUserGroup :: AuthUserGroupId -> StateT s m (Maybe AuthUserGroup) Source #

listAuthUserGroupPermissions :: AuthUserGroupId -> StateT s m [WithId AuthUserGroupPermsId AuthUserGroupPerms] Source #

listAuthUserGroupUsers :: AuthUserGroupId -> StateT s m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

replaceAuthUserGroup :: AuthUserGroupId -> AuthUserGroup -> StateT s m () Source #

clearAuthUserGroupUsers :: AuthUserGroupId -> StateT s m () Source #

clearAuthUserGroupPerms :: AuthUserGroupId -> StateT s m () Source #

deleteAuthUserGroup :: AuthUserGroupId -> StateT s m () Source #

listGroupsPaged :: Page -> PageSize -> StateT s m ([WithId AuthUserGroupId AuthUserGroup], Word) Source #

setAuthUserGroupName :: AuthUserGroupId -> Text -> StateT s m () Source #

setAuthUserGroupParent :: AuthUserGroupId -> Maybe AuthUserGroupId -> StateT s m () Source #

insertSingleUseCode :: UserSingleUseCode -> StateT s m UserSingleUseCodeId Source #

setSingleUseCodeUsed :: UserSingleUseCodeId -> Maybe UTCTime -> StateT s m () Source #

getUnusedCode :: SingleUseCode -> UserImplId -> UTCTime -> StateT s m (Maybe (WithId UserSingleUseCodeId UserSingleUseCode)) Source #

invalidatePermanentCodes :: UserImplId -> UTCTime -> StateT s m () Source #

selectLastRestoreCode :: UserImplId -> UTCTime -> StateT s m (Maybe (WithId UserRestoreId UserRestore)) Source #

insertUserRestore :: UserRestore -> StateT s m UserRestoreId Source #

findRestoreCode :: UserImplId -> RestoreCode -> UTCTime -> StateT s m (Maybe (WithId UserRestoreId UserRestore)) Source #

replaceRestoreCode :: UserRestoreId -> UserRestore -> StateT s m () Source #

findAuthToken :: UserImplId -> UTCTime -> StateT s m (Maybe (WithId AuthTokenId AuthToken)) Source #

findAuthTokenByValue :: SimpleToken -> StateT s m (Maybe (WithId AuthTokenId AuthToken)) Source #

insertAuthToken :: AuthToken -> StateT s m AuthTokenId Source #

replaceAuthToken :: AuthTokenId -> AuthToken -> StateT s m () Source #

(HasStorage m, Monoid w) => HasStorage (WriterT w m) Source # 
Instance details

Defined in Servant.Server.Auth.Token.Model

Methods

getUserImpl :: UserImplId -> WriterT w m (Maybe UserImpl) Source #

getUserImplByLogin :: Login -> WriterT w m (Maybe (WithId UserImplId UserImpl)) Source #

listUsersPaged :: Page -> PageSize -> WriterT w m ([WithId UserImplId UserImpl], Word) Source #

getUserImplPermissions :: UserImplId -> WriterT w m [WithId UserPermId UserPerm] Source #

deleteUserPermissions :: UserImplId -> WriterT w m () Source #

insertUserPerm :: UserPerm -> WriterT w m UserPermId Source #

insertUserImpl :: UserImpl -> WriterT w m UserImplId Source #

replaceUserImpl :: UserImplId -> UserImpl -> WriterT w m () Source #

deleteUserImpl :: UserImplId -> WriterT w m () Source #

hasPerm :: UserImplId -> Permission -> WriterT w m Bool Source #

getFirstUserByPerm :: Permission -> WriterT w m (Maybe (WithId UserImplId UserImpl)) Source #

selectUserImplGroups :: UserImplId -> WriterT w m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

clearUserImplGroups :: UserImplId -> WriterT w m () Source #

insertAuthUserGroup :: AuthUserGroup -> WriterT w m AuthUserGroupId Source #

insertAuthUserGroupUsers :: AuthUserGroupUsers -> WriterT w m AuthUserGroupUsersId Source #

insertAuthUserGroupPerms :: AuthUserGroupPerms -> WriterT w m AuthUserGroupPermsId Source #

getAuthUserGroup :: AuthUserGroupId -> WriterT w m (Maybe AuthUserGroup) Source #

listAuthUserGroupPermissions :: AuthUserGroupId -> WriterT w m [WithId AuthUserGroupPermsId AuthUserGroupPerms] Source #

listAuthUserGroupUsers :: AuthUserGroupId -> WriterT w m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

replaceAuthUserGroup :: AuthUserGroupId -> AuthUserGroup -> WriterT w m () Source #

clearAuthUserGroupUsers :: AuthUserGroupId -> WriterT w m () Source #

clearAuthUserGroupPerms :: AuthUserGroupId -> WriterT w m () Source #

deleteAuthUserGroup :: AuthUserGroupId -> WriterT w m () Source #

listGroupsPaged :: Page -> PageSize -> WriterT w m ([WithId AuthUserGroupId AuthUserGroup], Word) Source #

setAuthUserGroupName :: AuthUserGroupId -> Text -> WriterT w m () Source #

setAuthUserGroupParent :: AuthUserGroupId -> Maybe AuthUserGroupId -> WriterT w m () Source #

insertSingleUseCode :: UserSingleUseCode -> WriterT w m UserSingleUseCodeId Source #

setSingleUseCodeUsed :: UserSingleUseCodeId -> Maybe UTCTime -> WriterT w m () Source #

getUnusedCode :: SingleUseCode -> UserImplId -> UTCTime -> WriterT w m (Maybe (WithId UserSingleUseCodeId UserSingleUseCode)) Source #

invalidatePermanentCodes :: UserImplId -> UTCTime -> WriterT w m () Source #

selectLastRestoreCode :: UserImplId -> UTCTime -> WriterT w m (Maybe (WithId UserRestoreId UserRestore)) Source #

insertUserRestore :: UserRestore -> WriterT w m UserRestoreId Source #

findRestoreCode :: UserImplId -> RestoreCode -> UTCTime -> WriterT w m (Maybe (WithId UserRestoreId UserRestore)) Source #

replaceRestoreCode :: UserRestoreId -> UserRestore -> WriterT w m () Source #

findAuthToken :: UserImplId -> UTCTime -> WriterT w m (Maybe (WithId AuthTokenId AuthToken)) Source #

findAuthTokenByValue :: SimpleToken -> WriterT w m (Maybe (WithId AuthTokenId AuthToken)) Source #

insertAuthToken :: AuthToken -> WriterT w m AuthTokenId Source #

replaceAuthToken :: AuthTokenId -> AuthToken -> WriterT w m () Source #

HasStorage m => HasStorage (ReaderT r m) Source # 
Instance details

Defined in Servant.Server.Auth.Token.Model

Methods

getUserImpl :: UserImplId -> ReaderT r m (Maybe UserImpl) Source #

getUserImplByLogin :: Login -> ReaderT r m (Maybe (WithId UserImplId UserImpl)) Source #

listUsersPaged :: Page -> PageSize -> ReaderT r m ([WithId UserImplId UserImpl], Word) Source #

getUserImplPermissions :: UserImplId -> ReaderT r m [WithId UserPermId UserPerm] Source #

deleteUserPermissions :: UserImplId -> ReaderT r m () Source #

insertUserPerm :: UserPerm -> ReaderT r m UserPermId Source #

insertUserImpl :: UserImpl -> ReaderT r m UserImplId Source #

replaceUserImpl :: UserImplId -> UserImpl -> ReaderT r m () Source #

deleteUserImpl :: UserImplId -> ReaderT r m () Source #

hasPerm :: UserImplId -> Permission -> ReaderT r m Bool Source #

getFirstUserByPerm :: Permission -> ReaderT r m (Maybe (WithId UserImplId UserImpl)) Source #

selectUserImplGroups :: UserImplId -> ReaderT r m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

clearUserImplGroups :: UserImplId -> ReaderT r m () Source #

insertAuthUserGroup :: AuthUserGroup -> ReaderT r m AuthUserGroupId Source #

insertAuthUserGroupUsers :: AuthUserGroupUsers -> ReaderT r m AuthUserGroupUsersId Source #

insertAuthUserGroupPerms :: AuthUserGroupPerms -> ReaderT r m AuthUserGroupPermsId Source #

getAuthUserGroup :: AuthUserGroupId -> ReaderT r m (Maybe AuthUserGroup) Source #

listAuthUserGroupPermissions :: AuthUserGroupId -> ReaderT r m [WithId AuthUserGroupPermsId AuthUserGroupPerms] Source #

listAuthUserGroupUsers :: AuthUserGroupId -> ReaderT r m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

replaceAuthUserGroup :: AuthUserGroupId -> AuthUserGroup -> ReaderT r m () Source #

clearAuthUserGroupUsers :: AuthUserGroupId -> ReaderT r m () Source #

clearAuthUserGroupPerms :: AuthUserGroupId -> ReaderT r m () Source #

deleteAuthUserGroup :: AuthUserGroupId -> ReaderT r m () Source #

listGroupsPaged :: Page -> PageSize -> ReaderT r m ([WithId AuthUserGroupId AuthUserGroup], Word) Source #

setAuthUserGroupName :: AuthUserGroupId -> Text -> ReaderT r m () Source #

setAuthUserGroupParent :: AuthUserGroupId -> Maybe AuthUserGroupId -> ReaderT r m () Source #

insertSingleUseCode :: UserSingleUseCode -> ReaderT r m UserSingleUseCodeId Source #

setSingleUseCodeUsed :: UserSingleUseCodeId -> Maybe UTCTime -> ReaderT r m () Source #

getUnusedCode :: SingleUseCode -> UserImplId -> UTCTime -> ReaderT r m (Maybe (WithId UserSingleUseCodeId UserSingleUseCode)) Source #

invalidatePermanentCodes :: UserImplId -> UTCTime -> ReaderT r m () Source #

selectLastRestoreCode :: UserImplId -> UTCTime -> ReaderT r m (Maybe (WithId UserRestoreId UserRestore)) Source #

insertUserRestore :: UserRestore -> ReaderT r m UserRestoreId Source #

findRestoreCode :: UserImplId -> RestoreCode -> UTCTime -> ReaderT r m (Maybe (WithId UserRestoreId UserRestore)) Source #

replaceRestoreCode :: UserRestoreId -> UserRestore -> ReaderT r m () Source #

findAuthToken :: UserImplId -> UTCTime -> ReaderT r m (Maybe (WithId AuthTokenId AuthToken)) Source #

findAuthTokenByValue :: SimpleToken -> ReaderT r m (Maybe (WithId AuthTokenId AuthToken)) Source #

insertAuthToken :: AuthToken -> ReaderT r m AuthTokenId Source #

replaceAuthToken :: AuthTokenId -> AuthToken -> ReaderT r m () Source #

HasStorage m => HasStorage (ContT r m) Source # 
Instance details

Defined in Servant.Server.Auth.Token.Model

Methods

getUserImpl :: UserImplId -> ContT r m (Maybe UserImpl) Source #

getUserImplByLogin :: Login -> ContT r m (Maybe (WithId UserImplId UserImpl)) Source #

listUsersPaged :: Page -> PageSize -> ContT r m ([WithId UserImplId UserImpl], Word) Source #

getUserImplPermissions :: UserImplId -> ContT r m [WithId UserPermId UserPerm] Source #

deleteUserPermissions :: UserImplId -> ContT r m () Source #

insertUserPerm :: UserPerm -> ContT r m UserPermId Source #

insertUserImpl :: UserImpl -> ContT r m UserImplId Source #

replaceUserImpl :: UserImplId -> UserImpl -> ContT r m () Source #

deleteUserImpl :: UserImplId -> ContT r m () Source #

hasPerm :: UserImplId -> Permission -> ContT r m Bool Source #

getFirstUserByPerm :: Permission -> ContT r m (Maybe (WithId UserImplId UserImpl)) Source #

selectUserImplGroups :: UserImplId -> ContT r m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

clearUserImplGroups :: UserImplId -> ContT r m () Source #

insertAuthUserGroup :: AuthUserGroup -> ContT r m AuthUserGroupId Source #

insertAuthUserGroupUsers :: AuthUserGroupUsers -> ContT r m AuthUserGroupUsersId Source #

insertAuthUserGroupPerms :: AuthUserGroupPerms -> ContT r m AuthUserGroupPermsId Source #

getAuthUserGroup :: AuthUserGroupId -> ContT r m (Maybe AuthUserGroup) Source #

listAuthUserGroupPermissions :: AuthUserGroupId -> ContT r m [WithId AuthUserGroupPermsId AuthUserGroupPerms] Source #

listAuthUserGroupUsers :: AuthUserGroupId -> ContT r m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

replaceAuthUserGroup :: AuthUserGroupId -> AuthUserGroup -> ContT r m () Source #

clearAuthUserGroupUsers :: AuthUserGroupId -> ContT r m () Source #

clearAuthUserGroupPerms :: AuthUserGroupId -> ContT r m () Source #

deleteAuthUserGroup :: AuthUserGroupId -> ContT r m () Source #

listGroupsPaged :: Page -> PageSize -> ContT r m ([WithId AuthUserGroupId AuthUserGroup], Word) Source #

setAuthUserGroupName :: AuthUserGroupId -> Text -> ContT r m () Source #

setAuthUserGroupParent :: AuthUserGroupId -> Maybe AuthUserGroupId -> ContT r m () Source #

insertSingleUseCode :: UserSingleUseCode -> ContT r m UserSingleUseCodeId Source #

setSingleUseCodeUsed :: UserSingleUseCodeId -> Maybe UTCTime -> ContT r m () Source #

getUnusedCode :: SingleUseCode -> UserImplId -> UTCTime -> ContT r m (Maybe (WithId UserSingleUseCodeId UserSingleUseCode)) Source #

invalidatePermanentCodes :: UserImplId -> UTCTime -> ContT r m () Source #

selectLastRestoreCode :: UserImplId -> UTCTime -> ContT r m (Maybe (WithId UserRestoreId UserRestore)) Source #

insertUserRestore :: UserRestore -> ContT r m UserRestoreId Source #

findRestoreCode :: UserImplId -> RestoreCode -> UTCTime -> ContT r m (Maybe (WithId UserRestoreId UserRestore)) Source #

replaceRestoreCode :: UserRestoreId -> UserRestore -> ContT r m () Source #

findAuthToken :: UserImplId -> UTCTime -> ContT r m (Maybe (WithId AuthTokenId AuthToken)) Source #

findAuthTokenByValue :: SimpleToken -> ContT r m (Maybe (WithId AuthTokenId AuthToken)) Source #

insertAuthToken :: AuthToken -> ContT r m AuthTokenId Source #

replaceAuthToken :: AuthTokenId -> AuthToken -> ContT r m () Source #

(HasStorage m, Monoid w) => HasStorage (RWST r w s m) Source # 
Instance details

Defined in Servant.Server.Auth.Token.Model

Methods

getUserImpl :: UserImplId -> RWST r w s m (Maybe UserImpl) Source #

getUserImplByLogin :: Login -> RWST r w s m (Maybe (WithId UserImplId UserImpl)) Source #

listUsersPaged :: Page -> PageSize -> RWST r w s m ([WithId UserImplId UserImpl], Word) Source #

getUserImplPermissions :: UserImplId -> RWST r w s m [WithId UserPermId UserPerm] Source #

deleteUserPermissions :: UserImplId -> RWST r w s m () Source #

insertUserPerm :: UserPerm -> RWST r w s m UserPermId Source #

insertUserImpl :: UserImpl -> RWST r w s m UserImplId Source #

replaceUserImpl :: UserImplId -> UserImpl -> RWST r w s m () Source #

deleteUserImpl :: UserImplId -> RWST r w s m () Source #

hasPerm :: UserImplId -> Permission -> RWST r w s m Bool Source #

getFirstUserByPerm :: Permission -> RWST r w s m (Maybe (WithId UserImplId UserImpl)) Source #

selectUserImplGroups :: UserImplId -> RWST r w s m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

clearUserImplGroups :: UserImplId -> RWST r w s m () Source #

insertAuthUserGroup :: AuthUserGroup -> RWST r w s m AuthUserGroupId Source #

insertAuthUserGroupUsers :: AuthUserGroupUsers -> RWST r w s m AuthUserGroupUsersId Source #

insertAuthUserGroupPerms :: AuthUserGroupPerms -> RWST r w s m AuthUserGroupPermsId Source #

getAuthUserGroup :: AuthUserGroupId -> RWST r w s m (Maybe AuthUserGroup) Source #

listAuthUserGroupPermissions :: AuthUserGroupId -> RWST r w s m [WithId AuthUserGroupPermsId AuthUserGroupPerms] Source #

listAuthUserGroupUsers :: AuthUserGroupId -> RWST r w s m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

replaceAuthUserGroup :: AuthUserGroupId -> AuthUserGroup -> RWST r w s m () Source #

clearAuthUserGroupUsers :: AuthUserGroupId -> RWST r w s m () Source #

clearAuthUserGroupPerms :: AuthUserGroupId -> RWST r w s m () Source #

deleteAuthUserGroup :: AuthUserGroupId -> RWST r w s m () Source #

listGroupsPaged :: Page -> PageSize -> RWST r w s m ([WithId AuthUserGroupId AuthUserGroup], Word) Source #

setAuthUserGroupName :: AuthUserGroupId -> Text -> RWST r w s m () Source #

setAuthUserGroupParent :: AuthUserGroupId -> Maybe AuthUserGroupId -> RWST r w s m () Source #

insertSingleUseCode :: UserSingleUseCode -> RWST r w s m UserSingleUseCodeId Source #

setSingleUseCodeUsed :: UserSingleUseCodeId -> Maybe UTCTime -> RWST r w s m () Source #

getUnusedCode :: SingleUseCode -> UserImplId -> UTCTime -> RWST r w s m (Maybe (WithId UserSingleUseCodeId UserSingleUseCode)) Source #

invalidatePermanentCodes :: UserImplId -> UTCTime -> RWST r w s m () Source #

selectLastRestoreCode :: UserImplId -> UTCTime -> RWST r w s m (Maybe (WithId UserRestoreId UserRestore)) Source #

insertUserRestore :: UserRestore -> RWST r w s m UserRestoreId Source #

findRestoreCode :: UserImplId -> RestoreCode -> UTCTime -> RWST r w s m (Maybe (WithId UserRestoreId UserRestore)) Source #

replaceRestoreCode :: UserRestoreId -> UserRestore -> RWST r w s m () Source #

findAuthToken :: UserImplId -> UTCTime -> RWST r w s m (Maybe (WithId AuthTokenId AuthToken)) Source #

findAuthTokenByValue :: SimpleToken -> RWST r w s m (Maybe (WithId AuthTokenId AuthToken)) Source #

insertAuthToken :: AuthToken -> RWST r w s m AuthTokenId Source #

replaceAuthToken :: AuthTokenId -> AuthToken -> RWST r w s m () Source #

(HasStorage m, Monoid w) => HasStorage (RWST r w s m) Source # 
Instance details

Defined in Servant.Server.Auth.Token.Model

Methods

getUserImpl :: UserImplId -> RWST r w s m (Maybe UserImpl) Source #

getUserImplByLogin :: Login -> RWST r w s m (Maybe (WithId UserImplId UserImpl)) Source #

listUsersPaged :: Page -> PageSize -> RWST r w s m ([WithId UserImplId UserImpl], Word) Source #

getUserImplPermissions :: UserImplId -> RWST r w s m [WithId UserPermId UserPerm] Source #

deleteUserPermissions :: UserImplId -> RWST r w s m () Source #

insertUserPerm :: UserPerm -> RWST r w s m UserPermId Source #

insertUserImpl :: UserImpl -> RWST r w s m UserImplId Source #

replaceUserImpl :: UserImplId -> UserImpl -> RWST r w s m () Source #

deleteUserImpl :: UserImplId -> RWST r w s m () Source #

hasPerm :: UserImplId -> Permission -> RWST r w s m Bool Source #

getFirstUserByPerm :: Permission -> RWST r w s m (Maybe (WithId UserImplId UserImpl)) Source #

selectUserImplGroups :: UserImplId -> RWST r w s m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

clearUserImplGroups :: UserImplId -> RWST r w s m () Source #

insertAuthUserGroup :: AuthUserGroup -> RWST r w s m AuthUserGroupId Source #

insertAuthUserGroupUsers :: AuthUserGroupUsers -> RWST r w s m AuthUserGroupUsersId Source #

insertAuthUserGroupPerms :: AuthUserGroupPerms -> RWST r w s m AuthUserGroupPermsId Source #

getAuthUserGroup :: AuthUserGroupId -> RWST r w s m (Maybe AuthUserGroup) Source #

listAuthUserGroupPermissions :: AuthUserGroupId -> RWST r w s m [WithId AuthUserGroupPermsId AuthUserGroupPerms] Source #

listAuthUserGroupUsers :: AuthUserGroupId -> RWST r w s m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #

replaceAuthUserGroup :: AuthUserGroupId -> AuthUserGroup -> RWST r w s m () Source #

clearAuthUserGroupUsers :: AuthUserGroupId -> RWST r w s m () Source #

clearAuthUserGroupPerms :: AuthUserGroupId -> RWST r w s m () Source #

deleteAuthUserGroup :: AuthUserGroupId -> RWST r w s m () Source #

listGroupsPaged :: Page -> PageSize -> RWST r w s m ([WithId AuthUserGroupId AuthUserGroup], Word) Source #

setAuthUserGroupName :: AuthUserGroupId -> Text -> RWST r w s m () Source #

setAuthUserGroupParent :: AuthUserGroupId -> Maybe AuthUserGroupId -> RWST r w s m () Source #

insertSingleUseCode :: UserSingleUseCode -> RWST r w s m UserSingleUseCodeId Source #

setSingleUseCodeUsed :: UserSingleUseCodeId -> Maybe UTCTime -> RWST r w s m () Source #

getUnusedCode :: SingleUseCode -> UserImplId -> UTCTime -> RWST r w s m (Maybe (WithId UserSingleUseCodeId UserSingleUseCode)) Source #

invalidatePermanentCodes :: UserImplId -> UTCTime -> RWST r w s m () Source #

selectLastRestoreCode :: UserImplId -> UTCTime -> RWST r w s m (Maybe (WithId UserRestoreId UserRestore)) Source #

insertUserRestore :: UserRestore -> RWST r w s m UserRestoreId Source #

findRestoreCode :: UserImplId -> RestoreCode -> UTCTime -> RWST r w s m (Maybe (WithId UserRestoreId UserRestore)) Source #

replaceRestoreCode :: UserRestoreId -> UserRestore -> RWST r w s m () Source #

findAuthToken :: UserImplId -> UTCTime -> RWST r w s m (Maybe (WithId AuthTokenId AuthToken)) Source #

findAuthTokenByValue :: SimpleToken -> RWST r w s m (Maybe (WithId AuthTokenId AuthToken)) Source #

insertAuthToken :: AuthToken -> RWST r w s m AuthTokenId Source #

replaceAuthToken :: AuthTokenId -> AuthToken -> RWST r w s m () Source #

type AuthHandler m = (HasAuthConfig m, MonadError ServantErr m, MonadIO m, HasStorage m) Source #

Context that is needed to run the auth server

Helpers

guardAuthToken :: forall perms m. (PermsList perms, AuthHandler m) => MToken perms -> m () Source #

If the token is missing or the user of the token doesn't have needed permissions, throw 401 response

guardAuthToken' :: AuthHandler m => Maybe SimpleToken -> [Permission] -> m (WithId AuthTokenId AuthToken) Source #

Same as guardAuthToken but returns record about the token

class WithAuthToken a where Source #

Minimal complete definition

withAuthToken

Methods

withAuthToken :: PermsList perms => a -> MToken perms -> a Source #

Authenticate an entire API rather than each individual endpoint.

As such, for a given HasServer instance api, if you have:

  f :: ServerT api m

then:

  withAuthToken f :: (AuthHandler m) => ServerT (TokenHeader perms :> api) m

(Note that the types don't reflect this, as it isn't possible to guarantee what all possible ServerT instances might be.)

Instances
AuthHandler m => WithAuthToken (m a) Source # 
Instance details

Defined in Servant.Server.Auth.Token

Methods

withAuthToken :: PermsList perms => m a -> MToken perms -> m a Source #

WithAuthToken r => WithAuthToken (a -> r) Source # 
Instance details

Defined in Servant.Server.Auth.Token

Methods

withAuthToken :: PermsList perms => (a -> r) -> MToken perms -> a -> r Source #

(WithAuthToken a, WithAuthToken b) => WithAuthToken (a :<|> b) Source # 
Instance details

Defined in Servant.Server.Auth.Token

Methods

withAuthToken :: PermsList perms => (a :<|> b) -> MToken perms -> a :<|> b Source #

ensureAdmin :: HasStorage m => Int -> Login -> Password -> Email -> m () Source #

Ensures that DB has at leas one admin, if not, creates a new one with specified info.

authUserByToken :: AuthHandler m => MToken '[] -> m UserImplId Source #

Getting user id by token

Combinators

data AuthPerm (perms :: [Symbol]) Source #

An authentication combinator.

TODO maybe move in the servant-auth-api library

Instances
(HasServer api context, PermsList (PlainPerms perms), HasContextEntry context AuthAction) => HasServer (AuthPerm perms :> api :: *) context Source # 
Instance details

Defined in Servant.Server.Auth.Token.Combinator

Associated Types

type ServerT (AuthPerm perms :> api) m :: * #

Methods

route :: Proxy (AuthPerm perms :> api) -> Context context -> Delayed env (Server (AuthPerm perms :> api)) -> Router env #

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

type ServerT (AuthPerm perms :> api :: *) m Source # 
Instance details

Defined in Servant.Server.Auth.Token.Combinator

type ServerT (AuthPerm perms :> api :: *) m = ServerT api m

newtype AuthAction Source #

An authentication handler.

Constructors

AuthAction 

API methods

authSignin Source #

Arguments

:: AuthHandler m 
=> Maybe Login

Login query parameter

-> Maybe Password

Password query parameter

-> Maybe Seconds

Expire query parameter, how many seconds the token is valid

-> m (OnlyField "token" SimpleToken)

If everything is OK, return token

Implementation of "signin" method

authSigninGetCode Source #

Arguments

:: AuthHandler m 
=> Maybe Login

User login, required

-> m Unit 

Authorisation via code of single usage.

Implementation of AuthSigninGetCodeMethod endpoint.

Logic of authorisation via this method is:

See also: authSigninPostCode

authSigninPostCode Source #

Arguments

:: AuthHandler m 
=> Maybe Login

User login, required

-> Maybe SingleUseCode

Received single usage code, required

-> Maybe Seconds

Time interval after which the token expires, Nothing means some default value

-> m (OnlyField "token" SimpleToken) 

Authorisation via code of single usage.

Logic of authorisation via this method is:

See also: authSigninGetCode

authTouch Source #

Arguments

:: AuthHandler m 
=> Maybe Seconds

Expire query parameter, how many seconds the token should be valid by now. Nothing means default value defined in server config.

-> MToken '[]

Authorisation header with token

-> m Unit 

Implementation of "touch" method

authToken Source #

Arguments

:: AuthHandler m 
=> MToken '[]

Authorisation header with token

-> m RespUserInfo 

Implementation of "token" method, return info about user binded to the token

authSignout Source #

Arguments

:: AuthHandler m 
=> Maybe (Token '[])

Authorisation header with token

-> m Unit 

Implementation of "signout" method

authSignup Source #

Arguments

:: AuthHandler m 
=> ReqRegister

Registration info

-> MToken' '["auth-register"]

Authorisation header with token

-> m (OnlyField "user" UserId) 

Implementation of "signup" method

authUsersInfo Source #

Arguments

:: AuthHandler m 
=> Maybe Page

Page num parameter

-> Maybe PageSize

Page size parameter

-> MToken' '["auth-info"]

Authorisation header with token

-> m RespUsersInfo 

Implementation of get "users" method

authUserInfo Source #

Arguments

:: AuthHandler m 
=> UserId

User id

-> MToken' '["auth-info"]

Authorisation header with token

-> m RespUserInfo 

Implementation of get "user" method

authUserPatch Source #

Arguments

:: AuthHandler m 
=> UserId

User id

-> PatchUser

JSON with fields for patching

-> MToken' '["auth-update"]

Authorisation header with token

-> m Unit 

Implementation of patch "user" method

authUserPut Source #

Arguments

:: AuthHandler m 
=> UserId

User id

-> ReqRegister

New user

-> MToken' '["auth-update"]

Authorisation header with token

-> m Unit 

Implementation of put "user" method

authUserDelete Source #

Arguments

:: AuthHandler m 
=> UserId

User id

-> MToken' '["auth-delete"]

Authorisation header with token

-> m Unit 

Implementation of patch "user" method

authRestore Source #

Arguments

:: AuthHandler m 
=> UserId

User id

-> Maybe RestoreCode 
-> Maybe Password 
-> m Unit 

authGetSingleUseCodes Source #

Arguments

:: AuthHandler m 
=> UserId

Id of user

-> Maybe Word

Number of codes. Nothing means that server generates some default count of codes. And server can define maximum count of codes that user can have at once.

-> MToken' '["auth-single-codes"] 
-> m (OnlyField "codes" [SingleUseCode]) 

Implementation of AuthGetSingleUseCodes endpoint.

authGroupGet Source #

Arguments

:: AuthHandler m 
=> UserGroupId 
-> MToken' '["auth-info"]

Authorisation header with token

-> m UserGroup 

Getting info about user group, requires authInfoPerm for token

authGroupPost Source #

Arguments

:: AuthHandler m 
=> UserGroup 
-> MToken' '["auth-update"]

Authorisation header with token

-> m (OnlyId UserGroupId) 

Inserting new user group, requires authUpdatePerm for token

authGroupPut Source #

Arguments

:: AuthHandler m 
=> UserGroupId 
-> UserGroup 
-> MToken' '["auth-update"]

Authorisation header with token

-> m Unit 

Replace info about given user group, requires authUpdatePerm for token

authGroupPatch Source #

Arguments

:: AuthHandler m 
=> UserGroupId 
-> PatchUserGroup 
-> MToken' '["auth-update"]

Authorisation header with token

-> m Unit 

Patch info about given user group, requires authUpdatePerm for token

authGroupDelete Source #

Arguments

:: AuthHandler m 
=> UserGroupId 
-> MToken' '["auth-delete"]

Authorisation header with token

-> m Unit 

Delete all info about given user group, requires authDeletePerm for token

authGroupList Source #

Arguments

:: AuthHandler m 
=> Maybe Page 
-> Maybe PageSize 
-> MToken' '["auth-info"]

Authorisation header with token

-> m (PagedList UserGroupId UserGroup) 

Get list of user groups, requires authInfoPerm for token

authCheckPermissionsMethod Source #

Arguments

:: AuthHandler m 
=> MToken' '["auth-check"]

Authorisation header with token

-> OnlyField "permissions" [Permission]

Body with permissions to check

-> m Bool

True if all permissions are OK, False if some permissions are not set for token and 401 error if the token doesn't have 'auth-check' permission.

Check that the token has required permissions and return False if it doesn't.

authGetUserIdMethod Source #

Arguments

:: AuthHandler m 
=> MToken' '["auth-userid"]

Authorisation header with token

-> m (OnlyId UserId) 

Get user ID for the owner of the speified token.

authFindUserByLogin Source #

Arguments

:: AuthHandler m 
=> Maybe Login

Login, Nothing will cause 400 error.

-> MToken' '["auth-info"] 
-> m RespUserInfo 

Implementation of AuthFindUserByLogin. Find user by login, throw 404 error if cannot find user by such login.

Low-level API

getAuthToken Source #

Arguments

:: AuthHandler m 
=> UserImplId

User for whom we want token

-> Maybe Seconds

Expiration duration, Nothing means default

-> m SimpleToken

Old token (if it doesn't expire) or new one

Helper to get or generate new token for user

hashPassword :: AuthHandler m => Password -> m Text Source #

Generate hash from given password and return it as text. May be useful if you don't like storing unencrypt passwords in config files.

setUserPasswordHash :: AuthHandler m => Text -> UserId -> m () Source #

Update password hash of user. Can be used to set direct hash for user password when it is taken from config file.

ensureAdminHash :: AuthHandler m => Int -> Login -> Text -> Email -> m () Source #

Ensures that DB has at least one admin, if not, creates a new one with specified info and direct password hash. May be useful if you don't like storing unencrypt passwords in config files.

signinByHashUnsafe Source #

Arguments

:: AuthHandler m 
=> Login

User login

-> Text

Hash of admin password

-> Maybe Seconds

Expire

-> m SimpleToken 

If you use password hash in configs, you cannot use them in signin method. This helper allows to get token by password hash and the function is not available for remote call (no endpoint).

Throws 401 if cannot find user or authorisation is failed.

WARNING: Do not expose the function to end user, never!