chore(jobs): upsertAzureUser on synchronise user job with azure config
This commit is contained in:
parent
24dbaf36bc
commit
f39de71c02
@ -11,8 +11,10 @@ import Import
|
|||||||
|
|
||||||
import qualified Data.CaseInsensitive as CI
|
import qualified Data.CaseInsensitive as CI
|
||||||
import qualified Data.Conduit.List as C
|
import qualified Data.Conduit.List as C
|
||||||
|
import qualified Data.UUID as UUID
|
||||||
|
|
||||||
import Auth.LDAP
|
import Auth.LDAP
|
||||||
|
import Auth.OAuth2
|
||||||
import Foundation.Yesod.Auth (CampusUserConversionException, upsertLdapUser, upsertAzureUser)
|
import Foundation.Yesod.Auth (CampusUserConversionException, upsertLdapUser, upsertAzureUser)
|
||||||
|
|
||||||
import Jobs.Queue
|
import Jobs.Queue
|
||||||
@ -44,23 +46,25 @@ dispatchJobSynchroniseUserdb numIterations epoch iteration
|
|||||||
|
|
||||||
dispatchJobSynchroniseUserdbUser :: UserId -> JobHandler UniWorX
|
dispatchJobSynchroniseUserdbUser :: UserId -> JobHandler UniWorX
|
||||||
dispatchJobSynchroniseUserdbUser jUser = JobHandlerException $ do
|
dispatchJobSynchroniseUserdbUser jUser = JobHandlerException $ do
|
||||||
UniWorX{..} <- getYesod
|
userSourceConf <- getsYesod $ view _appUserSourceConf
|
||||||
case appUserSourceConf of
|
case userSourceConf of
|
||||||
UserSourceConfSingleSource (UserSourceLdap ldapConf) ->
|
UserSourceConfSingleSource (UserSourceLdap _ldapConf) ->
|
||||||
runDB . void . runMaybeT . handleExc $ do
|
runDB . void . runMaybeT . handleExc $ do
|
||||||
|
ldapPool <- MaybeT . getsYesod $ view _appLdapPool
|
||||||
user@User{userIdent,userLdapPrimaryKey} <- MaybeT $ get jUser
|
user@User{userIdent,userLdapPrimaryKey} <- MaybeT $ get jUser
|
||||||
let upsertIdent = maybe userIdent CI.mk userLdapPrimaryKey
|
let upsertIdent = maybe userIdent CI.mk userLdapPrimaryKey
|
||||||
$logInfoS "SynchroniseUserdb" [st|Synchronising #{upsertIdent} with LDAP|]
|
$logInfoS "SynchroniseUserdb" [st|Synchronising #{upsertIdent} with LDAP|]
|
||||||
-- reTestAfter <- getsYesod $ view _appUserdbRetestFailover
|
-- reTestAfter <- getsYesod $ view _appUserdbRetestFailover
|
||||||
-- ldapAttrs <- MaybeT $ campusUserReTest' ldapConf ((>= reTestAfter) . realToFrac) FailoverUnlimited user
|
-- ldapAttrs <- MaybeT $ campusUserReTest' ldapConf ((>= reTestAfter) . realToFrac) FailoverUnlimited user
|
||||||
ldapAttrs <- MaybeT $ ldapUser ldapConf user
|
ldapAttrs <- MaybeT $ ldapUser' ldapPool user
|
||||||
void . lift $ upsertLdapUser (UpsertUserSync upsertIdent) ldapAttrs
|
void . lift $ upsertLdapUser (UpsertUserSync upsertIdent) ldapAttrs
|
||||||
UserSourceConfSingleSource (UserSourceAzureAdV2 azureConf) ->
|
UserSourceConfSingleSource (UserSourceAzureAdV2 azureConf) ->
|
||||||
runDB . void . runMaybeT . handleExc $ do
|
runDB . void . runMaybeT . handleExc $ do
|
||||||
user@User{userIdent,userAzurePrimaryKey} <- MaybeT $ get jUser
|
user@User{userIdent,userAzurePrimaryKey} <- MaybeT $ get jUser
|
||||||
let upsertIdent = maybe userIdent CI.mk userAzurePrimaryKey
|
let upsertIdent = maybe userIdent (CI.mk . UUID.toText) userAzurePrimaryKey -- TODO: use userPrincipalName
|
||||||
$logInfoS "SynchroniseUserdb" [st|Synchronising #{upsertIdent} with Azure|]
|
$logInfoS "SynchroniseUserdb" [st|Synchronising #{upsertIdent} with Azure|]
|
||||||
void . lift $ upsertAzureUser (UpsertUserSync upsertIdent) azureConf
|
azureAttrs <- MaybeT $ azureUser' azureConf user
|
||||||
|
void . lift $ upsertAzureUser (UpsertUserSync upsertIdent) azureAttrs
|
||||||
where
|
where
|
||||||
handleExc :: MaybeT DB a -> MaybeT DB a
|
handleExc :: MaybeT DB a -> MaybeT DB a
|
||||||
handleExc
|
handleExc
|
||||||
|
|||||||
Reference in New Issue
Block a user