chore: use previous oauth2 lib

This commit is contained in:
Sarah Vaupel 2024-03-18 12:54:05 +01:00
parent 7e33d9e5de
commit 8be3e2ea78
2 changed files with 8 additions and 8 deletions

View File

@ -61,7 +61,7 @@ import Jobs
import qualified Data.Text.Encoding as Text import qualified Data.Text.Encoding as Text
import Yesod.Auth.OAuth2.AzureADv2 (oauth2AzureADv2Scoped) import Yesod.Auth.OAuth2.AzureAD (oauth2AzureADScoped)
import Yesod.Auth.Util.PasswordStore import Yesod.Auth.Util.PasswordStore
import qualified Data.ByteString.Lazy as LBS import qualified Data.ByteString.Lazy as LBS
@ -349,7 +349,7 @@ makeFoundation appSettings''@AppSettings{..} = do
#ifdef DEVELOPMENT #ifdef DEVELOPMENT
oauth2Plugins <- liftIO $ sequence oauth2Plugins <- liftIO $ sequence
[ (azureMockServer . fromJust) <$> lookupEnv "OAUTH2_SERVER_PORT" [ (azureMockServer . fromJust) <$> lookupEnv "OAUTH2_SERVER_PORT"
, return $ oauth2AzureADv2Scoped ["openid", "profile", "offline_access"] "42" "42" "shhh" , return $ oauth2AzureADScoped ["openid", "profile", "offline_access"] "42" "shhh"
] ]
#else #else
let -- Auth Plugins let -- Auth Plugins
@ -366,7 +366,7 @@ makeFoundation appSettings''@AppSettings{..} = do
-> error "Tenant ID missing!" -> error "Tenant ID missing!"
oauth2Plugins oauth2Plugins
| UserAuthConfSingleSource (AuthSourceConfAzure AzureConf{..}) appUserAuthConf | UserAuthConfSingleSource (AuthSourceConfAzure AzureConf{..}) appUserAuthConf
-> singleton $ oauth2AzureADv2Scoped (Set.toList azureConfScopes) azureConfTenantId azureConfClientId azureConfClientSecret -> singleton $ oauth2AzureADScoped (Set.toList azureConfScopes) azureConfTenantId azureConfClientId azureConfClientSecret
| otherwise | otherwise
-> mempty -> mempty
#endif #endif

View File

@ -118,15 +118,15 @@ instance FromJSON UserID where
azureMockServer :: YesodAuth m => String -> AuthPlugin m azureMockServer :: YesodAuth m => String -> AuthPlugin m
azureMockServer port = azureMockServer port =
let oa = OAuth2 let oa = OAuth2
{ oauth2ClientId = "42" { oauthClientId = "42"
, oauth2ClientSecret = Just "shhh" , oauthClientSecret = Just "shhh"
, oauth2AuthorizeEndpoint = fromString (mockServerURL <> "/auth") , oauthOAuthorizeEndpoint = fromString (mockServerURL <> "/auth")
`withQuery` [ scopeParam " " ["openid", "profile", "email", "offline_access"] -- TODO read scopes from config `withQuery` [ scopeParam " " ["openid", "profile", "email", "offline_access"] -- TODO read scopes from config
, ("response_type", "code id_token") , ("response_type", "code id_token")
, ("nonce", "Foo") -- TODO generate meaningful value , ("nonce", "Foo") -- TODO generate meaningful value
] ]
, oauth2TokenEndpoint = fromString $ mockServerURL <> "/token" , oauthAccessTokenEndpoint = fromString $ mockServerURL <> "/token"
, oauth2RedirectUri = Nothing , oauthCallback = Nothing
} }
mockServerURL = "http://localhost:" <> fromString port mockServerURL = "http://localhost:" <> fromString port
profileSrc = fromString $ mockServerURL <> "/users/me" profileSrc = fromString $ mockServerURL <> "/users/me"