FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
Fossology\UI\Api\Helper\AuthHelper Class Reference

Provides helper methods for REST api. More...

Collaboration diagram for Fossology\UI\Api\Helper\AuthHelper:
Collaboration graph

Public Member Functions

 __construct (UserDao $userDao, Session $session, DbHelper $dbhelper)
 
 checkUsernameAndPassword ($userName, $password)
 Check the username and password against the database. More...
 
 verifyAuthToken ($authHeader, &$userId, &$tokenScope)
 
 isTokenActive ($valuesFromDb, $tokenId)
 
 getSession ()
 
 updateUserSession ($userId, $scope, $groupName=null)
 Update the session using updateSession(). More...
 
 generateJwtToken ($expire, $created, $jti, $scope, $key)
 
 getMaxTokenValidity ()
 
 userHasGroupAccess ($userId, $groupName)
 Verify if given User Id has access to given Group name. More...
 
 isGroupExisting ($groupName)
 Verify if given Group name exists. More...
 

Private Member Functions

 isDateExpired ($date)
 

Private Attributes

 $session
 
 $userDao
 
 $dbHelper
 

Detailed Description

Provides helper methods for REST api.

Definition at line 39 of file AuthHelper.php.

Constructor & Destructor Documentation

Fossology\UI\Api\Helper\AuthHelper::__construct ( UserDao  $userDao,
Session  $session,
DbHelper  $dbhelper 
)

AuthHelper constructor.

Parameters
UserDao$userDaoUser dao to use
Session$sessionSession to use
DbHelper$dbhelperDb Helper to use

Definition at line 64 of file AuthHelper.php.

Member Function Documentation

Fossology\UI\Api\Helper\AuthHelper::checkUsernameAndPassword (   $userName,
  $password 
)

Check the username and password against the database.

If the user is not 'Default User' and is valid, this function also update session using updateSession().

Parameters
string$userNameUsername
string$passwordPassword
Returns
boolean True if user is valid, false otherwise.
See also
updateSession()

Definition at line 86 of file AuthHelper.php.

Fossology\UI\Api\Helper\AuthHelper::generateJwtToken (   $expire,
  $created,
  $jti,
  $scope,
  $key 
)

Generates new JWT token.

Parameters
string$expireWhen the token will expire ('YYYY-MM-DD')
string$createdWhen the token was created ('YYYY-MM-DD')
string$jtiToken id (pat_pk.user_pk)
string$scopeUser friendly token scope
string$keyToken secret key
Returns
string New JWT token

Definition at line 214 of file AuthHelper.php.

Fossology\UI\Api\Helper\AuthHelper::getMaxTokenValidity ( )

Get the value for maximum API token validity from sysconfig table.

Returns
integer The value stored in DB.
See also
Fossology::UI::Api::Helper::getMaxTokenValidity()

Definition at line 231 of file AuthHelper.php.

Fossology\UI\Api\Helper\AuthHelper::getSession ( )

Get the current Symfony session

Returns
Session

Definition at line 178 of file AuthHelper.php.

Fossology\UI\Api\Helper\AuthHelper::isDateExpired (   $date)
private

Check if the given date is expired (is past).

Parameters
string$dateDate in Y-m-d format
Returns
boolean True if the date is of past.

Definition at line 148 of file AuthHelper.php.

Fossology\UI\Api\Helper\AuthHelper::isGroupExisting (   $groupName)

Verify if given Group name exists.

Parameters
string$groupNameName of the group to update session with.
Returns
boolean|Fossology::UI::Api::Models::Info True if group exists, Info in case of nt existing group.

Definition at line 267 of file AuthHelper.php.

Fossology\UI\Api\Helper\AuthHelper::isTokenActive (   $valuesFromDb,
  $tokenId 
)

Check if the token is still active and not expired.

Parameters
array$valuesFromDbValues from DB.
array$tokenIdToken id (pat_pk)
Returns
boolean|Fossology::UI::Api::Models::Info True if values are ok Info otherwise.

Definition at line 161 of file AuthHelper.php.

Fossology\UI\Api\Helper\AuthHelper::updateUserSession (   $userId,
  $scope,
  $groupName = null 
)

Update the session using updateSession().

Parameters
int$userIdUser id from the JWT.
string$scopeScope of the current token.
string$groupNameName of the group to update session with.
See also
updateSession()

Definition at line 191 of file AuthHelper.php.

Fossology\UI\Api\Helper\AuthHelper::userHasGroupAccess (   $userId,
  $groupName 
)

Verify if given User Id has access to given Group name.

Parameters
int$userIdUser id from the JWT.
string$groupNameName of the group to verify access to.
Returns
boolean|Fossology::UI::Api::Models::Info True if user has access to group, Info in case of no access or not existing group.

Definition at line 244 of file AuthHelper.php.

Fossology\UI\Api\Helper\AuthHelper::verifyAuthToken (   $authHeader,
$userId,
$tokenScope 
)

Verify the JWT token sent by user.

Parameters
string$authHeaderThe "Authorization" header sent by user.
int$userIdThe user id as per the valid token.
string$tokenScopeThe scope of the token presented.
Returns
boolean|Fossology::UI::Api::Models::Info True if the token is valid, false otherwise, Info in case of error.

Definition at line 101 of file AuthHelper.php.

Member Data Documentation

DbHelper Fossology\UI\Api\Helper\AuthHelper::$dbHelper
private

DB helper for DB interaction.

Definition at line 55 of file AuthHelper.php.

Session Fossology\UI\Api\Helper\AuthHelper::$session
private

Current Symfony session

Definition at line 45 of file AuthHelper.php.

UserDao Fossology\UI\Api\Helper\AuthHelper::$userDao
private

User DAO object

Definition at line 50 of file AuthHelper.php.


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