hoauth2-2.14.3: Haskell OAuth2 authentication client

Safe Haskell | None
Language | Haskell2010

Network.OAuth.OAuth2

Contents

- Authorization Requset
- Token Request
- OAuth'ed http client utilities

Description

A lightweight oauth2 Haskell binding. See Readme for more details

Synopsis

- data OAuth2 = OAuth2 {
  - oauth2ClientId :: Text
  - oauth2ClientSecret :: Text
  - oauth2AuthorizeEndpoint :: URIRef Absolute
  - oauth2TokenEndpoint :: URIRef Absolute
  - oauth2RedirectUri :: URIRef Absolute
  }
- data ClientAuthenticationMethod
  - = ClientSecretBasic
  - | ClientSecretPost
  - | ClientAssertionJwt
- newtype RefreshToken = RefreshToken {
  - rtoken :: Text
  }
- data OAuth2Token = OAuth2Token {
  - accessToken :: AccessToken
  - refreshToken :: Maybe RefreshToken
  - expiresIn :: Maybe Int
  - tokenType :: Maybe Text
  - idToken :: Maybe IdToken
  - scope :: Maybe Text
  - rawResponse :: Object
  }
- type PostBody = [(ByteString, ByteString)]
- uriToRequest :: MonadThrow m => URI -> m Request
- newtype ExchangeToken = ExchangeToken {
  - extoken :: Text
  }
- newtype AccessToken = AccessToken {
  - atoken :: Text
  }
- newtype IdToken = IdToken {
  - idtoken :: Text
  }
- type QueryParams = [(ByteString, ByteString)]
- defaultRequestHeaders :: [(HeaderName, ByteString)]
- appendQueryParams :: [(ByteString, ByteString)] -> URIRef a -> URIRef a
- hostLens :: Lens' Request ByteString
- portLens :: Lens' Request Int
- requestToUri :: Request -> URI
- authorizationUrl :: OAuth2 -> URI
- authorizationUrlWithParams :: QueryParams -> OAuth2 -> URI
- module Network.OAuth.OAuth2.TokenRequest
- module Network.OAuth.OAuth2.HttpClient

# Documentation

data OAuth2 Source #

Query Parameter Representation

Constructors

OAuth2 |

Fields

- oauth2ClientId :: Text
- oauth2ClientSecret :: Text
- oauth2AuthorizeEndpoint :: URIRef Absolute
- oauth2TokenEndpoint :: URIRef Absolute
- oauth2RedirectUri :: URIRef Absolute

#### Instances

Instances details

Default OAuth2 Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods def :: OAuth2 Source #
Show OAuth2 Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods showsPrec :: Int -> OAuth2 -> ShowS Source # show :: OAuth2 -> String Source # showList :: [OAuth2] -> ShowS Source #
Eq OAuth2 Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods (==) :: OAuth2 -> OAuth2 -> Bool Source # (/=) :: OAuth2 -> OAuth2 -> Bool Source #

data ClientAuthenticationMethod Source #

How would the Client (RP) authenticate itself?

The client MUST NOT use more than one authentication method in each request. Means use Authorization header or Post body.

See more details

https://www.rfc-editor.org/rfc/rfc6749#section-2.3 https://oauth.net/private-key-jwt/ https://www.rfc-editor.org/rfc/rfc7523.html

Constructors

ClientSecretBasic |
ClientSecretPost |
ClientAssertionJwt |

#### Instances

Instances details

Show ClientAuthenticationMethod Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods showsPrec :: Int -> ClientAuthenticationMethod -> ShowS Source # show :: ClientAuthenticationMethod -> String Source # showList :: [ClientAuthenticationMethod] -> ShowS Source #
Eq ClientAuthenticationMethod Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods (==) :: ClientAuthenticationMethod -> ClientAuthenticationMethod -> Bool Source # (/=) :: ClientAuthenticationMethod -> ClientAuthenticationMethod -> Bool Source #

newtype RefreshToken Source #

Constructors

RefreshToken |

Fields

- rtoken :: Text

#### Instances

Instances details

FromJSON RefreshToken Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods parseJSON :: Value -> Parser RefreshToken Source # parseJSONList :: Value -> Parser [RefreshToken] Source # omittedField :: Maybe RefreshToken Source #
ToJSON RefreshToken Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods toJSON :: RefreshToken -> Value Source # toEncoding :: RefreshToken -> Encoding Source # toJSONList :: [RefreshToken] -> Value Source # toEncodingList :: [RefreshToken] -> Encoding Source # omitField :: RefreshToken -> Bool Source #
Show RefreshToken Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods showsPrec :: Int -> RefreshToken -> ShowS Source # show :: RefreshToken -> String Source # showList :: [RefreshToken] -> ShowS Source #
Eq RefreshToken Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods (==) :: RefreshToken -> RefreshToken -> Bool Source # (/=) :: RefreshToken -> RefreshToken -> Bool Source #
ToQueryParam RefreshToken Source # |
Instance details Defined in Network.OAuth2.Experiment.Types Methods toQueryParam :: RefreshToken -> Map Text Text Source #

data OAuth2Token Source #

https://www.rfc-editor.org/rfc/rfc6749#section-4.1.4

Constructors

OAuth2Token |

Fields

- accessToken :: AccessToken
- refreshToken :: Maybe RefreshToken

  Exists when `offline_access` scope is in the Authorization Request and the provider supports Refresh Access Token.

