oauthenticated-0.1.0: Simple OAuth for http-client

Portabilitynon-portable
Stabilityexperimental
Maintainerme@jspha.com
Safe HaskellNone

Network.OAuth.ThreeLegged

Contents

Description

The "Three-legged OAuth" protocol implementing RFC 5849's Redirection-Based Authorization.

Synopsis

Configuration types

data ThreeLegged Source

Data parameterizing the "Three-legged OAuth" redirection-based authorization protocol. These parameters cover the protocol as described in the community editions OAuth Core 1.0 and OAuth Core 1.0a as well as RFC 5849.

Constructors

ThreeLegged 

Fields

temporaryTokenRequest :: Request

Base Request for the "endpoint used by the client to obtain a set of Temporary Credentials" in the form of a Temporary Token. This request is automatically instantiated and performed during the first leg of the ThreeLegged authorization protocol.

resourceOwnerAuthorization :: Request

Base Request for the "endpoint to which the resource owner is redirected to grant authorization". This request must be performed by the user granting token authorization to the client. Transmitting the parameters of this request to the user is out of scope of oauthenticated, but functions are provided to make it easier.

permanentTokenRequest :: Request

Base Request for the "endpoint used by the client to request a set of token credentials using the set of Temporary Credentials". This request is also instantiated and performed by oauthenticated in order to produce a Permanent Token.

callback :: Callback

The Callback parameter configures how the user is intended to communicate the Verifier back to the client.

parseThreeLegged :: String -> String -> String -> Callback -> Maybe ThreeLeggedSource

Convenience method for creating a ThreeLegged configuration from a trio of URLs and a Callback. Returns Nothing if one of the callback URLs could not be parsed correctly.

data Callback Source

When performing the second leg of the three-leg token request workflow, the user must pass the oauth_verifier code back to the client. In order to ensure that this protocol is secure, OAuth demands that the client associates this "callback method" with the temporary credentials generated for the workflow. This Callback method may be a URL where the parameters are returned to or the string "oob" which indicates that the user is responsible for returning the oauth_verifier to the client OutOfBand.

Constructors

OutOfBand 
Callback Request 

Instances

Show Callback 
Typeable Callback 
QueryValueLike Callback

Prints out in Epoch time format, a printed integer

type Verifier = ByteStringSource

A Verifier is produced when a user authorizes a set of Temporary Creds. Using the Verifier allows the client to request Permanent Creds.

Actions

requestTemporaryToken :: CPRG gen => Cred Client -> Server -> ThreeLegged -> Manager -> gen -> IO (Response (Either ByteString (Token Temporary)), gen)Source

Returns the raw result if the Response could not be parsed as a valid Token. Importantly, in RFC 5849 compliant modes this requires that the token response includes callback_confirmed=true. See also requestTemporaryTokenRaw.

Throws HttpExceptions.

buildAuthorizationUrl :: Cred Temporary -> ThreeLegged -> URISource

Produce a URI which the user should be directed to in order to authorize a set of Temporary Creds.

requestPermanentToken :: CPRG gen => Cred Temporary -> Server -> Verifier -> ThreeLegged -> Manager -> gen -> IO (Response (Either ByteString (Token Permanent)), gen)Source

Returns Nothing if the response could not be decoded as a Token. See also requestPermanentTokenRaw.

Throws HttpExceptions.

Raw forms

requestTemporaryTokenRaw :: CPRG gen => Cred Client -> Server -> ThreeLegged -> Manager -> gen -> IO (Response ByteString, gen)Source

Request a Temporary Token based on the parameters of a ThreeLegged protocol. This returns the raw response which should be encoded as www-form-urlencoded.

Throws HttpExceptions.

requestPermanentTokenRaw :: CPRG gen => Cred Temporary -> Server -> Verifier -> ThreeLegged -> Manager -> gen -> IO (Response ByteString, gen)Source

Request a 'Permanent Token based on the parameters of a ThreeLegged protocol. This returns the raw response which should be encoded as www-form-urlencoded.

Throws HttpExceptions.

Example system

requestTokenProtocol :: Cred Client -> Server -> ThreeLegged -> (URI -> IO Verifier) -> IO (Maybe (Cred Permanent))Source

Performs an interactive token request provided credentials, configuration, and a way to convert a user authorization URI into a Verifier out of band. Does not use any kind of TLS protection---it will throw a TlsNotSupported exception if TLS is required.

Throws HttpExceptions.