Wt: Wt::Auth::FacebookService Class Reference

Wt 4.10.4

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Wt::Auth::FacebookService Class Reference

OAuth service for Facebook as third-party authenticator. More...

`#include <FacebookService.h>`

Inheritance diagram for Wt::Auth::FacebookService:
[legend]

## Public Member Functions
| FacebookService (const AuthService &baseAuthService)
| Constructor.
virtual std::string | name () const override
| Returns the provider name.
virtual WString | description () const override
| Returns the provider description.
virtual int | popupWidth () const override
| Returns the desired width for the popup window.
virtual int | popupHeight () const override
| Returns the desired height for the popup window.
virtual std::string | authenticationScope () const override
| Returns the scope needed for authentication.
virtual std::string | redirectEndpoint () const override
| Returns the redirection endpoint URL.
virtual std::string | redirectEndpointPath () const override
| Returns the deployment path of the redirection endpoint.
virtual std::string | authorizationEndpoint () const override
| Returns the authorization endpoint URL.
virtual std::string | tokenEndpoint () const override
| Returns the token endpoint URL.
virtual std::string | clientId () const override
| Returns the client ID.
virtual std::string | clientSecret () const override
| Returns the client secret.
virtual ClientSecretMethod | clientSecretMethod () const override
| Returns the method to transfer the client secret.
virtual Http::Method | tokenRequestMethod () const override
| Returns the HTTP method used for the token request.
virtual std::unique_ptr< OAuthProcess > | createProcess (const std::string &scope) const override
| Creates a new authorization process.
Public Member Functions inherited from Wt::Auth::OAuthService
| OAuthService (const AuthService &baseAuth)
| Constructor.
virtual | ~OAuthService ()
| Destructor.
const AuthService & | baseAuth () const
| Returns the basic authentication service.
void | setPopupEnabled (bool enable)
| Configure if a popup should be used for the login.
bool | popupEnabled () const
| Returns if a popup is used for the login.
virtual std::string | encodeState (const std::string &sessionId) const
| Derives a state value from the session ID.
virtual std::string | decodeState (const std::string &state) const
| Validates and decodes a state parameter.
void | configureRedirectEndpoint () const
| Configures the static resource implementing the redirect endpoint.

## Static Public Member Functions
static bool | configured ()
| Checks whether a FacebookAuth service is properly configured.

## Detailed Description

OAuth service for Facebook as third-party authenticator.

The configuration of the service is done using properties, whose values need to match the values configured at Facebook.

- `facebook-oauth2-redirect-endpoint`: the URL of the local redirect endpoint, to which the Facebook OAuth service redirects the user after authentication. See also redirectEndpoint()
- `facebook-oauth2-redirect-endpoint-path`: optionally, the deployment path that corresponds to the redirect endpoint. See also redirectEndpointPath()
- `facebook-oauth2-app-id`: The application ID
- `facebook-oauth2-app-secret`: The application secret.

For example:

<properties>
<property name="facebook-oauth2-redirect-endpoint">
http://localhost:8080/oauth2callback
</property>
<property name="facebook-oauth2-app-id">
1234567890123456
</property>
<property name="facebook-oauth2-app-secret">
a3cf1630b1ae415c7260d849efdf444d
</property>
</properties>
Wt::Auth::FacebookService::name
virtual std::string name() const override
Returns the provider name.

Like all service classes, this class holds only configuration state. Thus, once configured, it can be safely shared between multiple sessions since its state (the configuration) is read-only. A "const FacebookService" object is thus thread-safe.

See also
  http://developers.facebook.com/docs/authentication/

Note
  For FastCGI, see also additional configuration in OAuthService

## Member Function Documentation

## ◆ authenticationScope()

virtual std::string Wt::Auth::FacebookService::authenticationScope | ( |  | ) | const
| overridevirtual

Returns the scope needed for authentication.

This returns the scope that is needed (and sufficient) for obtaining identity information, and thus to authenticate the user.

See also
  OAuthProcess::getIdentity(), OAuthProcess::startAuthenticate()

Implements Wt::Auth::OAuthService.

## ◆ authorizationEndpoint()

virtual std::string Wt::Auth::FacebookService::authorizationEndpoint | ( |  | ) | const
| overridevirtual

Returns the authorization endpoint URL.