- expiresIn :: Maybe Int
- tokenType :: Maybe Text

  See https://www.rfc-editor.org/rfc/rfc6749#section-5.1. It's required per spec. But OAuth2 provider implementation are vary. Maybe will remove `Maybe` in future release.

- idToken :: Maybe IdToken

  Exists when `openid` scope is in the Authorization Request and the provider supports OpenID protocol.

- scope :: Maybe Text
- rawResponse :: Object

#### Instances

Instances details

FromJSON OAuth2Token Source # | Parse JSON data into `OAuth2Token`
Instance details Defined in Network.OAuth.OAuth2.Internal Methods parseJSON :: Value -> Parser OAuth2Token Source # parseJSONList :: Value -> Parser [OAuth2Token] Source # omittedField :: Maybe OAuth2Token Source #
ToJSON OAuth2Token Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods toJSON :: OAuth2Token -> Value Source # toEncoding :: OAuth2Token -> Encoding Source # toJSONList :: [OAuth2Token] -> Value Source # toEncodingList :: [OAuth2Token] -> Encoding Source # omitField :: OAuth2Token -> Bool Source #
Binary OAuth2Token Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods put :: OAuth2Token -> Put Source # get :: Get OAuth2Token Source # putList :: [OAuth2Token] -> Put Source #
Show OAuth2Token Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods showsPrec :: Int -> OAuth2Token -> ShowS Source # show :: OAuth2Token -> String Source # showList :: [OAuth2Token] -> ShowS Source #
Eq OAuth2Token Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods (==) :: OAuth2Token -> OAuth2Token -> Bool Source # (/=) :: OAuth2Token -> OAuth2Token -> Bool Source #

type PostBody = [(ByteString, ByteString)] Source #

Type synonym of post body content

uriToRequest :: MonadThrow m => URI -> m Request Source #

newtype ExchangeToken Source #

Authorization Code

Constructors

ExchangeToken |

Fields

- extoken :: Text

#### Instances

Instances details

FromJSON ExchangeToken Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods parseJSON :: Value -> Parser ExchangeToken Source # parseJSONList :: Value -> Parser [ExchangeToken] Source # omittedField :: Maybe ExchangeToken Source #
ToJSON ExchangeToken Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods toJSON :: ExchangeToken -> Value Source # toEncoding :: ExchangeToken -> Encoding Source # toJSONList :: [ExchangeToken] -> Value Source # toEncodingList :: [ExchangeToken] -> Encoding Source # omitField :: ExchangeToken -> Bool Source #
Show ExchangeToken Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods showsPrec :: Int -> ExchangeToken -> ShowS Source # show :: ExchangeToken -> String Source # showList :: [ExchangeToken] -> ShowS Source #
ToQueryParam ExchangeToken Source # |
Instance details Defined in Network.OAuth2.Experiment.Types Methods toQueryParam :: ExchangeToken -> Map Text Text Source #

newtype AccessToken Source #

Constructors

AccessToken |

Fields

- atoken :: Text

#### Instances

Instances details

FromJSON AccessToken Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods parseJSON :: Value -> Parser AccessToken Source # parseJSONList :: Value -> Parser [AccessToken] Source # omittedField :: Maybe AccessToken Source #
ToJSON AccessToken Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods toJSON :: AccessToken -> Value Source # toEncoding :: AccessToken -> Encoding Source # toJSONList :: [AccessToken] -> Value Source # toEncodingList :: [AccessToken] -> Encoding Source # omitField :: AccessToken -> Bool Source #
Show AccessToken Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods showsPrec :: Int -> AccessToken -> ShowS Source # show :: AccessToken -> String Source # showList :: [AccessToken] -> ShowS Source #
Eq AccessToken Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods (==) :: AccessToken -> AccessToken -> Bool Source # (/=) :: AccessToken -> AccessToken -> Bool Source #

newtype IdToken Source #

Constructors

IdToken |

Fields

- idtoken :: Text

#### Instances

Instances details

FromJSON IdToken Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods parseJSON :: Value -> Parser IdToken Source # parseJSONList :: Value -> Parser [IdToken] Source # omittedField :: Maybe IdToken Source #
ToJSON IdToken Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods toJSON :: IdToken -> Value Source # toEncoding :: IdToken -> Encoding Source # toJSONList :: [IdToken] -> Value Source # toEncodingList :: [IdToken] -> Encoding Source # omitField :: IdToken -> Bool Source #
Show IdToken Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods showsPrec :: Int -> IdToken -> ShowS Source # show :: IdToken -> String Source # showList :: [IdToken] -> ShowS Source #
Eq IdToken Source # |
Instance details Defined in Network.OAuth.OAuth2.Internal Methods (==) :: IdToken -> IdToken -> Bool Source # (/=) :: IdToken -> IdToken -> Bool Source #

type QueryParams = [(ByteString, ByteString)] Source #

Type sysnonym of request query params

defaultRequestHeaders :: [(HeaderName, ByteString)] Source #

appendQueryParams :: [(ByteString, ByteString)] -> URIRef a -> URIRef a Source #

hostLens :: Lens' Request ByteString Source #

portLens :: Lens' Request Int Source #

requestToUri :: Request -> URI Source #

# Authorization Requset

authorizationUrl :: OAuth2 -> URI Source #

See `authorizationUrlWithParams`

authorizationUrlWithParams :: QueryParams -> OAuth2 -> URI Source #

Prepare the authorization URL. Redirect to this URL asking for user interactive authentication.

Since: 2.6.0

# Token Request

module Network.OAuth.OAuth2.TokenRequest

# OAuth'ed http client utilities

module Network.OAuth.OAuth2.HttpClient