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::OAuth2Client Class Reference

#include <oauth2.h>

Inheritance diagram for granada::http::oauth2::OAuth2Client:
granada::http::oauth2::OAuth2Entity granada::http::oauth2::MapOAuth2Client granada::http::oauth2::RedisOAuth2Client

Public Member Functions

 OAuth2Client ()
 
 OAuth2Client (const std::string &id)
 
virtual void Load () override
 
virtual void Load (const std::string &identifier) override
 
virtual void Create (const std::string &type, const std::vector< std::string > &redirect_uris, const std::string &application_name, const std::vector< std::string > &roles, std::string &secret)
 
virtual bool CorrectCredentials (std::string secret)
 
virtual bool Delete (const std::string &secret)
 
virtual const bool HasRedirectURI (const std::string &redirect_uri)
 
virtual const bool HasRole (const std::string &role)
 
virtual const std::string GetId ()
 
virtual void SetId (const std::string &id)
 
virtual const std::string GetType ()
 
virtual const std::string GetApplicationName ()
 
virtual const std::vector
< std::string > 
GetRedirectURIs ()
 
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 id_
 
std::string key_
 
std::string type_
 
std::string application_name_
 
std::vector< std::string > redirect_uris_
 
std::vector< std::string > roles_
 
std::time_t creation_time_
 

Static Protected Attributes

static std::mutex oauth2_client_creation_mtx_
 
static std::string cache_namespace_
 
static int client_id_length_
 

Detailed Description

OAuth 2.0 client. The client represents the application that will access the user's resources.

Constructor & Destructor Documentation

granada::http::oauth2::OAuth2Client::OAuth2Client ( )
inline

Constructor Loads the properties.

granada::http::oauth2::OAuth2Client::OAuth2Client ( const std::string &  id)
inline

Constructor Loads the properties and the values of the client with given id.

Parameters
idIdentifier of the client.

Member Function Documentation

virtual bool granada::http::oauth2::OAuth2Client::CorrectCredentials ( std::string  secret)
virtual

Check if client credentials: id and secret are correct decrypting the key stored in the client key property. Use the cryptograph to decrypt the key with the given client secret.

Parameters
secretClient password.
Returns
True if credentials are correct, false if they are not.
virtual void granada::http::oauth2::OAuth2Client::Create ( const std::string &  type,
const std::vector< std::string > &  redirect_uris,
const std::string &  application_name,
const std::vector< std::string > &  roles,
std::string &  secret 
)
virtual

Creates a new client and store it using the cache. Client values will be stored with a key like: oauth2.client:value:myfNv849Z1GNuPAN.

Parameters
typeType of client: public | confidential public: Clients incapable of maintaining the confidentiality of their credentials (e.g., clients executing on the device used by the resource owner, such as an installed native application or a web browser-based application), and incapable of secure client authentication via any other means. confidential: Clients capable of maintaining the confidentiality of their credentials (e.g., client implemented on a secure server with restricted access to the client credentials), or capable of secure client authentication using other means.
redirect_urisUris to redirect the user after he has authorize or not the client. The redirection endpoint URI MUST be an absolute URI
application_nameName of the application.
rolesMaximum roles the client can ask to have, roles manage the permissions over the user's resources. Example: MSG_INSERT => this role will give the client the permission to create user messages.
secretPassword of the client, the client can use it to ask for a OAuth 2.0 code.
virtual bool granada::http::oauth2::OAuth2Client::Delete ( const std::string &  secret)
virtual

Delets an OAuth 2.0 client.

Parameters
secretClient password.
Returns
True if client is deleted successfuly, false if it not.
virtual const std::string granada::http::oauth2::OAuth2Client::GetApplicationName ( )
inlinevirtual
virtual const std::time_t granada::http::oauth2::OAuth2Client::GetCreationTime ( )
inlinevirtual
virtual const std::string granada::http::oauth2::OAuth2Client::GetId ( )
inlinevirtual
virtual const std::vector<std::string> granada::http::oauth2::OAuth2Client::GetRedirectURIs ( )
inlinevirtual
virtual const std::vector<std::string> granada::http::oauth2::OAuth2Client::GetRoles ( )
inlinevirtual
virtual const std::string granada::http::oauth2::OAuth2Client::GetType ( )
inlinevirtual
virtual const std::string granada::http::oauth2::OAuth2Client::hash ( )
inlineoverrideprotectedvirtual

Returns the key of the client values : that is the namespace and the client id Example: oauth2.client:value:myfNv849Z1GNuPAN This is the key to retrieve the client values, such as its key, type, redirect URIs, roles, creation time.

Returns
Key of the client values.

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

virtual const bool granada::http::oauth2::OAuth2Client::HasRedirectURI ( const std::string &  redirect_uri)
inlinevirtual

Returns true if the client has the given redirect URI in its collection. A client can have multiple redirect URI, in OAuth 2.0 authorization if no redirect_uri is provided, the first one in the client collection is taken.

Parameters
redirect_uriRedirect URI, check if the client has it.
Returns
True if client has the given redirection URI in its collection, False if it does not.
virtual const bool granada::http::oauth2::OAuth2Client::HasRole ( const std::string &  role)
inlinevirtual

Returns true if client has the given role in its collection. False if it does not.

Parameters
roleRole to check.
Returns
True if client has the given role in its collection, false if it does not.
virtual void granada::http::oauth2::OAuth2Client::Load ( )
overridevirtual

Loads the values of the client retrieving them from the cache with the client id.

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

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

Loads the values of the client retrieving them from the cache with the given client id.

Parameters
identifierClient id.

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

virtual void granada::http::oauth2::OAuth2Client::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::OAuth2Client::SetId ( const std::string &  id)
inlinevirtual

Member Data Documentation

std::string granada::http::oauth2::OAuth2Client::application_name_
protected

Name of the client application, used like a client description field, not used for authorization purposes.

std::string granada::http::oauth2::OAuth2Client::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:

int granada::http::oauth2::OAuth2Client::client_id_length_
staticprotected

Length of the unique alphanumeric id assigned to the client when created.

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

Date when client is created.

std::string granada::http::oauth2::OAuth2Client::id_
protected

Client id. Unique alphanumeric hash.

std::string granada::http::oauth2::OAuth2Client::key_
protected

Crypted key, used with the client secret to verify the client credentials when needed.

std::mutex granada::http::oauth2::OAuth2Client::oauth2_client_creation_mtx_
staticprotected

Mutex for multithread safety.

std::vector<std::string> granada::http::oauth2::OAuth2Client::redirect_uris_
protected

URI to which the user will be redirected once he authorize or not the client.

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

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

std::string granada::http::oauth2::OAuth2Client::type_
protected

Type of client: public | confidential public: Clients incapable of maintaining the confidentiality of their credentials (e.g., clients executing on the device used by the resource owner, such as an installed native application or a web browser-based application), and incapable of secure client authentication via any other means. confidential: Clients capable of maintaining the confidentiality of their credentials (e.g., client implemented on a secure server with restricted access to the client credentials), or capable of secure client authentication using other means.


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