10Duke Enterprise C++ Client
|
#include <OAuthPKCERequest.h>
PKCE-implementation of tenduke::oauth::OAuthRequest.
Public Member Functions | |
OAuthPKCERequest (std::string scopes, std::string state, std::map< std::string, std::string > additionalParameters, std::string codeVerifier, std::shared_ptr< const tenduke::oauth::OAuthConfiguration > config, std::shared_ptr< const tenduke::http::HTTPClient > httpClient, std::shared_ptr< const tenduke::net::URLParser > urlParser, std::shared_ptr< const tenduke::json::JSONParser > jsonParser, std::shared_ptr< const tenduke::utl::Base64Encoder > base64Encoder, std::shared_ptr< const tenduke::crypto::MessageDigestFactory > messageDigestFactory, std::shared_ptr< tenduke::time::Clock > clock) | |
Constructs new instance. | |
std::string | buildAuthorizationRequestUrl () const override |
Creates the initial authorization request URL. | |
std::unique_ptr< tenduke::oauth::OAuthState > | handleCallback (const std::string &redirectUri) const override |
Handles callback: performs consequent actions to authorize. | |
Protected Member Functions | |
virtual std::map< std::string, std::string > | buildTokenRequestParameters (const std::string &code) const |
Builds parameters for the token request. | |
virtual std::map< std::string, std::string > | buildAuthorizationRequestParameters () const |
Builds parameters for the authorization request. | |
virtual void | createCodeChallenge (std::map< std::string, std::string > ¶meters) const |
Creates PKCE code challenge and adds it to the provided parameters. | |
virtual std::unique_ptr< tenduke::oauth::OAuthState > | handleSuccessfulCallback (const std::multimap< std::string, std::string > &queryParameters) const |
Handles successful callback to redirect-uri from authorization request, performing the next steps to complete the authorization. | |
virtual bool | isPKCERequest () const |
Checks if this is PKCE-request. | |
virtual std::unique_ptr< tenduke::oauth::OAuthTokenRequest > | createTokenRequest (const std::string &code) const |
Creates the token request. | |
Protected Member Functions inherited from tenduke::oauth::BaseOAuthRequest | |
BaseOAuthRequest (const std::string &scopes, const std::map< std::string, std::string > &additionalParameters, const std::shared_ptr< const ::tenduke::oauth::OAuthConfiguration > &config, const std::shared_ptr< const ::tenduke::http::HTTPClient > &http, const std::shared_ptr< const ::tenduke::json::JSONParser > &parseJson, const std::shared_ptr<::tenduke::time::Clock > &clock) | |
Constructs new instance. | |
virtual std::map< std::string, std::string > | buildTokenRequestParameters () const |
Builds base parameters for the token request. | |
virtual std::unique_ptr<::tenduke::oauth::OAuthTokenRequest > | createTokenRequest () const |
Creates the token request. | |
virtual std::unique_ptr<::tenduke::oauth::OAuthState > | handleTokenResponse (std::unique_ptr<::tenduke::oauth::OAuthTokenResponse > response) const |
Handles token response. | |
Additional Inherited Members | |
Protected Attributes inherited from tenduke::oauth::BaseOAuthRequest | |
const std::string | scopes |
const std::map< std::string, std::string > | additionalParameters |
const std::shared_ptr< const ::tenduke::oauth::OAuthConfiguration > | config |
const std::shared_ptr< const ::tenduke::http::HTTPClient > | http |
const std::shared_ptr< const ::tenduke::json::JSONParser > | parseJSON |
const std::shared_ptr<::tenduke::time::Clock > | clock |
tenduke::oauth::pkce::OAuthPKCERequest::OAuthPKCERequest | ( | std::string | scopes, |
std::string | state, | ||
std::map< std::string, std::string > | additionalParameters, | ||
std::string | codeVerifier, | ||
std::shared_ptr< const tenduke::oauth::OAuthConfiguration > | config, | ||
std::shared_ptr< const tenduke::http::HTTPClient > | httpClient, | ||
std::shared_ptr< const tenduke::net::URLParser > | urlParser, | ||
std::shared_ptr< const tenduke::json::JSONParser > | jsonParser, | ||
std::shared_ptr< const tenduke::utl::Base64Encoder > | base64Encoder, | ||
std::shared_ptr< const tenduke::crypto::MessageDigestFactory > | messageDigestFactory, | ||
std::shared_ptr< tenduke::time::Clock > | clock | ||
) |
Constructs new instance.
scopes | - |
state | - |
additionalParameters | - |
codeVerifier | - |
config | - |
httpClient | - |
urlParser | - |
jsonParser | - |
base64Encoder | - |
messageDigestFactory | - |
clock | - |
|
protectedvirtual |
Builds parameters for the authorization request.
|
overridevirtual |
Creates the initial authorization request URL.
Navigate browser to this URL.
Implements tenduke::oauth::OAuthBrowserAuthorizationRequest.
|
protectedvirtual |
Builds parameters for the token request.
code | authorization code returned from the authorization request. |
|
protectedvirtual |
Creates PKCE code challenge and adds it to the provided parameters.
parameters | - |
|
protectedvirtual |
Creates the token request.
code | authorization code returned from the authorization request. |
|
overridevirtual |
Handles callback: performs consequent actions to authorize.
In the flow, the OAuth-server signals success or error by navigating (using HTTP-redirect) to configured redirect-URI. You must listen the browser events to detect, when the redirect-URI is navigated to. Once you detect navigation to the redirect-URI, call this method with the complete redirect-URI.
The call is synchronous.
redirectURI | - |
std::nested_exception | when the there is some nested cause |
tenduke::http::HTTPException | (or subclasses of it) when the server responds with HTTP error status code which does not indicate OAuth-error, e.g. 500 (internal server error) or 404 (not found = wrong endpoint configured) |
tenduke::json::JSONParsingException | when server response is not valid JSON |
tenduke::oauth::OAuthException | when the server response is not what we expected, e.g.
|
tenduke::oauth::OAuthServerError | when the server responds with an error |
tenduke::net::NetworkingException | (or subclasses of it) when networking error occurred, e.g.
|
tenduke::net::URLException | if problem parsing the redirectURI (should not happen, though) |
tenduke::net::MalformedURLException | if the redirectURI is invalid |
Implements tenduke::oauth::OAuthBrowserAuthorizationRequest.
|
protectedvirtual |
Handles successful callback to redirect-uri from authorization request, performing the next steps to complete the authorization.
queryParameters | query parameters extracted from the callback to the redirect-uri |
|
protectedvirtual |
Checks if this is PKCE-request.