From 037f4644186ca2ac6dc7570c4b87a8a03e7c75f3 Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Thu, 16 May 2024 17:13:38 +0200 Subject: [PATCH] chore(oauth2): add debug output on azure auth plugin initialization --- src/Application.hs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Application.hs b/src/Application.hs index e9874d3c1..df53e5a24 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -331,7 +331,7 @@ makeFoundation appSettings''@AppSettings{..} = do , return $ oauth2AzureADv2Scoped ["openid", "profile", "offline_access"] "42" "shhh" ] #else - let -- Auth Plugins + -- let -- Auth Plugins -- loadPlugin p prefix = do -- Loads given YesodAuthPlugin -- mID <- fmap Text.pack <$> appUserAuthConf ^? _UserAuthConfSingleSource . _AuthSourceConfAzureAdV2 . _azureConfClientId -- mSecret <- fmap Text.pack <$> appUserAuthConf ^? _UserAuthConfSingleSource . _AuthSourceConfAzureAdV2 . _azureConfClientSecret @@ -343,11 +343,17 @@ makeFoundation appSettings''@AppSettings{..} = do -- -> tshow azureConfTenantId -- _other -- -> error "Tenant ID missing!" - oauth2Plugins - | UserAuthConfSingleSource (AuthSourceConfAzureAdV2 AzureConf{..}) <- appUserAuthConf - = singleton $ oauth2AzureADv2Scoped (Set.toList azureConfScopes) (tshow azureConfClientId) azureConfClientSecret - | otherwise - = mempty + oauth2Plugins <- if + | UserAuthConfSingleSource (AuthSourceConfAzureAdV2 AzureConf{..}) <- appUserAuthConf -> do + $logInfoS "OAuth2" "Successfully parsed OAuth2 config from AppSettings" + return . singleton $ oauth2AzureADv2Scoped (Set.toList azureConfScopes) (tshow azureConfClientId) azureConfClientSecret + | otherwise -> do + when appSingleSignOn $ do + $logErrorS "OAuth2" "SingleSignOn via AzureADv2 is enabled, but user-auth config could not be parsed!" + when appAutoSignOn $ + $logErrorS "OAuth2" "SingleSignOn via AzureADv2 and AutoSignOn are enabled, but user-auth config could not be parsed! This will likely prevent the app from being accessible!" + $logInfoS "UserAuthConf" $ tshow appUserAuthConf + return mempty #endif let appAuthPlugins = oauth2Plugins