summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fig-web/main/Main.hs4
-rw-r--r--fig-web/src/Fig/Web/Auth.hs10
2 files changed, 9 insertions, 5 deletions
diff --git a/fig-web/main/Main.hs b/fig-web/main/Main.hs
index 89ac345..909127e 100644
--- a/fig-web/main/Main.hs
+++ b/fig-web/main/Main.hs
@@ -25,7 +25,7 @@ data Command
| Secure SecureOptions
parseCommand :: Parser Command
-parseCommand = subparser $ mconcat
+parseCommand = hsubparser $ mconcat
[ command "public" $ info (Public <$> parsePublicOptions) (progDesc "Launch the public web server")
, command "secure" $ info (Secure <$> parseSecureOptions) (progDesc "Launch the private web server (intended to be run behind authentication proxy)")
]
@@ -49,7 +49,7 @@ main :: IO ()
main = do
opts <- execParser $ info (parseOpts <**> helper)
( fullDesc
- <> Options.Applicative.header "fig-web - public-facing web applications"
+ <> Options.Applicative.header "fig-web - web backends"
)
cfg <- loadConfig opts.config
case opts.cmd of
diff --git a/fig-web/src/Fig/Web/Auth.hs b/fig-web/src/Fig/Web/Auth.hs
index 5017b3e..0e372c8 100644
--- a/fig-web/src/Fig/Web/Auth.hs
+++ b/fig-web/src/Fig/Web/Auth.hs
@@ -5,6 +5,7 @@ module Fig.Web.Auth
import Fig.Prelude
+import qualified Data.Text as Text
import qualified Web.Scotty as Sc
import Fig.Web.Types
@@ -12,14 +13,17 @@ import Fig.Web.Utils
data Credentials = Credentials
{ user :: Text
- , email :: Text
+ , twitchId :: Text
}
authed :: SecureModuleArgs -> (Credentials -> Sc.ActionM ()) -> Sc.ActionM ()
-authed args h = do
+authed args h | args.options.simAuth = do
+ let auth = Credentials { user = "fake_test_user", twitchId = "69" }
+ h auth
+authed _ h = do
muser <- header "Remote-User"
memail <- header "Remote-Email"
case (muser, memail) of
- (Just user, Just email) -> do
+ (Just user, Just email) | twitchId:_ <- Text.splitOn "@" email -> do
let auth = Credentials{..}
h auth
_else -> do