diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 0efd43546f..51b03f31c1 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1133,6 +1133,7 @@ App::put('/v1/account/sessions/token') ->desc('Exchange token for session') ->label('event', 'users.[userId].sessions.[sessionId].create') ->groups(['api', 'account']) + ->label('scope', 'sessions') ->label('auth.type', 'token') ->label('audits.event', 'session.create') ->label('audits.resource', 'user/{response.userId}') diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 3cb54e271a..a3555956e1 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -1171,8 +1171,8 @@ App::post('/v1/users/:userId/tokens') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_TOKEN) ->param('userId', '', new UID(), 'User ID.') - ->param('length', 6, new Range(4, 128), 'Token length in chars.') - ->param('expire', Auth::TOKEN_EXPIRATION_UNIVERSAL, new Range(1, Auth::TOKEN_EXPIRATION_LOGIN_LONG), 'Token expiration in seconds from now.') + ->param('length', 6, new Range(4, 128), 'Token length in chars.', true) + ->param('expire', Auth::TOKEN_EXPIRATION_UNIVERSAL, new Range(1, Auth::TOKEN_EXPIRATION_LOGIN_LONG), 'Token expiration in seconds from now.', true) ->inject('request') ->inject('response') ->inject('dbForProject') @@ -1192,9 +1192,9 @@ App::post('/v1/users/:userId/tokens') 'userId' => $user->getId(), 'userInternalId' => $user->getInternalId(), 'type' => Auth::TOKEN_TYPE_GENERIC, - 'secret' => Auth::hash($secret), // One way hash encryption to protect DB leak + 'secret' => Auth::hash($secret), 'expire' => $expire, - 'userAgent' => 'UNKNOWN', + 'userAgent' => $request->getUserAgent('UNKNOWN'), 'ip' => $request->getIP() ]); diff --git a/tests/e2e/Services/Account/AccountCustomClientTest.php b/tests/e2e/Services/Account/AccountCustomClientTest.php index cb2b19f347..e4f9c9b788 100644 --- a/tests/e2e/Services/Account/AccountCustomClientTest.php +++ b/tests/e2e/Services/Account/AccountCustomClientTest.php @@ -2435,7 +2435,7 @@ class AccountCustomClientTest extends Scope $this->assertEmpty($response['body']['secret']); $sessionId = $response['body']['$id']; - $session = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_' . $this->getProject()['$id']]; + $session = $response['cookies']['a_session_' . $this->getProject()['$id']]; $response = $this->client->call(Client::METHOD_GET, '/account', array_merge([ 'origin' => 'http://localhost', diff --git a/tests/e2e/Services/Account/AccountCustomServerTest.php b/tests/e2e/Services/Account/AccountCustomServerTest.php index cf563affa2..435f8aac1b 100644 --- a/tests/e2e/Services/Account/AccountCustomServerTest.php +++ b/tests/e2e/Services/Account/AccountCustomServerTest.php @@ -133,7 +133,7 @@ class AccountCustomServerTest extends Scope $this->assertNotEmpty($response['body']['secret']); $sessionId = $response['body']['$id']; - $session = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_' . $this->getProject()['$id']]; + $session = $response['cookies']['a_session_' . $this->getProject()['$id']]; $response = $this->client->call(Client::METHOD_GET, '/account', array_merge( [