Kurlyk
Loading...
Searching...
No Matches
kurlyk::http::auth::BearerTokenAuthProvider Class Reference

Injects an Authorization: Bearer <token> header. More...

#include <BearerTokenAuthProvider.hpp>

Inheritance diagram for kurlyk::http::auth::BearerTokenAuthProvider:
kurlyk::http::auth::IAuthProvider

Public Member Functions

 BearerTokenAuthProvider (const std::string &token)
 Constructs a provider with a Bearer token.
void set_token (const std::string &token)
 Sets a new Bearer token, replacing any previous value.
bool authorize (HttpRequest &request) const override
 Modifies an HttpRequest in-place to include authentication credentials.
bool authorize (Headers &headers) const override
 Modifies a header map in-place to include authentication credentials.
Public Member Functions inherited from kurlyk::http::auth::IAuthProvider
virtual ~IAuthProvider ()

Private Attributes

std::string m_token

Detailed Description

Injects an Authorization: Bearer <token> header.

Definition at line 17 of file BearerTokenAuthProvider.hpp.

Constructor & Destructor Documentation

◆ BearerTokenAuthProvider()

kurlyk::http::auth::BearerTokenAuthProvider::BearerTokenAuthProvider ( const std::string & token)
inlineexplicit

Constructs a provider with a Bearer token.

Parameters
tokenThe bearer token string.

Definition at line 21 of file BearerTokenAuthProvider.hpp.

Member Function Documentation

◆ authorize() [1/2]

bool kurlyk::http::auth::BearerTokenAuthProvider::authorize ( Headers & headers) const
inlineoverridevirtual

Modifies a header map in-place to include authentication credentials.

Parameters
headersThe headers to authorize.
Returns
true if authorization was applied successfully.

Implements kurlyk::http::auth::IAuthProvider.

Definition at line 37 of file BearerTokenAuthProvider.hpp.

◆ authorize() [2/2]

bool kurlyk::http::auth::BearerTokenAuthProvider::authorize ( HttpRequest & request) const
inlineoverridevirtual

Modifies an HttpRequest in-place to include authentication credentials.

Parameters
requestThe HTTP request to authorize.
Returns
true if authorization was applied successfully.

Implements kurlyk::http::auth::IAuthProvider.

Definition at line 30 of file BearerTokenAuthProvider.hpp.

◆ set_token()

void kurlyk::http::auth::BearerTokenAuthProvider::set_token ( const std::string & token)
inline

Sets a new Bearer token, replacing any previous value.

Parameters
tokenThe new bearer token.

Definition at line 26 of file BearerTokenAuthProvider.hpp.

Member Data Documentation

◆ m_token

std::string kurlyk::http::auth::BearerTokenAuthProvider::m_token
private

Definition at line 45 of file BearerTokenAuthProvider.hpp.


The documentation for this class was generated from the following file: