address comment: add auth0 to example

This commit is contained in:
Haisheng W - M 2022-08-17 15:25:01 -07:00 committed by patrick brisbin
parent fa25c8ad56
commit 1842441647
3 changed files with 11 additions and 0 deletions

View File

@ -5,6 +5,11 @@
# you plan to try. # you plan to try.
# #
### ###
AUTH0_HOST=x
AUTH0_CLIENT_ID=x
AUTH0_CLIENT_SECRET=x
AZURE_AD_CLIENT_ID=x AZURE_AD_CLIENT_ID=x
AZURE_AD_CLIENT_SECRET=x AZURE_AD_CLIENT_SECRET=x

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
.stack-work .stack-work
TAGS
# OAuth keys configuration for the example # OAuth keys configuration for the example
.env* .env*

View File

@ -26,6 +26,7 @@ import Data.Aeson.Encode.Pretty
import Data.ByteString.Lazy (fromStrict, toStrict) import Data.ByteString.Lazy (fromStrict, toStrict)
import qualified Data.Map as M import qualified Data.Map as M
import Data.Maybe (fromJust) import Data.Maybe (fromJust)
import Data.String ( IsString(fromString) )
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text as T import qualified Data.Text as T
import Data.Text.Encoding (decodeUtf8) import Data.Text.Encoding (decodeUtf8)
@ -35,6 +36,7 @@ import Network.Wai.Handler.Warp (runEnv)
import System.Environment (getEnv) import System.Environment (getEnv)
import Yesod import Yesod
import Yesod.Auth import Yesod.Auth
import Yesod.Auth.OAuth2.Auth0
import Yesod.Auth.OAuth2.AzureAD import Yesod.Auth.OAuth2.AzureAD
import Yesod.Auth.OAuth2.BattleNet import Yesod.Auth.OAuth2.BattleNet
import Yesod.Auth.OAuth2.Bitbucket import Yesod.Auth.OAuth2.Bitbucket
@ -129,6 +131,8 @@ mkFoundation :: IO App
mkFoundation = do mkFoundation = do
loadEnv loadEnv
auth0Host <- getEnv "AUTH0_HOST"
appHttpManager <- newManager tlsManagerSettings appHttpManager <- newManager tlsManagerSettings
appAuthPlugins <- sequence appAuthPlugins <- sequence
-- When Providers are added, add them here and update .env.example. -- When Providers are added, add them here and update .env.example.
@ -137,6 +141,7 @@ mkFoundation = do
-- FIXME: oauth2BattleNet is quite annoying! -- FIXME: oauth2BattleNet is quite annoying!
-- --
[ loadPlugin oauth2AzureAD "AZURE_AD" [ loadPlugin oauth2AzureAD "AZURE_AD"
, loadPlugin (oauth2Auth0Host $ fromString auth0Host) "AUTH0"
, loadPlugin (oauth2BattleNet [whamlet|TODO|] "en") "BATTLE_NET" , loadPlugin (oauth2BattleNet [whamlet|TODO|] "en") "BATTLE_NET"
, loadPlugin oauth2Bitbucket "BITBUCKET" , loadPlugin oauth2Bitbucket "BITBUCKET"
, loadPlugin oauth2ClassLink "CLASSLINK" , loadPlugin oauth2ClassLink "CLASSLINK"