servant-auth-token-0.1.2.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.Model

Contents

Description

 

Synopsis

DB entities

data AuthUserGroupUsers Source

data AuthUserGroupPerms Source

data family EntityField record a

An EntityField is parameterised by the Haskell record it belongs to and the additional type of that field.

Instances

data EntityField AuthUserGroupPerms where 
data EntityField AuthUserGroupUsers where 
data EntityField AuthUserGroup where 
data EntityField UserRestore where 
data EntityField AuthToken where 
data EntityField UserPerm where 
data EntityField UserImpl where 

IDs of entities

Operations

runDB :: (MonadReader AuthConfig m, MonadIO m) => SqlPersistT IO b -> m b Source

Execute database transaction

passToByteString :: Password -> ByteString Source

Convert password to bytestring

byteStringToPass :: ByteString -> Password Source

Convert bytestring into password

User

userToUserInfo :: Entity UserImpl -> [Permission] -> [UserGroupId] -> RespUserInfo Source

Helper to convert user to response

getUserPermissions :: UserImplId -> SqlPersistT IO [Permission] Source

Return list of permissions for the given user (only permissions that are assigned to him directly)

setUserPermissions :: UserImplId -> [Permission] -> SqlPersistT IO () Source

Return list of permissions for the given user

createUser :: Int -> Login -> Password -> Email -> [Permission] -> SqlPersistT IO UserImplId Source

Creation of new user

hasPerm :: UserImplId -> Permission -> SqlPersistT IO Bool Source

Check whether the user has particular permission

hasPerms :: UserImplId -> [Permission] -> SqlPersistT IO Bool Source

Check whether the user has particular permissions

createAdmin :: Int -> Login -> Password -> Email -> SqlPersistT IO UserImplId Source

Creates user with admin privileges

ensureAdmin :: Int -> Login -> Password -> Email -> SqlPersistT IO () Source

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

patchUser Source

Arguments

:: Int

Password strength

-> PatchUser 
-> Entity UserImpl 
-> SqlPersistT IO (Entity UserImpl) 

Apply patches for user

setUserPassword' Source

Arguments

:: MonadIO m 
=> Int

Password strength

-> Password 
-> UserImpl 
-> m UserImpl 

Update password of user

User groups

getUserGroups :: UserImplId -> SqlPersistT IO [UserGroupId] Source

Get all groups the user belongs to

setUserGroups :: UserImplId -> [UserGroupId] -> SqlPersistT IO () Source

Rewrite all user groups

validateGroups :: [UserGroupId] -> SqlPersistT IO [AuthUserGroupId] Source

Leave only existing groups

getGroupPermissions :: UserGroupId -> SqlPersistT IO [Permission] Source

Getting permission of a group and all it parent groups

getUserGroupPermissions :: UserImplId -> SqlPersistT IO [Permission] Source

Get user permissions that are assigned to him/her via groups only

getUserAllPermissions :: UserImplId -> SqlPersistT IO [Permission] Source

Get user permissions that are assigned to him/her either by direct way or by his/her groups.

readUserGroup :: UserGroupId -> SqlPersistT IO (Maybe UserGroup) Source

Collect full info about user group from RDBMS

toAuthUserGroup :: UserGroup -> (AuthUserGroup, AuthUserGroupId -> [AuthUserGroupUsers], AuthUserGroupId -> [AuthUserGroupPerms]) Source

Helper to convert user group into values of several tables

insertUserGroup :: UserGroup -> SqlPersistT IO UserGroupId Source

Insert user group into RDBMS

updateUserGroup :: UserGroupId -> UserGroup -> SqlPersistT IO () Source

Replace user group with new value

deleteUserGroup :: UserGroupId -> SqlPersistT IO () Source

Erase user group from RDBMS, cascade

patchUserGroup :: UserGroupId -> PatchUserGroup -> SqlPersistT IO () Source

Partial update of user group