yesod-auth-basic 0.1.0.1 → 0.1.0.2
raw patch · 2 files changed
+19/−12 lines, 2 filesdep +iproutedep ~hlint
Dependencies added: iproute
Dependency ranges changed: hlint
Files
- Yesod/Auth/Http/Basic.hs +9/−7
- yesod-auth-basic.cabal +10/−5
Yesod/Auth/Http/Basic.hs view
@@ -1,11 +1,12 @@ -- | A Yesod middleware for <<http://tools.ietf.org/html/rfc1945#section-11.1 HTTP Basic Authentication>> ----- This middleware performs a single authentication lookup--- per request and uses the Yesod request-local caching--- mechanisms to store valid auth credentials found in the--- Authorization header. --+-- Performs a single authentication lookup per request and uses the+-- <<https://github.com/yesodweb/yesod/blob/7f775e1ddebaeb4b8509b512b6d4b539d96258bd/yesod-core/Yesod/Core/TypeCache.hs#L21+-- Yesod request-local caching>> mechanisms to store valid auth+-- credentials found in the Authorization header. --+-- -- The recommended way to use this module is to override the -- @maybeAuthId@ to @defaultMaybeBasicAuthId@ and supply a -- lookup function.@@ -14,7 +15,7 @@ -- instance YesodAuth App where -- type AuthId App = Text -- getAuthId = return . Just . credsIdent--- maybeAuthId = defaultMaybeBasicAuthId checkCreds+-- maybeAuthId = defaultMaybeBasicAuthId checkCreds defaultAuthSettings -- where -- checkCreds = \k s -> return $ (k == "user") -- && (s == "secret")@@ -60,7 +61,7 @@ -- * Drop in replace for maybeAuthId. defaultMaybeBasicAuthId - -- The AuthSettings currently do nothing+ -- * The AuthSettings currently do nothing -- useful but are supplied to the defaultMaybeAUthId -- anyways , AuthSettings@@ -77,6 +78,7 @@ import qualified Data.Text.Encoding as T import Data.Typeable import Data.Word8 (isSpace, toLower, _colon)+import Prelude import Network.Wai import Yesod hiding (Header) @@ -153,7 +155,7 @@ authorization = BS.break isSpace <$> lookup "Authorization" (requestHeaders req) authorizeCredentials encoded =- let (username, password') = BS.breakByte _colon $ decodeLenient encoded+ let (username, password') = BS.break (== _colon) $ decodeLenient encoded in case BS.uncons password' of Nothing -> return Nothing Just (_,password) -> do
yesod-auth-basic.cabal view
@@ -1,6 +1,6 @@ name: yesod-auth-basic-version: 0.1.0.1+version: 0.1.0.2 license: BSD3 license-file: LICENSE author: Christopher Reichert@@ -27,7 +27,7 @@ exposed-modules: Yesod.Auth.Http.Basic ghc-options: -Wall default-language: Haskell2010- build-depends: base == 4.*+ build-depends: base == 4.* , base64-bytestring , bytestring , exceptions@@ -36,13 +36,17 @@ , wai , word8 + if impl(ghc < 7.6)+ build-depends:+ iproute < 1.4 + test-suite spec type: exitcode-stdio-1.0 main-is: Spec.hs hs-source-dirs: test/ other-modules: YesodAuthHttpBasicSpec- ghc-options: -Wall -Werror -threaded+ ghc-options: -Wall -threaded default-language: Haskell2010 build-depends: base == 4.* , yesod@@ -54,8 +58,9 @@ test-suite hlint main-is: test/HLint.hs- ghc-options: -Wall -Werror -threaded+ ghc-options: -Wall -threaded type: exitcode-stdio-1.0 default-language: Haskell2010 build-depends: base- , hlint == 1.8.*+ , hlint +