http-client-auth-0.1.0.0: HTTP authorization (both basic and digest) done right

Safe HaskellNone

Network.HTTP.Client.Auth

Contents

Synopsis

Documentation

requestWithAuthSource

Arguments

:: String

login

-> String

password

-> (Request (ResourceT IO) -> IO (Response body))

function like withManager . httpLbs, to actually send a request

-> Request (ResourceT IO)

request to send (without authorization)

-> MaybeT IO (Response body) 

This is the main function. It sends a request, gets the response, and, if this response requires authorization, it sends the same request again, now including authorization data (user-supplied login and password).

High-level functions

data Challenge Source

This is an abstract type representing the challenge sent by the server.

Instances

realm :: Challenge -> Maybe StringSource

Realm is the only thing users are supposed to know about the challenge.

getChallenge :: Response body -> Maybe ChallengeSource

This function parses the response headers to get the challenge. It failes if there is some challenge, but it can't be parsed. If there is no challenge at all, function doesn't fail.

makeRequestHeaderSource

Arguments

:: Monad m 
=> String

login

-> String

password

-> String

string to use as cnonce, not very important yet

-> Request m

first request, already sent to the server

-> Challenge

challenge generated by server in responce to that request

-> MaybeT m String 

This function creates a string that should be sent in the Authorization header.

Low-level functions

extractAuthHeader :: Response body -> Maybe StringSource

This function extracts a WWW-Authenticate header from the response.

parseChallenge :: String -> Maybe ChallengeSource

This function parses the WWW-Authenticate header line to get a challenge. If it fails, it's probably because the header is malformed

Utils

makeRequestUri :: Request m -> StringSource

This function extracts URI part from the request. It wouldn't include the host name.

makeRequestBodyHash :: Monad m => Request m -> m StringSource

This function makes an MD5 hash of the request body