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

Safe HaskellNone
LanguageHaskell98

Network.HTTP.Client.Auth

Contents

Synopsis

Documentation

requestWithAuth Source

Arguments

:: String

login

-> String

password

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

function like withManager . httpLbs, to actually send a request

-> Request

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 String Source

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

getChallenge :: Response body -> Maybe Challenge Source

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.

makeRequestHeader Source

Arguments

:: String

login

-> String

password

-> String

string to use as cnonce, not very important yet

-> Request

first request, already sent to the server

-> Challenge

challenge generated by server in responce to that request

-> MaybeT (ResourceT IO) String 

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

Low-level functions

extractAuthHeader :: Response body -> Maybe String Source

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

parseChallenge :: String -> Maybe Challenge Source

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 -> String Source

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

makeRequestBodyHash :: Request -> IO String Source

This function makes an MD5 hash of the request body