Skip to content

Commit

Permalink
newUser
Browse files Browse the repository at this point in the history
  • Loading branch information
ginokok1996 committed Dec 22, 2020
1 parent a3bb923 commit 63a3c3b
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 11 deletions.
Binary file modified api/helm/id-vault-0.1.0.tgz
Binary file not shown.
6 changes: 3 additions & 3 deletions api/helm/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ entries:
id-vault:
- apiVersion: v1
appVersion: V1.0
created: "2020-12-21T14:29:00.7595462Z"
created: "2020-12-22T11:56:11.8123539Z"
description: Naast deze JSON rest API is er ook een [graphql](/graphql) interface
beschikbaar.
digest: c2eba3fb200fe47299311d383bbb64abf010fee92542f30a3bcfd9c9f5c484da
digest: eb16b6b648f8639cb31e16c1ce8451786bada937c50e727e942e40d9d2a52552
home: www.id-vault.com
icon: www.id-vault.com
name: id-vault
urls:
- id-vault-0.1.0.tgz
version: 0.1.0
generated: "2020-12-21T14:29:00.7233135Z"
generated: "2020-12-22T11:56:11.8052208Z"
14 changes: 10 additions & 4 deletions api/public/schema/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5865,6 +5865,9 @@ components:
state:
description: 'A unique validator provided by your application to check the validaty of the call'
type: string
newUser:
description: 'Whether this user is new or not'
type: boolean
AccessToken-write:
type: object
description: ''
Expand Down Expand Up @@ -5923,6 +5926,9 @@ components:
state:
description: 'A unique validator provided by your application to check the validaty of the call'
type: string
newUser:
description: 'Whether this user is new or not'
type: boolean
'AccessToken:jsonld-write':
type: object
description: ''
Expand Down Expand Up @@ -7115,12 +7121,12 @@ definitions:
description: 'The moment this request was created'
type: string
format: date-time
example: '2020-12-21 14:31:13'
example: '2020-12-22 11:57:30'
dateModified:
description: 'The moment this request last Modified'
type: string
format: date-time
example: '2020-12-21 14:31:13'
example: '2020-12-22 11:57:30'
required: []
AuditTrail-write:
properties:
Expand Down Expand Up @@ -7168,12 +7174,12 @@ definitions:
description: 'The moment this request was created'
type: string
format: date-time
example: '2020-12-21 14:31:13'
example: '2020-12-22 11:57:30'
dateModified:
description: 'The moment this request last Modified'
type: string
format: date-time
example: '2020-12-21 14:31:13'
example: '2020-12-22 11:57:30'
required: []
ChangeLog-write:
properties:
Expand Down
2 changes: 1 addition & 1 deletion api/public/schema/publiccode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ url: "https://github.com/ConductionNL/id-vault"
landingURL: "dev.id-vault.com"
isBasedOn: "https://github.com/ConductionNL/Proto-component-commonground.git"
softwareVersion: "V1.0"
releaseDate: "2020-21-12"
releaseDate: "2020-22-12"
logo: www.id-vault.com
monochromeLogo: img/logo-mono.svg

Expand Down
21 changes: 21 additions & 0 deletions api/src/Entity/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ class AccessToken
*/
private $state;

/**
* @var bool Whether this user is new or not
*
* @example false
*
* @Groups({"read"})
*/
private $newUser;

public function getId(): ?Uuid
{
return $this->id;
Expand Down Expand Up @@ -286,4 +295,16 @@ public function setAccessToken(string $accessToken): self

return $this;
}

public function getNewUser(): ?bool
{
return $this->newUser;
}

public function setNewUser(bool $newUser): self
{
$this->newUser = $newUser;

return $this;
}
}
43 changes: 40 additions & 3 deletions api/src/Subscriber/AccessSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,57 @@ public function grantAccess(ViewEvent $event)
$application = $applications[0];

$authorization = $this->commonGroundService->getResource(['component' => 'wac', 'type' => 'authorizations', 'id' => $token->getCode()]);
// $authorization['code'] = null;
// $authorization['application'] = '/applications/'.$application['id'];
// $authorization = $this->commonGroundService->updateResource($authorization);

$token->setAccessToken($this->accessTokenGeneratorService->generateAccessToken($authorization, $application));
$token->setTokenType('bearer');
$token->setExpiresIn('3600');
$token->setNewUser($authorization['newUser']);
$token->setScope(implode('+', $authorization['scopes']));
$authorizationLog['status'] = '200';
$goal = $token->getGoal();
if (isset($goal)) {
$authorizationLog['goal'] = $goal;
}
$authorizationLog['authorization'] = '/authorizations/'.$authorization['id'];

$authorization['code'] = null;
$authorization['application'] = '/applications/'.$authorization['application']['id'];

if (!empty($authorization['claims'])) {
foreach ($authorization['claims'] as &$claim) {
$claim = '/claims/'.$claim['id'];
}
}

if (!empty($authorization['purposeLimitation'])) {
$authorization['purposeLimitation'] = '/purpose_limitations/'.$authorization['purposeLimitation']['id'];
}


if (!empty($authorization['dossiers'])) {
foreach ($authorization['dossiers'] as &$dossier) {
$dossier = '/dossiers/'.$dossier['id'];
}
}

if (!empty($authorization['scopeRequests'])) {
foreach ($authorization['scopeRequests'] as &$scopeRequest) {
$scopeRequest = '/scopes_requests/'.$scopeRequest['id'];
}
}

if (!empty($authorization['authorizationLogs'])) {
foreach ($authorization['authorizationLogs'] as &$log) {
$log = '/authorization_logs/'.$log['id'];
}
}

if ($authorization['newUser']) {
$authorization['newUser'] = false;
}

$authorization = $this->commonGroundService->saveResource($authorization, ['component' => 'wac', 'type' => 'authorizations']);

}
$authorizationLog['endpoint'] = 'access_tokens';
$this->commonGroundService->createResource($authorizationLog, ['component' => 'wac', 'type' => 'authorization_logs']);
Expand Down

0 comments on commit 63a3c3b

Please sign in to comment.