Middleware for handling OAuth2 authentication.
More...
#include <OAuth2.hpp>
|
| static OAuth2 | google (const std::string &client_id, const std::string &client_secret, const std::string &redirect_uri) |
| | Pre-configured factory for Google OAuth2.
|
| |
| static OAuth2 | github (const std::string &client_id, const std::string &client_secret, const std::string &redirect_uri) |
| | Pre-configured factory for GitHub OAuth2.
|
| |
Middleware for handling OAuth2 authentication.
◆ OAuth2()
Constructs an OAuth2 middleware with the given config.
- Parameters
-
| config | The OAuth2 configuration. |
◆ callback_handler()
Handler to process the redirect callback, exchange the code for an access token, and fetch user info.
- Parameters
-
| on_success | Callback executed upon successful authentication. |
| on_error | Callback executed if an error occurs during authentication. |
- Returns
- std::function A middleware handler for the callback route.
◆ github()
| OAuth2 middleware::OAuth2::github |
( |
const std::string & |
client_id, |
|
|
const std::string & |
client_secret, |
|
|
const std::string & |
redirect_uri |
|
) |
| |
|
static |
Pre-configured factory for GitHub OAuth2.
- Parameters
-
| client_id | The GitHub client ID. |
| client_secret | The GitHub client secret. |
| redirect_uri | The redirect URI. |
- Returns
- OAuth2 A configured OAuth2 instance.
◆ google()
| OAuth2 middleware::OAuth2::google |
( |
const std::string & |
client_id, |
|
|
const std::string & |
client_secret, |
|
|
const std::string & |
redirect_uri |
|
) |
| |
|
static |
Pre-configured factory for Google OAuth2.
- Parameters
-
| client_id | The Google client ID. |
| client_secret | The Google client secret. |
| redirect_uri | The redirect URI. |
- Returns
- OAuth2 A configured OAuth2 instance.
◆ login_handler()
Handler to redirect the user to the OAuth2 provider's consent page.
- Returns
- std::function A middleware handler for login redirection.
The documentation for this class was generated from the following files: