From acd6a3c11c75f85dd11422e4ad535d78512c06a8 Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Thu, 14 Mar 2024 12:42:10 +0100 Subject: [PATCH] chore: hlint --- src/Auth/OAuth2.hs | 2 +- src/Foundation/Yesod/Auth.hs | 14 +++++++------- src/Settings.hs | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Auth/OAuth2.hs b/src/Auth/OAuth2.hs index 272129052..fa1291407 100644 --- a/src/Auth/OAuth2.hs +++ b/src/Auth/OAuth2.hs @@ -120,7 +120,7 @@ azureMockServer port = let oa = OAuth2 { oauth2ClientId = "42" , oauth2ClientSecret = Just "shhh" - , oauth2AuthorizeEndpoint = (fromString $ mockServerURL <> "/auth") + , oauth2AuthorizeEndpoint = fromString (mockServerURL <> "/auth") `withQuery` [ scopeParam " " ["openid", "profile", "email", "offline_access"] -- TODO read scopes from config , ("response_type", "code id_token") , ("nonce", "Foo") -- TODO generate meaningful value diff --git a/src/Foundation/Yesod/Auth.hs b/src/Foundation/Yesod/Auth.hs index 94573e8fd..72f9cda84 100644 --- a/src/Foundation/Yesod/Auth.hs +++ b/src/Foundation/Yesod/Auth.hs @@ -51,7 +51,7 @@ authenticate :: ( MonadHandler m, HandlerSite m ~ UniWorX -> m (AuthenticationResult UniWorX) authenticate creds@Creds{..} = liftHandler . runDB . withReaderT projectBackend $ do $logErrorS "Auth Debug" $ "\a\27[31m" <> tshow creds <> "\27[0m" -- TODO: debug only - setSessionJson SessionOAuth2Token $ (getAccessToken creds, getRefreshToken creds) + setSessionJson SessionOAuth2Token (getAccessToken creds, getRefreshToken creds) sess <- getSession $logErrorS "OAuth session Debug" $ "\27[34m" <> tshow sess <> "\27[0m" -- TODO: debug only @@ -210,12 +210,12 @@ fetchUserData Creds{..} = do UpsertUserDataLdap{..} -> (toJSON upsertUserLdapData, AuthSourceIdLdap upsertUserLdapHost) externalUserUser <- if | UpsertUserDataAzure{..} <- res - , azureData <- Map.fromListWith (++) $ upsertUserAzureData <&> \(t,bs) -> (t, filter (not . ByteString.null) bs) - , [(Text.decodeUtf8' -> Right azureUserPrincipalName')] <- azureData !!! azureUserPrincipalName + , azureData <- Map.fromListWith (++) $ upsertUserAzureData <&> second (filter (not . ByteString.null)) + , [Text.decodeUtf8' -> Right azureUserPrincipalName'] <- azureData !!! azureUserPrincipalName -> return $ CI.mk azureUserPrincipalName' | UpsertUserDataLdap{..} <- res - , ldapData <- Map.fromListWith (++) $ upsertUserLdapData <&> \(t,bs) -> (t, filter (not . ByteString.null) bs) - , [(Text.decodeUtf8' -> Right ldapPrimaryKey')] <- ldapData !!! ldapPrimaryKey + , ldapData <- Map.fromListWith (++) $ upsertUserLdapData <&> second (filter (not . ByteString.null)) + , [Text.decodeUtf8' -> Right ldapPrimaryKey'] <- ldapData !!! ldapPrimaryKey -> return $ CI.mk ldapPrimaryKey' | otherwise -> throwM DecodeUserInvalidIdent @@ -291,11 +291,11 @@ decodeUser :: ( MonadThrow m decodeUser now UserDefaultConf{..} upsertData = do userIdent <- if | Just azureData <- mbAzureData - , [(Text.decodeUtf8' -> Right azureUserPrincipalName')] <- azureData !!! azureUserPrincipalName + , [Text.decodeUtf8' -> Right azureUserPrincipalName'] <- azureData !!! azureUserPrincipalName , Just azureUserPrincipalName'' <- assertM' (not . Text.null) $ Text.strip azureUserPrincipalName' -> return $ CI.mk azureUserPrincipalName'' | Just ldapData <- mbLdapData - , [(Text.decodeUtf8' -> Right ldapPrimaryKey')] <- ldapData !!! ldapPrimaryKey + , [Text.decodeUtf8' -> Right ldapPrimaryKey'] <- ldapData !!! ldapPrimaryKey , Just ldapPrimaryKey'' <- assertM' (not . Text.null) $ Text.strip ldapPrimaryKey' -> return $ CI.mk ldapPrimaryKey'' | otherwise diff --git a/src/Settings.hs b/src/Settings.hs index 1762c46fd..773071a5e 100644 --- a/src/Settings.hs +++ b/src/Settings.hs @@ -140,7 +140,7 @@ instance FromJSON PWHashConf where data AuthSourceConf = AuthSourceConfLdap LdapConf | AuthSourceConfAzureAdV2 AzureConf deriving (Show) -data UserAuthConf = +newtype UserAuthConf = UserAuthConfSingleSource -- ^ use only one specific source { userAuthConfSingleSource :: AuthSourceConf }