This is a remote URL which hosts the OAuth authorization user interface. This URL is loaded in the popup window at the start of an authorization process.

Implements Wt::Auth::OAuthService.

## ◆ clientId()

virtual std::string Wt::Auth::FacebookService::clientId | ( |  | ) | const
| overridevirtual

Returns the client ID.

This is the identification for this web application with the OAuth authorization server.

Implements Wt::Auth::OAuthService.

## ◆ clientSecret()

virtual std::string Wt::Auth::FacebookService::clientSecret | ( |  | ) | const
| overridevirtual

Returns the client secret.

This is the secret credentials for this web application with the OAuth authorization server.

Implements Wt::Auth::OAuthService.

## ◆ clientSecretMethod()

virtual ClientSecretMethod Wt::Auth::FacebookService::clientSecretMethod | ( |  | ) | const
| overridevirtual

Returns the method to transfer the client secret.

Some implementations (like Facebook) encode the secret in the GET request parameters, while this is explicitly not allowed in the OAuth 2.0 specification.

The default implementation returns HttpAuthorizationBasic (the recommended method).

Implements Wt::Auth::OAuthService.

## ◆ configured()

static bool Wt::Auth::FacebookService::configured | ( |  | ) |
| static

Checks whether a FacebookAuth service is properly configured.

This returns `true` if a value is found for the three configuration properties.

## ◆ createProcess()

virtual std::unique_ptr< OAuthProcess > Wt::Auth::FacebookService::createProcess | ( | const std::string & | scope | ) | const
| overridevirtual

Creates a new authorization process.

This creates a new authorization process for the indicated scope. Valid names for the scope are service provider dependent.

See also
  authenticationScope()

Implements Wt::Auth::OAuthService.

## ◆ description()

virtual WString Wt::Auth::FacebookService::description | ( |  | ) | const
| overridevirtual

Returns the provider description.

This returns a description useful for e.g. tool tips on a login icon.

See also
  name()

Implements Wt::Auth::OAuthService.

## ◆ name()

virtual std::string Wt::Auth::FacebookService::name | ( |  | ) | const
| overridevirtual

Returns the provider name.

This is a short identifier.

See also
  description()

Implements Wt::Auth::OAuthService.

## ◆ popupHeight()

virtual int Wt::Auth::FacebookService::popupHeight | ( |  | ) | const
| overridevirtual

Returns the desired height for the popup window.

See also
  popupWidth()

Implements Wt::Auth::OAuthService.

## ◆ popupWidth()

virtual int Wt::Auth::FacebookService::popupWidth | ( |  | ) | const
| overridevirtual

Returns the desired width for the popup window.

See also
  popupHeight()

Implements Wt::Auth::OAuthService.

## ◆ redirectEndpoint()

virtual std::string Wt::Auth::FacebookService::redirectEndpoint | ( |  | ) | const
| overridevirtual

Returns the redirection endpoint URL.

This is the local URL to which the browser is redirect from the service provider, after the authorization process. You need to configure this URL with the third party authentication service.

A static resource will be deployed at this URL.

See also
  WServer::addResource()

Implements Wt::Auth::OAuthService.

## ◆ redirectEndpointPath()

virtual std::string Wt::Auth::FacebookService::redirectEndpointPath | ( |  | ) | const
| overridevirtual

Returns the deployment path of the redirection endpoint.

This returns the path at which the static resource is deployed that corresponds to the redirectEndpoint().

The default implementation will derive this path from the redirectEndpoint() URL.

Reimplemented from Wt::Auth::OAuthService.

## ◆ tokenEndpoint()

virtual std::string Wt::Auth::FacebookService::tokenEndpoint | ( |  | ) | const
| overridevirtual

Returns the token endpoint URL.

This is a remote URL which hosts a web-service that generates access tokens.

Implements Wt::Auth::OAuthService.

## ◆ tokenRequestMethod()

virtual Http::Method Wt::Auth::FacebookService::tokenRequestMethod | ( |  | ) | const
| overridevirtual

Returns the HTTP method used for the token request.

While the current OAuth 2.0 draft mandates the use of POST, some implementations (like Facebook) use URL-encoding and a GET request.

The default implementation returns Http::Method::Post (corresponding to the current draft).

Reimplemented from Wt::Auth::OAuthService.