oauth2-mock-server/app/Main.hs
2024-01-16 03:06:13 +01:00

22 lines
666 B
Haskell

{-# Language TypeApplications #-}
module Main (main) where
import UniWorX
import Server
import Control.Applicative ((<|>))
import System.Environment (lookupEnv)
import qualified Data.Map as M
import qualified Data.Text as T
main :: IO ()
main = do
port <- determinePort
putStrLn $ "Try: http://localhost:" ++ show port ++ "/auth?scope=ID%20Profile&client_id=42&response_type=code&redirect_uri=http:%2F%2Flocalhost:0000%2F"
runMockServer @User @(M.Map T.Text T.Text) port
where
determinePort :: IO Int
determinePort = do
Just port <- lookupEnv "OAUTH2_SERVER_PORT" >>= \p -> return $ p <|> Just "9443"
return $ read @Int port