Granada  1.54.0
Structured layer on top of C++ REST SDK for building server applications in C++. Granada implements sessions, server side plug-in framework, C++ OAuth 2.0 server, data storage access, server script running, server browsing.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
granada::http::oauth2::OAuth2Code Class Reference

#include <oauth2.h>

Inheritance diagram for granada::http::oauth2::OAuth2Code:
granada::http::oauth2::OAuth2Entity granada::http::oauth2::MapOAuth2Code granada::http::oauth2::RedisOAuth2Code

Public Member Functions

 OAuth2Code ()
 
 OAuth2Code (const std::string &code)
 
virtual void Load () override
 
virtual void Load (const std::string &identifier) override
 
virtual void Create (const std::string &client_id, const std::string &roles, const std::string &username)
 
virtual void Delete ()
 
virtual const std::string GetCode ()
 
virtual void SetCode (const std::string &code)
 
virtual const std::string GetClientId ()
 
virtual const std::string GetUsername ()
 
virtual const std::vector
< std::string > 
GetRoles ()
 
virtual const std::time_t GetCreationTime ()
 
- Public Member Functions inherited from granada::http::oauth2::OAuth2Entity
virtual
granada::cache::CacheHandler
cache ()
 
virtual
granada::crypto::Cryptograph
cryptograph ()
 
virtual
granada::crypto::NonceGenerator
nonce_generator ()
 
virtual const bool Exists ()
 

Protected Member Functions

virtual void LoadProperties ()
 
virtual const std::string hash () override
 

Protected Attributes

std::string code_
 
std::string client_id_
 
std::string username_
 
std::vector< std::string > roles_
 
std::time_t creation_time_
 

Static Protected Attributes

static std::mutex oauth2_code_creation_mtx_
 
static std::string cache_namespace_
 
static int code_length_
 

Detailed Description

OAuth 2.0 Code The authorization code is obtained by using an authorization server as an intermediary between the client and resource owner. Instead of requesting authorization directly from the resource owner, the client directs the resource owner to an authorization server (via its user-agent as defined in [RFC2616]), which in turn directs the resource owner back to the client with the authorization code.

Before directing the resource owner back to the client with the authorization code, the authorization server authenticates the resource owner and obtains authorization. Because the resource owner only authenticates with the authorization server, the resource owner's credentials are never shared with the client.

The authorization code provides a few important security benefits, such as the ability to authenticate the client, as well as the transmission of the access token directly to the client without passing it through the resource owner's user-agent and potentially exposing it to others, including the resource owner.

Constructor & Destructor Documentation

granada::http::oauth2::OAuth2Code::OAuth2Code ( )
inline

Constructor Loads the properties.

granada::http::oauth2::OAuth2Code::OAuth2Code ( const std::string &  code)
inline

Constructor Loads the properties and the values of the code with given code.

Parameters
codeUnique alphanumeric code.

Member Function Documentation

virtual void granada::http::oauth2::OAuth2Code::Create ( const std::string &  client_id,
const std::string &  roles,
const std::string &  username 
)
virtual

Creates an OAuth 2.0 user. This user should not be used for accessing resources, this is used for authorization and authentication purposes. It will be stored in the cache with a key like: oauth2.user:value:username.

Parameters
client_id[description]
roles[description]
username[description]
virtual void granada::http::oauth2::OAuth2Code::Delete ( )
virtual

Delete code from where it is stored.

virtual const std::string granada::http::oauth2::OAuth2Code::GetClientId ( )
inlinevirtual
virtual const std::string granada::http::oauth2::OAuth2Code::GetCode ( )
inlinevirtual
virtual const std::time_t granada::http::oauth2::OAuth2Code::GetCreationTime ( )
inlinevirtual
virtual const std::vector<std::string> granada::http::oauth2::OAuth2Code::GetRoles ( )
inlinevirtual
virtual const std::string granada::http::oauth2::OAuth2Code::GetUsername ( )
inlinevirtual
virtual const std::string granada::http::oauth2::OAuth2Code::hash ( )
inlineoverrideprotectedvirtual

Returns the key of the code values : that is the namespace and the code Example: oauth2.code:value:RQlUIgDxgCaTO8CLhAxNzveNtCHPQFrf This is the key to retrieve the code values, such as its client_id, username, roles, creation time.

Returns
Key of the OAuth 2.0 code values.

Reimplemented from granada::http::oauth2::OAuth2Entity.

virtual void granada::http::oauth2::OAuth2Code::Load ( )
overridevirtual

Loads the values of the code retrieving them from the cache with the code.

Reimplemented from granada::http::oauth2::OAuth2Entity.

virtual void granada::http::oauth2::OAuth2Code::Load ( const std::string &  identifier)
overridevirtual

Loads the values of the code retrieving them from the cache with the given code.

Parameters
identifierUnique alphanumeric code.

Reimplemented from granada::http::oauth2::OAuth2Entity.

virtual void granada::http::oauth2::OAuth2Code::LoadProperties ( )
protectedvirtual

Loads properties given in the configuration file, if properties are not found, then default values included in granada/defaults.dat file are used.

Reimplemented from granada::http::oauth2::OAuth2Entity.

virtual void granada::http::oauth2::OAuth2Code::SetCode ( const std::string &  code)
inlinevirtual

Member Data Documentation

std::string granada::http::oauth2::OAuth2Code::cache_namespace_
staticprotected

Namespace of the key of the entity data in the cache. Example: If we have the key : oauth2.client:value:L05l6pFaPFgZbtP9 => namespace is : oauth2.client:value:

std::string granada::http::oauth2::OAuth2Code::client_id_
protected

Client id. Unique alphanumeric hash identifying the client.

std::string granada::http::oauth2::OAuth2Code::code_
protected

Alphanumeric unique code.

int granada::http::oauth2::OAuth2Code::code_length_
staticprotected

Length of the unique alphanumeric code.

std::time_t granada::http::oauth2::OAuth2Code::creation_time_
protected

Date when code is created.

std::mutex granada::http::oauth2::OAuth2Code::oauth2_code_creation_mtx_
staticprotected

Mutex for multithread safety.

std::vector<std::string> granada::http::oauth2::OAuth2Code::roles_
protected

Maximum roles a user can be authorize to authorize a client to have, roles manage the permissions an entity has over user's resources.

std::string granada::http::oauth2::OAuth2Code::username_
protected

Username. Unique user identifier.


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