aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2017-12-19 15:47:37 +0300
committerIgor Pashev <pashev.igor@gmail.com>2017-12-19 15:47:37 +0300
commit95c1b5b93eb0378f8efc9aaa5926c7b9d972037c (patch)
tree0e16ea965467119c75c4af6e422b717f1b2f17e9 /src
parent820ea577989fd40473db25f6166092336c483338 (diff)
downloadsproxy2-95c1b5b93eb0378f8efc9aaa5926c7b9d972037c.tar.gz
Clean imports
Drop `containers`.
Diffstat (limited to 'src')
-rw-r--r--src/Sproxy/Application.hs32
-rw-r--r--src/Sproxy/Server.hs2
2 files changed, 16 insertions, 18 deletions
diff --git a/src/Sproxy/Application.hs b/src/Sproxy/Application.hs
index 3311f05..c05844b 100644
--- a/src/Sproxy/Application.hs
+++ b/src/Sproxy/Application.hs
@@ -13,14 +13,12 @@ import Control.Exception
(Exception, Handler(..), SomeException, catches, displayException)
import qualified Data.Aeson as JSON
import Data.ByteString (ByteString)
-import Data.ByteString as BS (break, intercalate)
+import qualified Data.ByteString as BS
import Data.ByteString.Char8 (pack, unpack)
import Data.ByteString.Lazy (fromStrict)
import Data.Conduit (Flush(Chunk), mapOutput)
-import Data.HashMap.Strict as HM (HashMap, foldrWithKey, lookup)
+import qualified Data.HashMap.Strict as HM
import Data.List (find, partition)
-import Data.Map as Map
- (delete, fromListWith, insert, insertWith, toList)
import Data.Maybe (fromJust, fromMaybe)
import Data.Monoid ((<>))
import Data.Text (Text)
@@ -83,7 +81,7 @@ redirect p req resp =
sproxy ::
ByteString
-> Database
- -> HashMap Text OAuth2Client
+ -> HM.HashMap Text OAuth2Client
-> [(Pattern, BackendConf, BE.Manager)]
-> W.Application
sproxy key db oa2 backends =
@@ -230,20 +228,20 @@ authorize db (authCookie, otherCookies) req = do
return . Just $
req
{ W.requestHeaders =
- toList $
- insert "From" emailUtf8 $
- insert "X-Groups" (BS.intercalate "," $ encodeUtf8 <$> grps) $
- insert "X-Given-Name" givenUtf8 $
- insert "X-Family-Name" familyUtf8 $
- insert "X-Forwarded-Proto" "https" $
- insertWith (flip combine) "X-Forwarded-For" ip $
+ HM.toList $
+ HM.insert "From" emailUtf8 $
+ HM.insert "X-Groups" (BS.intercalate "," $ encodeUtf8 <$> grps) $
+ HM.insert "X-Given-Name" givenUtf8 $
+ HM.insert "X-Family-Name" familyUtf8 $
+ HM.insert "X-Forwarded-Proto" "https" $
+ HM.insertWith (flip combine) "X-Forwarded-For" ip $
setCookies otherCookies $
- fromListWith combine $ W.requestHeaders req
+ HM.fromListWith combine $ W.requestHeaders req
}
where
combine a b = a <> "," <> b
- setCookies [] = delete hCookie
- setCookies cs = insert hCookie (toByteString . renderCookies $ cs)
+ setCookies [] = HM.delete hCookie
+ setCookies cs = HM.insert hCookie (toByteString . renderCookies $ cs)
checkAccess :: Database -> AuthCookie -> W.Application
checkAccess db authCookie req resp = do
@@ -321,7 +319,7 @@ modifyResponseHeaders = filter (\(n, _) -> n `notElem` ban)
]
authenticationRequired ::
- ByteString -> HashMap Text OAuth2Client -> W.Application
+ ByteString -> HM.HashMap Text OAuth2Client -> W.Application
authenticationRequired key oa2 req resp = do
Log.info $ "511 Unauthenticated: " ++ showReq req
resp $
@@ -342,7 +340,7 @@ authenticationRequired key oa2 req resp = do
let u = oauth2AuthorizeURL oa2c state (redirectURL req provider)
d = pack $ oauth2Description oa2c
in [qc|{html}<p><a href="{u}">Authenticate with {d}</a></p>|]
- authHtml = foldrWithKey authLink "" oa2
+ authHtml = HM.foldrWithKey authLink "" oa2
page =
fromStrict
[qc|
diff --git a/src/Sproxy/Server.hs b/src/Sproxy/Server.hs
index 2477364..809d242 100644
--- a/src/Sproxy/Server.hs
+++ b/src/Sproxy/Server.hs
@@ -6,7 +6,7 @@ import Control.Concurrent (forkIO)
import Control.Exception (bracketOnError)
import Control.Monad (void, when)
import Data.ByteString.Char8 (pack)
-import Data.HashMap.Strict as HM (fromList, lookup, toList)
+import qualified Data.HashMap.Strict as HM
import Data.Maybe (fromMaybe)
import Data.Text (Text)
import Data.Word (Word16)