13 namespace Fossology\UI\Api\Controllers;
28 use Psr\Http\Message\ServerRequestInterface;
47 return $response->withStatus(204);
63 "Use OAuth clients.");
69 $this->restHelper->validateTokenRequest($tokenRequest->getTokenExpire(),
70 $tokenRequest->getTokenName(), $tokenRequest->getTokenScope());
72 $authHelper = $this->restHelper->getAuthHelper();
73 if (!$authHelper->checkUsernameAndPassword($tokenRequest->getUsername(),
74 $tokenRequest->getPassword())) {
78 $userId = $this->restHelper->getUserId();
82 $jti = $this->dbHelper->insertNewTokenKey($userId,
83 $tokenRequest->getTokenExpire(), $tokenRequest->getTokenScope(),
84 $tokenRequest->getTokenName(), $key);
90 $jti = $this->dbHelper->insertNewTokenKey($userId,
91 $tokenRequest->getTokenExpire(), $tokenRequest->getTokenScope(),
92 $tokenRequest->getTokenName(), $key);
102 if (! empty($jti[
'jti'])) {
103 $theJwtToken = $this->restHelper->getAuthHelper()->generateJwtToken(
104 $tokenRequest->getTokenExpire(), $jti[
'created_on'], $jti[
'jti'],
105 $tokenRequest->getTokenScope(), $key);
106 return $response->withJson([
107 "Authorization" =>
"Bearer " . $theJwtToken
Contains the constants and helpers for authentication of user.
static getRestTokenType()
Exception when a token has duplicate key for same user.
Exception when a token has duplicate name for same user.
Controller for Auth requests.
createNewJwtToken($request, $response, $args)
optionsVerification($request, $response, $args)
Base controller for REST calls.
getParsedBody(ServerRequestInterface $request)
Parse request body as JSON and return associative PHP array.
Override Slim response for withJson function.
Provides various DAO helper functions for REST api.
static getVersion(ServerRequestInterface $request)
static fromArray(array $input, int $version)