chore(settings): simplify/flatten userdb config settings
This commit is contained in:
parent
1f31fe8cf2
commit
9dc6ec461c
@ -131,13 +131,12 @@ auto-db-migrate: '_env:AUTO_DB_MIGRATE:true'
|
||||
# External databases used for authentication and user data lookup
|
||||
# If the first user database in the list is unreachable, the application will perform a failover to the next list entry, etc.
|
||||
user-database:
|
||||
mode: simple
|
||||
mode: single-source
|
||||
protocol: oauth2
|
||||
config:
|
||||
protocol: "oauth2"
|
||||
config:
|
||||
client-id: "_env:OAUTH2CLIENTID:"
|
||||
client-secret: "_env:OAUTH2CLIENTSECRET:"
|
||||
tenant-id: "_env:OAUTH2TENANTID:"
|
||||
client-id: "_env:OAUTH2CLIENTID:"
|
||||
client-secret: "_env:OAUTH2CLIENTSECRET:"
|
||||
tenant-id: "_env:OAUTH2TENANTID:"
|
||||
# protocol: "ldap"
|
||||
# config:
|
||||
# host: "_env:LDAPHOST:"
|
||||
|
||||
@ -146,16 +146,16 @@ data UserDbConf' = UserDbLdap LdapConf | UserDbOAuth2 OAuth2Conf
|
||||
deriving (Show)
|
||||
|
||||
data UserDbConf =
|
||||
UserDbSimple -- ^ use only one specific source
|
||||
{ userdbSource :: UserDbConf'
|
||||
UserDbSingleSource -- ^ use only one specific source
|
||||
{ userdbSingleSource :: UserDbConf'
|
||||
}
|
||||
-- TODO: other modes yet to be implemented
|
||||
-- | UserDbFailover -- ^ use only one user source at a time, but failover to the next-best database if the current source is unavailable
|
||||
-- { userdbFailoverSources :: PointedList UserDbConf
|
||||
-- , userDbFailoverRetest :: NominalDiffTime
|
||||
-- }
|
||||
-- | UserDbMerge -- ^ Multiple coequal user sources
|
||||
-- { userdbMergeSources :: Set UserDbConf
|
||||
-- | UserDbMultiSource -- ^ Multiple coequal user sources
|
||||
-- { userdbMultiSources :: Set UserDbConf
|
||||
-- }
|
||||
deriving (Show)
|
||||
|
||||
@ -318,14 +318,12 @@ deriveFromJSON defaultOptions
|
||||
, sumEncoding = TaggedObject "protocol" "config"
|
||||
} ''UserDbConf'
|
||||
|
||||
instance FromJSON UserDbConf where
|
||||
parseJSON = withObject "UserDbConf" $ \o -> do
|
||||
mode <- o .: "mode"
|
||||
case mode of
|
||||
"simple" -> do
|
||||
userdbSource <- o .: "config"
|
||||
return UserDbSimple{..}
|
||||
other -> error $ "Unsupported user database mode: " <> other
|
||||
deriveFromJSON defaultOptions
|
||||
{ constructorTagModifier = camelToPathPiece' 1
|
||||
, fieldLabelModifier = camelToPathPiece' 1
|
||||
, sumEncoding = TaggedObject "mode" "config"
|
||||
, unwrapUnaryRecords = True
|
||||
} ''UserDbConf
|
||||
|
||||
instance FromJSON HaskellNet.PortNumber where
|
||||
parseJSON = withScientific "PortNumber" $ \sciNum -> case Scientific.toBoundedInteger sciNum of
|
||||
|
||||
Reference in New Issue
Block a user