Copyright | (c) Joseph Abrahamson 2013 |
---|---|
License | MIT |
Maintainer | me@jspha.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
OAuth Parameters
OAuth 1.0 operates by creating a set of "oauth parameters" here
called Oa
which augment a request with OAuth specific
metadata. They may be used to augment the request by one of several
ParameterMethods
.
- data ParameterMethod
- data SignatureMethod
- data Version
- data Callback
- newtype Timestamp = Timestamp UTCTime
- timestampFromSeconds :: Integer -> Timestamp
- data Server = Server {}
- defaultServer :: Server
- type Verifier = ByteString
- data Workflow
- data OaPin = OaPin {}
- emptyPin :: OaPin
- freshPin :: CPRG gen => gen -> IO (OaPin, gen)
- emptyOa :: Cred ty -> Oa ty
- freshOa :: CPRG gen => Cred ty -> gen -> IO (Oa ty, gen)
- data Oa ty = Oa {}
Documentation
data ParameterMethod Source
The OAuth spec suggest that the OAuth parameter be passed via the
Authorization
header, but allows for other methods of
transmission (see section "3.5. Parameter Transmission") so we
select the 'Server'\'s preferred method with this type.
AuthorizationHeader | Place the |
RequestEntityBody | Augment the |
QueryString | Augment the |
data SignatureMethod Source
OAuth has progressed through several versions since its inception. In particular, there are two community editions "OAuth Core 1.0" (2007) and "OAuth Core 1.0a" (2009) along with the IETF Official version RFC 5849 (2010) which is confusingly named "OAuth 1.0".
/Servers which only implement the obsoleted community edition "OAuth Core 1.0" are susceptible to a session fixation attack./
If at all possible, choose the RFC 5849 version (the OAuth1
value) as
it is the modern standard. Some servers may only be compliant with an
earlier OAuth version---this should be tested against each server, in
particular the protocols defined in Network.OAuth.ThreeLegged.
OAuthCommunity1 | OAuth Core 1.0 Community Edition |
OAuthCommunity1a | OAuth Core 1.0 Community Edition, Revision A |
OAuth1 | RFC 5849 |
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
.
An Epoch time format timestamp.
timestampFromSeconds :: Integer -> Timestamp Source
Create a Timestamp
deterministically from a POSIX Epoch Time.
The Server
information contains details which parameterize how a
particular server wants to interpret OAuth requests.
defaultServer :: Server Source
The default Server
parameterization uses OAuth recommended parameters.
type Verifier = ByteString Source
Some special OAuth requests use extra oauth_*
parameters. For example,
when requesting a temporary credential, it's necessary that a
oauth_callback
parameter be specified. WorkflowParams
allows these extra
parameters to be specified.
Standard | No special OAuth parameters needed |
TemporaryTokenRequest Callback | |
PermanentTokenRequest ByteString | Includes the |
The OaPin
is a set of impure OAuth parameters which are generated for each
request in order to ensure uniqueness and temporality.
OaPin | |
|
An "empty" pin useful for testing. This OaPin
is referentially
transparent and thus has none of the necessary security features---it should
never be used in an actual transaction!
freshPin :: CPRG gen => gen -> IO (OaPin, gen) Source
Creates a new, unique, unpredictable OaPin
. This should be used quickly
as dependent on the OAuth server settings it may expire.