Servant.Server.Internal.BasicAuth

servant-server-0.20.2: A family of combinators for defining webservices APIs and serving them

Safe Haskell | None
Language | Haskell2010

Servant.Server.Internal.BasicAuth

Contents

- Basic Auth

Synopsis

- data BasicAuthResult usr
  - = Unauthorized
  - | BadPassword
  - | NoSuchUser
  - | Authorized usr
- newtype BasicAuthCheck usr = BasicAuthCheck {
  - unBasicAuthCheck :: BasicAuthData -> IO (BasicAuthResult usr)
  }
- mkBAChallengerHdr :: ByteString -> Header
- decodeBAHdr :: Request -> Maybe BasicAuthData
- runBasicAuth :: Request -> ByteString -> BasicAuthCheck usr -> DelayedIO usr

# Basic Auth

data BasicAuthResult usr #

servant-server's current implementation of basic authentication is not immune to certain kinds of timing attacks. Decoding payloads does not take a fixed amount of time.

The result of authentication/authorization

Constructors

Unauthorized |
BadPassword |
NoSuchUser |
Authorized usr |

#### Instances

Instances details

Functor BasicAuthResult # |
Instance details Defined in Servant.Server.Internal.BasicAuth Methods fmap :: (a -> b) -> BasicAuthResult a -> BasicAuthResult b # (<$) :: a -> BasicAuthResult b -> BasicAuthResult a #
Generic (BasicAuthResult usr) # |
Instance details Defined in Servant.Server.Internal.BasicAuth Associated Types
type Rep (BasicAuthResult usr) |
Instance details Defined in Servant.Server.Internal.BasicAuth type Rep (BasicAuthResult usr) = D1 ('MetaData "BasicAuthResult" "Servant.Server.Internal.BasicAuth" "servant-server-0.20.2-Knbwwylwin94JEnqxQX42x" 'False) ((C1 ('MetaCons "Unauthorized" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BadPassword" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NoSuchUser" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Authorized" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 usr))))
Methods from :: BasicAuthResult usr -> Rep (BasicAuthResult usr) x # to :: Rep (BasicAuthResult usr) x -> BasicAuthResult usr #
Read usr => Read (BasicAuthResult usr) # |
Instance details Defined in Servant.Server.Internal.BasicAuth Methods readsPrec :: Int -> ReadS (BasicAuthResult usr) # readList :: ReadS [BasicAuthResult usr] # readPrec :: ReadPrec (BasicAuthResult usr) # readListPrec :: ReadPrec [BasicAuthResult usr] #
Show usr => Show (BasicAuthResult usr) # |
Instance details Defined in Servant.Server.Internal.BasicAuth Methods showsPrec :: Int -> BasicAuthResult usr -> ShowS # show :: BasicAuthResult usr -> String # showList :: [BasicAuthResult usr] -> ShowS #
Eq usr => Eq (BasicAuthResult usr) # |
Instance details Defined in Servant.Server.Internal.BasicAuth Methods (==) :: BasicAuthResult usr -> BasicAuthResult usr -> Bool # (/=) :: BasicAuthResult usr -> BasicAuthResult usr -> Bool #
type Rep (BasicAuthResult usr) # |
Instance details Defined in Servant.Server.Internal.BasicAuth type Rep (BasicAuthResult usr) = D1 ('MetaData "BasicAuthResult" "Servant.Server.Internal.BasicAuth" "servant-server-0.20.2-Knbwwylwin94JEnqxQX42x" 'False) ((C1 ('MetaCons "Unauthorized" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BadPassword" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NoSuchUser" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Authorized" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 usr))))

newtype BasicAuthCheck usr #

Datatype wrapping a function used to check authentication.

Constructors

BasicAuthCheck |
Fields unBasicAuthCheck :: BasicAuthData -> IO (BasicAuthResult usr)

#### Instances

Instances details

Functor BasicAuthCheck # |
Instance details Defined in Servant.Server.Internal.BasicAuth Methods fmap :: (a -> b) -> BasicAuthCheck a -> BasicAuthCheck b # (<$) :: a -> BasicAuthCheck b -> BasicAuthCheck a #
Generic (BasicAuthCheck usr) # |
Instance details Defined in Servant.Server.Internal.BasicAuth Associated Types
type Rep (BasicAuthCheck usr) |
Instance details Defined in Servant.Server.Internal.BasicAuth type Rep (BasicAuthCheck usr) = D1 ('MetaData "BasicAuthCheck" "Servant.Server.Internal.BasicAuth" "servant-server-0.20.2-Knbwwylwin94JEnqxQX42x" 'True) (C1 ('MetaCons "BasicAuthCheck" 'PrefixI 'True) (S1 ('MetaSel ('Just "unBasicAuthCheck") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (BasicAuthData -> IO (BasicAuthResult usr)))))
Methods from :: BasicAuthCheck usr -> Rep (BasicAuthCheck usr) x # to :: Rep (BasicAuthCheck usr) x -> BasicAuthCheck usr #
type Rep (BasicAuthCheck usr) # |
Instance details Defined in Servant.Server.Internal.BasicAuth type Rep (BasicAuthCheck usr) = D1 ('MetaData "BasicAuthCheck" "Servant.Server.Internal.BasicAuth" "servant-server-0.20.2-Knbwwylwin94JEnqxQX42x" 'True) (C1 ('MetaCons "BasicAuthCheck" 'PrefixI 'True) (S1 ('MetaSel ('Just "unBasicAuthCheck") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (BasicAuthData -> IO (BasicAuthResult usr)))))

mkBAChallengerHdr :: ByteString -> Header #

Internal method to make a basic-auth challenge

decodeBAHdr :: Request -> Maybe BasicAuthData #

Find and decode an `Authorization` header from the request as Basic Auth

runBasicAuth :: Request -> ByteString -> BasicAuthCheck usr -> DelayedIO usr #

Run and check basic authentication, returning the appropriate http error per the spec.