10Duke Enterprise C++ Client
Loading...
Searching...
No Matches
OAuthPKCERequest.h
1#ifndef TENDUKE_OAUTH_PKCE_OAUTHPKCEREQUEST_H
2#define TENDUKE_OAUTH_PKCE_OAUTHPKCEREQUEST_H
3
4#include "../BaseOAuthRequest.h"
5#include "../OAuthBrowserAuthorizationRequest.h"
6#include "../OAuthConfiguration.h"
7#include "../OAuthTokenRequest.h"
8#include "../OAuthState.h"
9
10#include "crypto/MessageDigestFactory.h"
11#include "http/HTTPClient.h"
12#include "json/JSONParser.h"
13#include "net/URLParser.h"
14#include "time/Clock.h"
15#include "utl/Base64Encoder.h"
16
17#include <map>
18#include <memory>
19
20namespace tenduke { namespace oauth { namespace pkce {
21
22
28{
29public:
45 std::string scopes,
46 std::string state,
47 std::map<std::string, std::string> additionalParameters,
48 std::string codeVerifier,
49 std::shared_ptr<const tenduke::oauth::OAuthConfiguration> config,
50 std::shared_ptr<const tenduke::http::HTTPClient> httpClient,
51 std::shared_ptr<const tenduke::net::URLParser> urlParser,
52 std::shared_ptr<const tenduke::json::JSONParser> jsonParser,
53 std::shared_ptr<const tenduke::utl::Base64Encoder> base64Encoder,
54 std::shared_ptr<const tenduke::crypto::MessageDigestFactory> messageDigestFactory,
55 std::shared_ptr<tenduke::time::Clock> clock
56 );
57 ~OAuthPKCERequest() override = default;
58
59 // tenduke::oauth::OAuthBrowserAuthorizationRequest interface
60 std::string buildAuthorizationRequestUrl() const override;
61 std::unique_ptr<tenduke::oauth::OAuthState> handleCallback(const std::string &redirectUri) const override;
62
63protected:
69 virtual std::map<std::string, std::string> buildTokenRequestParameters(const std::string &code) const;
70
75 virtual std::map<std::string, std::string> buildAuthorizationRequestParameters() const;
76
81 virtual void createCodeChallenge(std::map<std::string, std::string> &parameters) const;
82
89 virtual std::unique_ptr<tenduke::oauth::OAuthState> handleSuccessfulCallback(const std::multimap<std::string, std::string> &queryParameters) const;
90
95 virtual bool isPKCERequest() const;
96
102 virtual std::unique_ptr<tenduke::oauth::OAuthTokenRequest> createTokenRequest(const std::string &code) const;
103
104private:
105 const std::string state;
106
107 const std::string codeVerifier; // PKCE code verifier
108
109 const std::shared_ptr<const tenduke::net::URLParser> parseURL;
110 const std::shared_ptr<const tenduke::utl::Base64Encoder> base64Encoder;
111 const std::shared_ptr<const tenduke::crypto::MessageDigestFactory> messageDigest;
112};
113
114
115}}}
116
117#endif // TENDUKE_OAUTH_PKCE_OAUTHPKCEREQUEST_H
Base OAuthRequest.
Definition BaseOAuthRequest.h:23
virtual std::map< std::string, std::string > buildTokenRequestParameters() const
Builds base parameters for the token request.
Definition BaseOAuthRequest.cpp:15
virtual std::unique_ptr<::tenduke::oauth::OAuthTokenRequest > createTokenRequest() const
Creates the token request.
Definition BaseOAuthRequest.cpp:30
OAuth-request to handle OAuth authorization using browser.
Definition OAuthBrowserAuthorizationRequest.h:20
PKCE-implementation of tenduke::oauth::OAuthRequest.
Definition OAuthPKCERequest.h:28
virtual void createCodeChallenge(std::map< std::string, std::string > &parameters) const
Creates PKCE code challenge and adds it to the provided parameters.
Definition OAuthPKCERequest.cpp:170
virtual bool isPKCERequest() const
Checks if this is PKCE-request.
Definition OAuthPKCERequest.cpp:129
std::unique_ptr< tenduke::oauth::OAuthState > handleCallback(const std::string &redirectUri) const override
Handles callback: performs consequent actions to authorize.
Definition OAuthPKCERequest.cpp:44
virtual std::map< std::string, std::string > buildAuthorizationRequestParameters() const
Builds parameters for the authorization request.
Definition OAuthPKCERequest.cpp:147
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 ...
Definition OAuthPKCERequest.cpp:64
std::string buildAuthorizationRequestUrl() const override
Creates the initial authorization request URL.
Definition OAuthPKCERequest.cpp:136
OAuth services.
Definition AccessTokenRequestAuthenticator.h:8
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4