Wt: Wt::Auth::GoogleService Class Reference

Wt 4.10.4

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

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

`#include <GoogleService.h>`

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

## Public Member Functions
| GoogleService (const AuthService &baseAuth)
| Constructor.
virtual std::string | redirectEndpointPath () const override
| Returns the deployment path of the redirection endpoint.
Public Member Functions inherited from Wt::Auth::OidcService
| OidcService (const AuthService &baseAuth)
| 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 of 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 | authorizationEndpoint () const override
| Returns the authorization endpoint URL.
virtual std::string | tokenEndpoint () const override
| Returns the token endpoint URL.
virtual std::string | userInfoEndpoint () const override
| Returns the user info 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 std::unique_ptr< OAuthProcess > | createProcess (const std::string &scope) const override
| Creates a new authentication process.
void | setRedirectEndpoint (const std::string &url)
| Sets the redirection endpoint URL.
void | setClientId (const std::string &id)
| Sets the client ID.
void | setClientSecret (const std::string &secret)
| Sets the client secret.
void | setAuthEndpoint (const std::string &url)
| Sets the authorization endpoint URL.
void | setTokenEndpoint (const std::string &url)
| Sets the token endpoint URL.
void | setUserInfoEndpoint (const std::string &url)
| Sets the user info endpoint URL.
void | setAuthenticationScope (const std::string &scope)
| Sets the scope needed for authentication.
void | setName (const std::string &name)
| Sets the provider name.
void | setDescription (const std::string &description)
| Sets the provider description.
void | setClientSecretMethod (ClientSecretMethod method)
| Sets the method to transfer the client secret.
void | setPopupWidth (int width)
| Sets the desired width for the popup window.
void | setPopupHeight (int height)
| Sets the desired height for the popup window.
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.
virtual Http::Method | tokenRequestMethod () const
| Returns the HTTP method used for the token request.
void | configureRedirectEndpoint () const
| Configures the static resource implementing the redirect endpoint.

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

## Detailed Description

OAuth service for Google as third-party authenticator.

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

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

For example:

<properties>
<property name="google-oauth2-redirect-endpoint">
http://localhost:8080/oauth2callback
</property>
<property name="google-oauth2-client-id">
123456789012.apps.googleusercontent.com
</property>
<property name="google-oauth2-client-secret">
abcdefghijk-12312312312
</property>
</properties>
Wt::Auth::OidcService::name
virtual std::string name() const override
Returns the provider name.
Definition OidcService.h:124

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 GoogleService" object is thus thread-safe.

See also
  https://developers.google.com/identity/protocols/OAuth2
  https://developers.google.com/identity/protocols/OpenIDConnect

Note
  For FastCGI, see also additional configuration in OAuthService

## Member Function Documentation

## ◆ configured()

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

Checks whether a GoogleAuth service is properly configured.

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

## ◆ redirectEndpointPath()

virtual std::string Wt::Auth::GoogleService::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.