lpr: add system function printer

This commit is contained in:
Steffen Jost 2022-08-23 18:43:26 +02:00
parent 5c2281bd29
commit 841936178d
4 changed files with 15 additions and 3 deletions

View File

@ -53,9 +53,9 @@ UserFunction -- Administratively assigned functions (lecturer, admin, evaluation
deriving Generic deriving Generic
UserSystemFunction UserSystemFunction
user UserId user UserId
function SystemFunction function SystemFunction -- Defined in Model.Types.User
manual Bool manual Bool -- Inserted manually by Admin or automatic from LDAP
isOptOut Bool isOptOut Bool -- User has currently deactivate the role for themselves
UniqueUserSystemFunction user function UniqueUserSystemFunction user function
deriving Generic deriving Generic
UserExamOffice UserExamOffice

2
routes
View File

@ -9,6 +9,8 @@
-- --
-- Admins always have access to entities within their assigned schools. -- Admins always have access to entities within their assigned schools.
-- --
-- Access tags are defined in Model.Types.Security
--
-- Access Tags: -- Access Tags:
-- !free -- free for all -- !free -- free for all
-- !lecturer -- lecturer for this course (or for any school, if route is not connected to a course) -- !lecturer -- lecturer for this course (or for any school, if route is not connected to a course)

View File

@ -555,6 +555,15 @@ tagAccessPredicate AuthSystemExamOffice = cacheAPSystemFunction SystemExamOffice
isExamOffice <- lift $ exists [UserSystemFunctionUser ==. authId, UserSystemFunctionFunction ==. SystemExamOffice, UserSystemFunctionIsOptOut ==. False] isExamOffice <- lift $ exists [UserSystemFunctionUser ==. authId, UserSystemFunctionFunction ==. SystemExamOffice, UserSystemFunctionIsOptOut ==. False]
guardMExceptT isExamOffice $ unauthorizedI MsgUnauthorizedSystemExamOffice guardMExceptT isExamOffice $ unauthorizedI MsgUnauthorizedSystemExamOffice
return Authorized return Authorized
tagAccessPredicate AuthSystemPrinter = cacheAPSystemFunction SystemPrinter (Just $ Right diffHour) $ \mAuthId' _ _ printerList -> if
| maybe True (`Set.notMember` printerList) mAuthId' -> Right $ if
| is _Nothing mAuthId' -> return AuthenticationRequired
| otherwise -> unauthorizedI MsgUnauthorizedSystemPrinter
| otherwise -> Left $ APDB $ \_ _ mAuthId _ _ -> $cachedHereBinary mAuthId . exceptT return return $ do
authId <- maybeExceptT AuthenticationRequired $ return mAuthId
isPrinter <- lift $ exists [UserSystemFunctionUser ==. authId, UserSystemFunctionFunction ==. SystemPrinter, UserSystemFunctionIsOptOut ==. False]
guardMExceptT isPrinter $ unauthorizedI MsgUnauthorizedSystemPrinter
return Authorized
tagAccessPredicate AuthStudent = cacheAPSystemFunction SystemStudent (Just $ Right diffHour) $ \mAuthId' _ _ studentList -> if tagAccessPredicate AuthStudent = cacheAPSystemFunction SystemStudent (Just $ Right diffHour) $ \mAuthId' _ _ studentList -> if
| maybe True (`Set.notMember` studentList) mAuthId' -> Right $ if | maybe True (`Set.notMember` studentList) mAuthId' -> Right $ if
| is _Nothing mAuthId' -> return AuthenticationRequired | is _Nothing mAuthId' -> return AuthenticationRequired

View File

@ -11,6 +11,7 @@ data SystemFunction
= SystemExamOffice = SystemExamOffice
| SystemFaculty | SystemFaculty
| SystemStudent | SystemStudent
| SystemPrinter
deriving (Eq, Ord, Read, Show, Enum, Bounded, Generic, Typeable) deriving (Eq, Ord, Read, Show, Enum, Bounded, Generic, Typeable)
deriving anyclass (Universe, Finite, Hashable, NFData) deriving anyclass (Universe, Finite, Hashable, NFData)