19#ifndef PULSAR_AUTHENTICATION_H_
20#define PULSAR_AUTHENTICATION_H_
22#include <pulsar/Result.h>
23#include <pulsar/defines.h>
84typedef std::shared_ptr<AuthenticationDataProvider> AuthenticationDataPtr;
85typedef std::shared_ptr<Authentication> AuthenticationPtr;
86typedef std::map<std::string, std::string> ParamMap;
105 authDataContent = authData_;
124 AuthenticationDataPtr authData_;
138 static AuthenticationPtr Disabled();
145 static AuthenticationPtr
create(
const std::string& pluginNameOrDynamicLibPath);
153 static AuthenticationPtr
create(
const std::string& pluginNameOrDynamicLibPath,
154 const std::string& authParamsString);
172 static AuthenticationPtr
create(
const std::string& pluginNameOrDynamicLibPath, ParamMap& params);
175 static bool isShutdownHookRegistered_;
176 static std::vector<void*> loadedLibrariesHandles_;
177 static void release_handles();
185 AuthTls(AuthenticationDataPtr&);
194 static AuthenticationPtr
create(ParamMap& params);
201 static AuthenticationPtr
create(
const std::string& authParamsString);
209 static AuthenticationPtr
create(
const std::string& certificatePath,
const std::string& privateKeyPath);
226 AuthenticationDataPtr authDataTls_;
229typedef std::function<std::string()> TokenSupplier;
254 static AuthenticationPtr
create(ParamMap& params);
261 static AuthenticationPtr
create(
const std::string& authParamsString);
277 static AuthenticationPtr
create(
const TokenSupplier& tokenSupplier);
294 AuthenticationDataPtr authDataToken_;
302 explicit AuthBasic(AuthenticationDataPtr&);
311 static AuthenticationPtr
create(ParamMap& params);
318 static AuthenticationPtr
create(
const std::string& authParamsString);
323 static AuthenticationPtr
create(
const std::string& username,
const std::string& password);
328 static AuthenticationPtr
create(
const std::string& username,
const std::string& password,
329 const std::string& method);
346 AuthenticationDataPtr authDataBasic_;
366 static AuthenticationPtr
create(ParamMap& params);
373 static AuthenticationPtr
create(
const std::string& authParamsString);
390 AuthenticationDataPtr authDataAthenz_;
399 undefined_expiration = -1
457 std::string accessToken_;
459 std::string idToken_;
461 std::string refreshToken_;
466typedef std::shared_ptr<Oauth2TokenResult> Oauth2TokenResultPtr;
492typedef std::shared_ptr<Oauth2Flow> FlowPtr;
514typedef std::shared_ptr<CachedToken> CachedTokenPtr;
541 static AuthenticationPtr
create(ParamMap& params);
548 static AuthenticationPtr
create(
const std::string& authParamsString);
566 CachedTokenPtr cachedTokenPtr_;
Definition Authentication.h:352
Result getAuthData(AuthenticationDataPtr &authDataAthenz)
const std::string getAuthMethodName() const
static AuthenticationPtr create(ParamMap ¶ms)
static AuthenticationPtr create(const std::string &authParamsString)
Definition Authentication.h:300
Result getAuthData(AuthenticationDataPtr &authDataBasic) override
static AuthenticationPtr create(const std::string &username, const std::string &password)
static AuthenticationPtr create(const std::string &username, const std::string &password, const std::string &method)
static AuthenticationPtr create(const std::string &authParamsString)
const std::string getAuthMethodName() const override
static AuthenticationPtr create(ParamMap ¶ms)
Definition Authentication.h:136
static AuthenticationPtr create(const std::string &pluginNameOrDynamicLibPath)
static AuthenticationPtr create(const std::string &pluginNameOrDynamicLibPath, ParamMap ¶ms)
static AuthenticationPtr create(const std::string &pluginNameOrDynamicLibPath, const std::string &authParamsString)
Definition Authentication.h:528
static AuthenticationPtr create(ParamMap ¶ms)
const std::string getAuthMethodName() const
static AuthenticationPtr create(const std::string &authParamsString)
Result getAuthData(AuthenticationDataPtr &authDataOauth2)
Definition Authentication.h:183
static AuthenticationPtr create(const std::string &authParamsString)
const std::string getAuthMethodName() const
static AuthenticationPtr create(ParamMap ¶ms)
static AuthenticationPtr create(const std::string &certificatePath, const std::string &privateKeyPath)
Result getAuthData(AuthenticationDataPtr &authDataTls)
Definition Authentication.h:234
const std::string getAuthMethodName() const
Result getAuthData(AuthenticationDataPtr &authDataToken)
static AuthenticationPtr createWithToken(const std::string &token)
static AuthenticationPtr create(const std::string &authParamsString)
static AuthenticationPtr create(ParamMap ¶ms)
static AuthenticationPtr create(const TokenSupplier &tokenSupplier)
Definition Authentication.h:36
virtual bool hasDataFromCommand()
virtual std::string getCommandData()
virtual std::string getTlsPrivateKey()
virtual std::string getHttpHeaders()
virtual std::string getHttpAuthType()
virtual std::string getTlsCertificates()
virtual bool hasDataForTls()
virtual bool hasDataForHttp()
Definition Authentication.h:88
static ParamMap parseDefaultFormatAuthParams(const std::string &authParamsString)
virtual Result getAuthData(AuthenticationDataPtr &authDataContent)
Definition Authentication.h:104
virtual const std::string getAuthMethodName() const =0
Definition Authentication.h:494
virtual bool isExpired()=0
virtual AuthenticationDataPtr getAuthData()=0
Definition ClientConfiguration.h:29
Definition Authentication.h:468
virtual Oauth2TokenResultPtr authenticate()=0
virtual void initialize()=0
Definition Authentication.h:395
int64_t getExpiresIn() const
const std::string & getAccessToken() const
Oauth2TokenResult & setRefreshToken(const std::string &refreshToken)
Oauth2TokenResult & setIdToken(const std::string &idToken)
Oauth2TokenResult & setExpiresIn(const int64_t expiresIn)
const std::string & getRefreshToken() const
const std::string & getIdToken() const
Oauth2TokenResult & setAccessToken(const std::string &accessToken)
Definition Authentication.h:31
Result
Definition Result.h:32
@ ResultOk
An internal error code used for retry.
Definition Result.h:34