refactor(model): migrate auth models and model types to models/auth.model

This commit is contained in:
Sarah Vaupel 2024-02-13 17:38:22 +01:00
parent 42c97924ec
commit 7803b753cb
4 changed files with 32 additions and 29 deletions

28
models/auth.model Normal file
View File

@ -0,0 +1,28 @@
-- SPDX-FileCopyrightText: 2024 Sarah Vaupel <sarah.vaupel@uniworx.de>
--
-- SPDX-License-Identifier: AGPL-3.0-or-later
-- | User authentication data, source-agnostic data
UserAuth
ident UserIdent -- Human-readable text uniquely identifying a user
lastLogin UTCTime -- When did the corresponding User last authenticate using this entry?
Primary ident
UniqueAuthentication ident
deriving Show Eq Ord Generic
-- | User authentication data fetched from external user sources
ExternalAuth
ident UserIdent
source AuthenticationSourceIdent -- Identifier of the external source in the config
data Value "default='{}'::jsonb" -- Raw user data from external source
lastSync UTCTime -- When was the corresponding User entry last synced with this external source?
UniqueExternalAuth ident source -- At most one entry of this user per source
deriving Show Eq Ord Generic
-- | FraDrive-specific user authentication data, internal logins have precedence over external authentication
InternalAuth
ident UserIdent
hash Text -- Hashed password
Primary ident
UniqueInternalAuth ident
deriving Show Eq Ord Generic

View File

@ -51,31 +51,6 @@ User json -- Each Uni2work user has a corresponding row in this table; create
UniqueEmail email -- Column 'email' can be used as a row-key in this table
deriving Show Eq Ord Generic -- Haskell-specific settings for runtime-value representing a row in memory
-- | User authentication data, source-agnostic data
UserAuth
ident UserIdent -- Human-readable text uniquely identifying a user
lastLogin UTCTime -- When did the corresponding User last authenticate using this entry?
Primary ident
UniqueAuthentication ident
deriving Show Eq Ord Generic
-- | User authentication data fetched from external user sources
ExternalAuth
ident UserIdent
source AuthenticationSourceIdent -- Identifier of the external source in the config
data Value "default='{}'::jsonb" -- Raw user data from external source
lastSync UTCTime -- When was the corresponding User entry last synced with this external source?
UniqueExternalAuth ident source -- At most one entry of this user per source
deriving Show Eq Ord Generic
-- | FraDrive-specific user authentication data, internal logins have precedence over external authentication
InternalAuth
ident UserIdent
hash Text -- Hashed password
Primary ident
UniqueInternalAuth ident
deriving Show Eq Ord Generic
UserFunction -- Administratively assigned functions (lecturer, admin, evaluation, ...)
user UserId
school SchoolId

View File

@ -48,6 +48,9 @@ import Database.Persist.Sql
import Servant.Docs (ToSample(..), samples)
type UserEduPersonPrincipalName = Text
-- | Supported protocols for external user sources used for authentication queries
data AuthenticationProtocol
= AuthAzure -- ^ Azure ADv2 (OAuth2)

View File

@ -1,4 +1,4 @@
-- SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Steffen Jost <jost@tcs.ifi.lmu.de>
-- SPDX-FileCopyrightText: 2022-2024 Sarah Vaupel <sarah.vaupel@uniworx.de>, Gregor Kleen <gregor.kleen@ifi.lmu.de>, Sarah Vaupel <sarah.vaupel@ifi.lmu.de>, Steffen Jost <jost@tcs.ifi.lmu.de>
--
-- SPDX-License-Identifier: AGPL-3.0-or-later
@ -8,9 +8,6 @@ import Import.NoModel
import Model.Types.TH.PathPiece
type UserEduPersonPrincipalName = Text
data SystemFunction
= SystemExamOffice
| SystemFaculty