Leosac  0.8.0
Open Source Access Control
Leosac::Auth::Token Class Reference

An authentication token used for authenticating a user against Leosac. More...

#include <Token.hpp>

+ Collaboration diagram for Leosac::Auth::Token:

Public Member Functions

 Token ()
 
 Token (const std::string &token, UserPtr owner)
 
const std::string & id () const
 Return the token identifier. More...
 
const std::string & token () const
 Retrieve the string representation of the token. More...
 
bool is_valid () const
 Check if the token is still active. More...
 
UserPtr owner () const
 Retrieve a shared_ptr to the user owning the token. More...
 
boost::posix_time::ptime expiration () const
 Retrieve the unix timestamp at which the token will/has expire(d). More...
 
template<typename T >
void expire_in (const T &duration)
 Set the expiration point of the token to be now + duration. More...
 

Public Attributes

ssize_t version_
 

Private Attributes

std::string token_
 The string representation of the token. More...
 
UserPtr owner_
 The user owning the token. More...
 
boost::posix_time::ptime expiration_
 

Friends

class odb::access
 

Detailed Description

An authentication token used for authenticating a user against Leosac.

The authentication token can be persisted in database. This lets user authenticate with the same token between reboot.

One token maps to one user.

Definition at line 42 of file Token.hpp.

Constructor & Destructor Documentation

◆ Token() [1/2]

Token::Token ( )

Definition at line 27 of file Token.cpp.

◆ Token() [2/2]

Token::Token ( const std::string &  token,
UserPtr  owner 
)

Definition at line 32 of file Token.cpp.

Member Function Documentation

◆ expiration()

boost::posix_time::ptime Token::expiration ( ) const

Retrieve the unix timestamp at which the token will/has expire(d).

Definition at line 56 of file Token.cpp.

◆ expire_in()

template<typename T >
void Leosac::Auth::Token::expire_in ( const T &  duration)
inline

Set the expiration point of the token to be now + duration.

Definition at line 84 of file Token.hpp.

◆ id()

const std::string & Token::id ( ) const

Return the token identifier.

This method is an alias to the token() method.

Returns

Definition at line 61 of file Token.cpp.

◆ is_valid()

bool Token::is_valid ( ) const

Check if the token is still active.

Definition at line 45 of file Token.cpp.

◆ owner()

UserPtr Token::owner ( ) const

Retrieve a shared_ptr to the user owning the token.

Definition at line 51 of file Token.cpp.

◆ token()

const std::string & Token::token ( ) const

Retrieve the string representation of the token.

Returns

Definition at line 40 of file Token.cpp.

Friends And Related Function Documentation

◆ odb::access

friend class odb::access
friend

Definition at line 94 of file Token.hpp.

Member Data Documentation

◆ expiration_

boost::posix_time::ptime Leosac::Auth::Token::expiration_
private

Definition at line 111 of file Token.hpp.

◆ owner_

UserPtr Leosac::Auth::Token::owner_
private

The user owning the token.

Definition at line 108 of file Token.hpp.

◆ token_

std::string Leosac::Auth::Token::token_
private

The string representation of the token.

Definition at line 101 of file Token.hpp.

◆ version_

ssize_t Leosac::Auth::Token::version_

Definition at line 115 of file Token.hpp.


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