Copyright | (c) Raghu Kaippully 2020 |
---|---|
License | MPL-2.0 |
Maintainer | rkaippully@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
Basic authentication support.
Synopsis
- data BasicAuth
- newtype Realm = Realm ByteString
- newtype Username = Username ByteString
- newtype Password = Password ByteString
- data Credentials = Credentials {}
- data BasicAuthError
- basicAuth :: forall m req a. MonadRouter m => Realm -> (Credentials -> m Bool) -> RequestMiddleware' m req (BasicAuth ': req) a
Documentation
Trait for HTTP basic authentication: https://tools.ietf.org/html/rfc7617
The protection space for basic authentication
Username for basic authentication. Valid usernames cannot contain ':' characters.
Password for basic authentication.
data Credentials Source #
Basic authentication credentials retrieved from an HTTP request
Instances
Eq Credentials Source # | |
Defined in WebGear.Middlewares.Auth.Basic (==) :: Credentials -> Credentials -> Bool # (/=) :: Credentials -> Credentials -> Bool # | |
Ord Credentials Source # | |
Defined in WebGear.Middlewares.Auth.Basic compare :: Credentials -> Credentials -> Ordering # (<) :: Credentials -> Credentials -> Bool # (<=) :: Credentials -> Credentials -> Bool # (>) :: Credentials -> Credentials -> Bool # (>=) :: Credentials -> Credentials -> Bool # max :: Credentials -> Credentials -> Credentials # min :: Credentials -> Credentials -> Credentials # | |
Read Credentials Source # | |
Defined in WebGear.Middlewares.Auth.Basic readsPrec :: Int -> ReadS Credentials # readList :: ReadS [Credentials] # readPrec :: ReadPrec Credentials # readListPrec :: ReadPrec [Credentials] # | |
Show Credentials Source # | |
Defined in WebGear.Middlewares.Auth.Basic showsPrec :: Int -> Credentials -> ShowS # show :: Credentials -> String # showList :: [Credentials] -> ShowS # |
data BasicAuthError Source #
Error extracting credentials from an HTTP request
AuthHeaderError | Authorization header is missing or badly formatted |
AuthSchemeMismatch | Authorization scheme is not Basic |
Instances
Eq BasicAuthError Source # | |
Defined in WebGear.Middlewares.Auth.Basic (==) :: BasicAuthError -> BasicAuthError -> Bool # (/=) :: BasicAuthError -> BasicAuthError -> Bool # | |
Ord BasicAuthError Source # | |
Defined in WebGear.Middlewares.Auth.Basic compare :: BasicAuthError -> BasicAuthError -> Ordering # (<) :: BasicAuthError -> BasicAuthError -> Bool # (<=) :: BasicAuthError -> BasicAuthError -> Bool # (>) :: BasicAuthError -> BasicAuthError -> Bool # (>=) :: BasicAuthError -> BasicAuthError -> Bool # max :: BasicAuthError -> BasicAuthError -> BasicAuthError # min :: BasicAuthError -> BasicAuthError -> BasicAuthError # | |
Read BasicAuthError Source # | |
Defined in WebGear.Middlewares.Auth.Basic readsPrec :: Int -> ReadS BasicAuthError # readList :: ReadS [BasicAuthError] # | |
Show BasicAuthError Source # | |
Defined in WebGear.Middlewares.Auth.Basic showsPrec :: Int -> BasicAuthError -> ShowS # show :: BasicAuthError -> String # showList :: [BasicAuthError] -> ShowS # |
basicAuth :: forall m req a. MonadRouter m => Realm -> (Credentials -> m Bool) -> RequestMiddleware' m req (BasicAuth ': req) a Source #
Middleware to add basic authentication protection for a handler.
Example usage:
basicAuth "realm" isValidCredentials handler
This middleware returns a 401 response if no credentials are found in the request. It returns a 403 response if credentials are present but isValidCredentials returns False.