webgear-core-1.0.3: Composable, type-safe library to build HTTP APIs
Safe HaskellNone
LanguageHaskell2010

WebGear.Core.Trait.Auth.Common

Description

Common types and functions related to authorization.

Synopsis

Documentation

type AuthorizationHeader scheme = Header Optional Lenient "Authorization" (AuthToken scheme) Source #

Trait for "Authorization" header

getAuthorizationHeaderTrait :: forall scheme h ts. Get h (AuthorizationHeader scheme) Request => h (Linked ts Request) (Maybe (Either Text (AuthToken scheme))) Source #

Extract the "Authorization" header from a request by specifying an authentication scheme.

The header is split into the scheme and token parts and returned.

newtype Realm Source #

The protection space for authentication

Constructors

Realm ByteString 

Instances

Instances details
Eq Realm Source # 
Instance details

Defined in WebGear.Core.Trait.Auth.Common

Methods

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

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

Ord Realm Source # 
Instance details

Defined in WebGear.Core.Trait.Auth.Common

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.Core.Trait.Auth.Common

Show Realm Source # 
Instance details

Defined in WebGear.Core.Trait.Auth.Common

Methods

showsPrec :: Int -> Realm -> ShowS #

show :: Realm -> String #

showList :: [Realm] -> ShowS #

IsString Realm Source # 
Instance details

Defined in WebGear.Core.Trait.Auth.Common

Methods

fromString :: String -> Realm #

data AuthToken (scheme :: Symbol) Source #

The components of Authorization request header

Constructors

AuthToken 

Fields

Instances

Instances details
KnownSymbol scheme => FromHttpApiData (AuthToken scheme) Source # 
Instance details

Defined in WebGear.Core.Trait.Auth.Common

respondUnauthorized Source #

Arguments

:: (Handler h m, Sets h [Status, RequiredHeader "Content-Type" Text, RequiredHeader "WWW-Authenticate" Text, Body Text] Response) 
=> CI ByteString

The authentication scheme

-> Realm

The authentication realm

-> h a Response 

Create a "401 Unauthorized" response.

The response will have a plain text body and an appropriate "WWW-Authenticate" header.