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

#include <oauth2.h>

Inheritance diagram for granada::http::oauth2::OAuth2User:
granada::http::oauth2::OAuth2Entity granada::http::oauth2::MapOAuth2User granada::http::oauth2::RedisOAuth2User

Public Member Functions

 OAuth2User ()
 
 OAuth2User (const std::string &username)
 
virtual void Load () override
 
virtual void Load (const std::string &identifier) override
 
virtual bool Create (const std::string &username, std::string &password, const web::json::value &roles)
 
virtual bool CorrectCredentials (std::string password)
 
virtual bool Delete (const std::string &password)
 
virtual const bool HasRole (const std::string &role)
 
virtual const std::string GetUsername ()
 
virtual void SetUsername (const std::string &username)
 
virtual web::json::value 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 username_
 
std::string key_
 
web::json::value roles_
 
std::time_t creation_time_
 

Static Protected Attributes

static std::mutex oauth2_user_creation_mtx_
 
static std::string cache_namespace_
 

Detailed Description

OAuth 2.0 User The user is the resource owner and the person that authorizes or denies the client to access the user's resources. Our authorization server must know the user. OAuth 2.0 User should not be used for accessing resources, this is used for authorization an authentication purposes.

Constructor & Destructor Documentation

granada::http::oauth2::OAuth2User::OAuth2User ( )
inline

Constructor Loads the properties.

granada::http::oauth2::OAuth2User::OAuth2User ( const std::string &  username)
inline

Constructor Loads the properties and the values of the user with given username.

Parameters
usernameUsername.

Member Function Documentation

virtual bool granada::http::oauth2::OAuth2User::CorrectCredentials ( std::string  password)
virtual

Verify if user credentials are correct. Returns true if they are, and false if they are not.

Parameters
usernameUsername
passwordUser password
Returns
True if credentials are correct and false if they are not.
virtual bool granada::http::oauth2::OAuth2User::Create ( const std::string &  username,
std::string &  password,
const web::json::value &  roles 
)
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
usernameUsername.
passwordPassword of the user.
rolesMaximum roles a user can be authorize to authorize a client to have, roles manage the permissions an entity has over user's resources.
Returns
True if client is successfully, false if it has not because it already exists.
virtual bool granada::http::oauth2::OAuth2User::Delete ( const std::string &  password)
virtual

Delete a user.

Parameters
passwordUser password.
Returns
True if user has successfuly been deleted.
virtual const std::time_t granada::http::oauth2::OAuth2User::GetCreationTime ( )
inlinevirtual
virtual web::json::value granada::http::oauth2::OAuth2User::GetRoles ( )
inlinevirtual
virtual const std::string granada::http::oauth2::OAuth2User::GetUsername ( )
inlinevirtual
virtual const std::string granada::http::oauth2::OAuth2User::hash ( )
inlineoverrideprotectedvirtual

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

Returns
Key of the OAuth 2.0 user values.

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

virtual const bool granada::http::oauth2::OAuth2User::HasRole ( const std::string &  role)
inlinevirtual

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

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

Loads the values of the user retrieving them from the cache with the username.

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

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

Loads the values of the user retrieving them from the cache with the given username.

Parameters
identifierUsername.

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

virtual void granada::http::oauth2::OAuth2User::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::OAuth2User::SetUsername ( const std::string &  username)
inlinevirtual

Member Data Documentation

std::string granada::http::oauth2::OAuth2User::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::time_t granada::http::oauth2::OAuth2User::creation_time_
protected

Date of the user creation.

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

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

std::mutex granada::http::oauth2::OAuth2User::oauth2_user_creation_mtx_
staticprotected

Mutex for multithread safety.

web::json::value granada::http::oauth2::OAuth2User::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::OAuth2User::username_
protected

Username. Unique identifier of the user.


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