Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newtype ModelId = ModelId {}
- modelId :: ModelId
- data Model = Model {
- _modelUsers :: !(Set UserImplId)
- _modelUsersByLogin :: !(Map Login UserImplId)
- _modelUserPerms :: !(Set UserPermId)
- _modelAuthTokens :: !(Set AuthTokenId)
- _modelUserRestores :: !(Set UserRestoreId)
- _modelUserSingleUseCodes :: !(Set UserSingleUseCodeId)
- _modelAuthUserGroups :: !(Set AuthUserGroupId)
- _modelAuthUserGroupUsers :: !(Set AuthUserGroupUsersId)
- _modelAuthUserGroupPerms :: !(Set AuthUserGroupPermsId)
- _modelNextUserImplId :: !Int64
- _modelNextUserPermId :: !Int64
- _modelNextAuthTokenId :: !Int64
- _modelNextUserRestoreId :: !Int64
- _modelNextUserSingleUseCodeId :: !Int64
- _modelNextAuthUserGroupId :: !Int64
- _modelNextAuthUserGroupUserId :: !Int64
- _modelNextAuthUserGroupPermId :: !Int64
- modelUsersByLogin :: Lens' Model (Map Login UserImplId)
- modelUsers :: Lens' Model (Set UserImplId)
- modelUserSingleUseCodes :: Lens' Model (Set UserSingleUseCodeId)
- modelUserRestores :: Lens' Model (Set UserRestoreId)
- modelUserPerms :: Lens' Model (Set UserPermId)
- modelNextUserSingleUseCodeId :: Lens' Model Int64
- modelNextUserRestoreId :: Lens' Model Int64
- modelNextUserPermId :: Lens' Model Int64
- modelNextUserImplId :: Lens' Model Int64
- modelNextAuthUserGroupUserId :: Lens' Model Int64
- modelNextAuthUserGroupPermId :: Lens' Model Int64
- modelNextAuthUserGroupId :: Lens' Model Int64
- modelNextAuthTokenId :: Lens' Model Int64
- modelAuthUserGroups :: Lens' Model (Set AuthUserGroupId)
- modelAuthUserGroupUsers :: Lens' Model (Set AuthUserGroupUsersId)
- modelAuthUserGroupPerms :: Lens' Model (Set AuthUserGroupPermsId)
- modelAuthTokens :: Lens' Model (Set AuthTokenId)
- newModel :: Model
- class Key i a | i -> a, a -> i where
- data LevelDBEnv = LevelDBEnv !DB !ReadOptions !WriteOptions !RLock
- newLevelDBEnv :: MonadIO m => DB -> ReadOptions -> WriteOptions -> m LevelDBEnv
- load :: (MonadResource m, Key i a, SafeCopy a) => LevelDBEnv -> i -> m (Maybe a)
- store :: (MonadResource m, Key i a, SafeCopy a) => LevelDBEnv -> i -> a -> m ()
- remove :: (MonadResource m, Key i a) => LevelDBEnv -> i -> m ()
- modify :: (MonadResource m, MonadMask m, Key i a, SafeCopy a) => LevelDBEnv -> i -> (a -> a) -> m ()
- modifyM :: (MonadResource m, MonadMask m, Key i a, SafeCopy a) => LevelDBEnv -> i -> (a -> m a) -> m ()
- loadModel :: MonadResource m => LevelDBEnv -> m Model
- storeModel :: MonadResource m => LevelDBEnv -> Model -> m ()
- modifyModel :: MonadResource m => LevelDBEnv -> (Model -> Model) -> m ()
- modifyModelM :: (MonadResource m, MonadMask m) => LevelDBEnv -> (Model -> m (Model, a)) -> m a
- getPagedList :: (MonadResource m, Ord i, Key i a, SafeCopy a) => LevelDBEnv -> Page -> PageSize -> Set i -> m ([WithId i a], Word)
- insertRecord :: (MonadResource m, MonadMask m, Key i a, ConvertableKey i, Ord i, SafeCopy a) => Lens' Model Int64 -> Lens' Model (Set i) -> a -> LevelDBEnv -> m i
- selectRecords :: (MonadResource m, Key i a, SafeCopy a) => Lens' Model (Set i) -> (i -> a -> Bool) -> LevelDBEnv -> m [WithId i a]
- deleteRecords :: (MonadResource m, MonadMask m, Key i a, Ord i, Foldable f) => Lens' Model (Set i) -> f i -> LevelDBEnv -> m ()
- replaceRecord :: (MonadResource m, MonadMask m, Key i a, Ord i, SafeCopy a) => Lens' Model (Set i) -> i -> a -> LevelDBEnv -> m ()
- withId :: WithField s i a -> i
- withVal :: WithField s i a -> a
- getUserImplByLogin :: MonadResource m => Login -> LevelDBEnv -> m (Maybe (WithId UserImplId UserImpl))
- listUsersPaged :: MonadResource m => Page -> PageSize -> LevelDBEnv -> m ([WithId UserImplId UserImpl], Word)
- getUserImplPermissions :: MonadResource m => UserImplId -> LevelDBEnv -> m [WithId UserPermId UserPerm]
- deleteUserPermissions :: (MonadResource m, MonadMask m) => UserImplId -> LevelDBEnv -> m ()
- insertUserPerm :: (MonadResource m, MonadMask m) => UserPerm -> LevelDBEnv -> m UserPermId
- insertUserImpl :: (MonadResource m, MonadMask m) => UserImpl -> LevelDBEnv -> m UserImplId
- replaceUserImpl :: (MonadResource m, MonadMask m) => UserImplId -> UserImpl -> LevelDBEnv -> m ()
- deleteUserImpl :: (MonadResource m, MonadMask m) => UserImplId -> LevelDBEnv -> m ()
- hasPerm :: MonadResource m => UserImplId -> Permission -> LevelDBEnv -> m Bool
- getFirstUserByPerm :: MonadResource m => Permission -> LevelDBEnv -> m (Maybe (WithId UserImplId UserImpl))
- selectUserImplGroups :: MonadResource m => UserImplId -> LevelDBEnv -> m [WithId AuthUserGroupUsersId AuthUserGroupUsers]
- clearUserImplGroups :: (MonadResource m, MonadMask m) => UserImplId -> LevelDBEnv -> m ()
- insertAuthUserGroup :: (MonadResource m, MonadMask m) => AuthUserGroup -> LevelDBEnv -> m AuthUserGroupId
- insertAuthUserGroupUsers :: (MonadResource m, MonadMask m) => AuthUserGroupUsers -> LevelDBEnv -> m AuthUserGroupUsersId
- insertAuthUserGroupPerms :: (MonadResource m, MonadMask m) => AuthUserGroupPerms -> LevelDBEnv -> m AuthUserGroupPermsId
- listAuthUserGroupPermissions :: MonadResource m => AuthUserGroupId -> LevelDBEnv -> m [WithId AuthUserGroupPermsId AuthUserGroupPerms]
- listAuthUserGroupUsers :: MonadResource m => AuthUserGroupId -> LevelDBEnv -> m [WithId AuthUserGroupUsersId AuthUserGroupUsers]
- replaceAuthUserGroup :: (MonadResource m, MonadMask m) => AuthUserGroupId -> AuthUserGroup -> LevelDBEnv -> m ()
- clearAuthUserGroupUsers :: (MonadResource m, MonadMask m) => AuthUserGroupId -> LevelDBEnv -> m ()
- clearAuthUserGroupPerms :: (MonadResource m, MonadMask m) => AuthUserGroupId -> LevelDBEnv -> m ()
- deleteAuthUserGroup :: (MonadResource m, MonadMask m) => AuthUserGroupId -> LevelDBEnv -> m ()
- listGroupsPaged :: MonadResource m => Page -> PageSize -> LevelDBEnv -> m ([WithId AuthUserGroupId AuthUserGroup], Word)
- setAuthUserGroupName :: (MonadResource m, MonadMask m) => AuthUserGroupId -> Text -> LevelDBEnv -> m ()
- setAuthUserGroupParent :: (MonadResource m, MonadMask m) => AuthUserGroupId -> Maybe AuthUserGroupId -> LevelDBEnv -> m ()
- insertSingleUseCode :: (MonadResource m, MonadMask m) => UserSingleUseCode -> LevelDBEnv -> m UserSingleUseCodeId
- setSingleUseCodeUsed :: (MonadResource m, MonadMask m) => UserSingleUseCodeId -> Maybe UTCTime -> LevelDBEnv -> m ()
- getUnusedCode :: MonadResource m => SingleUseCode -> UserImplId -> UTCTime -> LevelDBEnv -> m (Maybe (WithId UserSingleUseCodeId UserSingleUseCode))
- invalidatePermamentCodes :: (MonadResource m, MonadMask m) => UserImplId -> UTCTime -> LevelDBEnv -> m ()
- selectLastRestoreCode :: MonadResource m => UserImplId -> UTCTime -> LevelDBEnv -> m (Maybe (WithId UserRestoreId UserRestore))
- insertUserRestore :: (MonadResource m, MonadMask m) => UserRestore -> LevelDBEnv -> m UserRestoreId
- findRestoreCode :: MonadResource m => UserImplId -> RestoreCode -> UTCTime -> LevelDBEnv -> m (Maybe (WithId UserRestoreId UserRestore))
- replaceRestoreCode :: (MonadResource m, MonadMask m) => UserRestoreId -> UserRestore -> LevelDBEnv -> m ()
- findAuthToken :: MonadResource m => UserImplId -> UTCTime -> LevelDBEnv -> m (Maybe (WithId AuthTokenId AuthToken))
- findAuthTokenByValue :: MonadResource m => SimpleToken -> LevelDBEnv -> m (Maybe (WithId AuthTokenId AuthToken))
- insertAuthToken :: (MonadResource m, MonadMask m) => AuthToken -> LevelDBEnv -> m AuthTokenId
- replaceAuthToken :: (MonadResource m, MonadMask m) => AuthTokenId -> AuthToken -> LevelDBEnv -> m ()
Documentation
ID of global model index
Holds all data for auth server in acid-state container
modelUsers :: Lens' Model (Set UserImplId) Source #
modelUserPerms :: Lens' Model (Set UserPermId) Source #
class Key i a | i -> a, a -> i where Source #
Helper that defines bijection between key and record
encodeKey :: i -> ByteString Source #
encodeKey :: (SafeCopy i, Typeable i) => i -> ByteString Source #
data LevelDBEnv Source #
Holds together db reference and options for read/write and mutex
Monad m => MonadReader (AuthConfig, LevelDBEnv) (LevelDBBackendT m) # | |
newLevelDBEnv :: MonadIO m => DB -> ReadOptions -> WriteOptions -> m LevelDBEnv Source #
Make new environment for execution of LevelDB operations
load :: (MonadResource m, Key i a, SafeCopy a) => LevelDBEnv -> i -> m (Maybe a) Source #
Load object by id from leveldb
store :: (MonadResource m, Key i a, SafeCopy a) => LevelDBEnv -> i -> a -> m () Source #
Store object by id in leveldb
remove :: (MonadResource m, Key i a) => LevelDBEnv -> i -> m () Source #
Remove object by given id in leveldb
modify :: (MonadResource m, MonadMask m, Key i a, SafeCopy a) => LevelDBEnv -> i -> (a -> a) -> m () Source #
Modify value by id in leveldb
modifyM :: (MonadResource m, MonadMask m, Key i a, SafeCopy a) => LevelDBEnv -> i -> (a -> m a) -> m () Source #
Modify value by id in leveldb
loadModel :: MonadResource m => LevelDBEnv -> m Model Source #
Load global index from leveldb
storeModel :: MonadResource m => LevelDBEnv -> Model -> m () Source #
Store glogal index to leveldb
modifyModel :: MonadResource m => LevelDBEnv -> (Model -> Model) -> m () Source #
Modify global index
modifyModelM :: (MonadResource m, MonadMask m) => LevelDBEnv -> (Model -> m (Model, a)) -> m a Source #
Modify global index
getPagedList :: (MonadResource m, Ord i, Key i a, SafeCopy a) => LevelDBEnv -> Page -> PageSize -> Set i -> m ([WithId i a], Word) Source #
Helper to get paged list of entities
:: (MonadResource m, MonadMask m, Key i a, ConvertableKey i, Ord i, SafeCopy a) | |
=> Lens' Model Int64 | Field of model that store counter of the record ids |
-> Lens' Model (Set i) | Field of model that store a registry of the record ids |
-> a | |
-> LevelDBEnv | |
-> m i |
Generic way to insert record in the leveldb with track in global registry
:: (MonadResource m, Key i a, SafeCopy a) | |
=> Lens' Model (Set i) | Model field with registry of the records |
-> (i -> a -> Bool) | Predicate |
-> LevelDBEnv | |
-> m [WithId i a] |
Generic way to select all records that satisfies given predicate
:: (MonadResource m, MonadMask m, Key i a, Ord i, Foldable f) | |
=> Lens' Model (Set i) | Model field with registry of the records |
-> f i | Set of ids of records that should be deleted |
-> LevelDBEnv | |
-> m () |
Generic way to delete several records with respect of global registry
:: (MonadResource m, MonadMask m, Key i a, Ord i, SafeCopy a) | |
=> Lens' Model (Set i) | Model field with registry of the records |
-> i | ID of record |
-> a | Value of record |
-> LevelDBEnv | |
-> m () |
Generic way to replace record in registry and leveldb
getUserImplByLogin :: MonadResource m => Login -> LevelDBEnv -> m (Maybe (WithId UserImplId UserImpl)) Source #
Getting user from storage by login
listUsersPaged :: MonadResource m => Page -> PageSize -> LevelDBEnv -> m ([WithId UserImplId UserImpl], Word) Source #
Get paged list of users and total count of users
getUserImplPermissions :: MonadResource m => UserImplId -> LevelDBEnv -> m [WithId UserPermId UserPerm] Source #
Get user permissions, ascending by tag
deleteUserPermissions :: (MonadResource m, MonadMask m) => UserImplId -> LevelDBEnv -> m () Source #
Delete user permissions
insertUserPerm :: (MonadResource m, MonadMask m) => UserPerm -> LevelDBEnv -> m UserPermId Source #
Insertion of new user permission
insertUserImpl :: (MonadResource m, MonadMask m) => UserImpl -> LevelDBEnv -> m UserImplId Source #
Insertion of new user
replaceUserImpl :: (MonadResource m, MonadMask m) => UserImplId -> UserImpl -> LevelDBEnv -> m () Source #
Replace user with new value
deleteUserImpl :: (MonadResource m, MonadMask m) => UserImplId -> LevelDBEnv -> m () Source #
Delete user by id
hasPerm :: MonadResource m => UserImplId -> Permission -> LevelDBEnv -> m Bool Source #
Check whether the user has particular permission
getFirstUserByPerm :: MonadResource m => Permission -> LevelDBEnv -> m (Maybe (WithId UserImplId UserImpl)) Source #
Get any user with given permission
selectUserImplGroups :: MonadResource m => UserImplId -> LevelDBEnv -> m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #
Select user groups and sort them by ascending name
clearUserImplGroups :: (MonadResource m, MonadMask m) => UserImplId -> LevelDBEnv -> m () Source #
Remove user from all groups
insertAuthUserGroup :: (MonadResource m, MonadMask m) => AuthUserGroup -> LevelDBEnv -> m AuthUserGroupId Source #
Add new user group
insertAuthUserGroupUsers :: (MonadResource m, MonadMask m) => AuthUserGroupUsers -> LevelDBEnv -> m AuthUserGroupUsersId Source #
Add user to given group
insertAuthUserGroupPerms :: (MonadResource m, MonadMask m) => AuthUserGroupPerms -> LevelDBEnv -> m AuthUserGroupPermsId Source #
Add permission to given group
listAuthUserGroupPermissions :: MonadResource m => AuthUserGroupId -> LevelDBEnv -> m [WithId AuthUserGroupPermsId AuthUserGroupPerms] Source #
Get list of permissions of given group
listAuthUserGroupUsers :: MonadResource m => AuthUserGroupId -> LevelDBEnv -> m [WithId AuthUserGroupUsersId AuthUserGroupUsers] Source #
Get list of all users of the group
replaceAuthUserGroup :: (MonadResource m, MonadMask m) => AuthUserGroupId -> AuthUserGroup -> LevelDBEnv -> m () Source #
Replace record of user group
clearAuthUserGroupUsers :: (MonadResource m, MonadMask m) => AuthUserGroupId -> LevelDBEnv -> m () Source #
Remove all users from group
clearAuthUserGroupPerms :: (MonadResource m, MonadMask m) => AuthUserGroupId -> LevelDBEnv -> m () Source #
Remove all permissions from group
deleteAuthUserGroup :: (MonadResource m, MonadMask m) => AuthUserGroupId -> LevelDBEnv -> m () Source #
Delete user group from storage
listGroupsPaged :: MonadResource m => Page -> PageSize -> LevelDBEnv -> m ([WithId AuthUserGroupId AuthUserGroup], Word) Source #
Get paged list of user groups with total count
setAuthUserGroupName :: (MonadResource m, MonadMask m) => AuthUserGroupId -> Text -> LevelDBEnv -> m () Source #
Set group name
setAuthUserGroupParent :: (MonadResource m, MonadMask m) => AuthUserGroupId -> Maybe AuthUserGroupId -> LevelDBEnv -> m () Source #
Set group parent
insertSingleUseCode :: (MonadResource m, MonadMask m) => UserSingleUseCode -> LevelDBEnv -> m UserSingleUseCodeId Source #
Add new single use code
setSingleUseCodeUsed :: (MonadResource m, MonadMask m) => UserSingleUseCodeId -> Maybe UTCTime -> LevelDBEnv -> m () Source #
Set usage time of the single use code
getUnusedCode :: MonadResource m => SingleUseCode -> UserImplId -> UTCTime -> LevelDBEnv -> m (Maybe (WithId UserSingleUseCodeId UserSingleUseCode)) Source #
Find unused code for the user and expiration time greater than the given time
invalidatePermamentCodes :: (MonadResource m, MonadMask m) => UserImplId -> UTCTime -> LevelDBEnv -> m () Source #
Invalidate all permament codes for user and set use time for them
selectLastRestoreCode :: MonadResource m => UserImplId -> UTCTime -> LevelDBEnv -> m (Maybe (WithId UserRestoreId UserRestore)) Source #
Select last valid restoration code by the given current time
insertUserRestore :: (MonadResource m, MonadMask m) => UserRestore -> LevelDBEnv -> m UserRestoreId Source #
Insert new restore code
findRestoreCode :: MonadResource m => UserImplId -> RestoreCode -> UTCTime -> LevelDBEnv -> m (Maybe (WithId UserRestoreId UserRestore)) Source #
Find unexpired by the time restore code
replaceRestoreCode :: (MonadResource m, MonadMask m) => UserRestoreId -> UserRestore -> LevelDBEnv -> m () Source #
Replace restore code with new value
findAuthToken :: MonadResource m => UserImplId -> UTCTime -> LevelDBEnv -> m (Maybe (WithId AuthTokenId AuthToken)) Source #
Find first non-expired by the time token for user
findAuthTokenByValue :: MonadResource m => SimpleToken -> LevelDBEnv -> m (Maybe (WithId AuthTokenId AuthToken)) Source #
Find token by value
insertAuthToken :: (MonadResource m, MonadMask m) => AuthToken -> LevelDBEnv -> m AuthTokenId Source #
Insert new token
replaceAuthToken :: (MonadResource m, MonadMask m) => AuthTokenId -> AuthToken -> LevelDBEnv -> m () Source #
Replace auth token with new value