webgear-server-0.2.1: Composable, type-safe library to build HTTP API servers
Copyright(c) Raghu Kaippully 2020
LicenseMPL-2.0
Maintainerrkaippully@gmail.com
Safe HaskellNone
LanguageHaskell2010

WebGear.Middlewares.Auth.Basic

Description

Basic authentication support.

Synopsis

Documentation

newtype Realm Source #

The protection space for basic authentication

Constructors

Realm ByteString 

Instances

Instances details
Eq Realm Source # 
Instance details

Defined in WebGear.Middlewares.Auth.Basic

Methods

(==) :: Realm -> Realm -> Bool #

(/=) :: Realm -> Realm -> Bool #

Ord Realm Source # 
Instance details

Defined in WebGear.Middlewares.Auth.Basic

Methods

compare :: Realm -> Realm -> Ordering #

(<) :: Realm -> Realm -> Bool #

(<=) :: Realm -> Realm -> Bool #

(>) :: Realm -> Realm -> Bool #

(>=) :: Realm -> Realm -> Bool #

max :: Realm -> Realm -> Realm #

min :: Realm -> Realm -> Realm #

Read Realm Source # 
Instance details

Defined in WebGear.Middlewares.Auth.Basic

Show Realm Source # 
Instance details

Defined in WebGear.Middlewares.Auth.Basic

Methods

showsPrec :: Int -> Realm -> ShowS #

show :: Realm -> String #

showList :: [Realm] -> ShowS #

IsString Realm Source # 
Instance details

Defined in WebGear.Middlewares.Auth.Basic

Methods

fromString :: String -> Realm #

newtype Username Source #

Username for basic authentication. Valid usernames cannot contain ':' characters.

Constructors

Username ByteString 

newtype Password Source #

Password for basic authentication.

Constructors

Password ByteString 

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.