Skip to content

Commit ec3c08c

Browse files
committed
refactor(oauth2): Replace security annotations with respective attributes
Signed-off-by: provokateurin <[email protected]>
1 parent 13d2b67 commit ec3c08c

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

apps/oauth2/lib/Controller/LoginRedirectorController.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
use OCA\OAuth2\Exceptions\ClientNotFoundException;
1313
use OCP\AppFramework\Controller;
1414
use OCP\AppFramework\Http;
15+
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
16+
use OCP\AppFramework\Http\Attribute\PublicPage;
17+
use OCP\AppFramework\Http\Attribute\UseSession;
1518
use OCP\AppFramework\Http\RedirectResponse;
1619
use OCP\AppFramework\Http\TemplateResponse;
1720
use OCP\IL10N;
@@ -51,10 +54,6 @@ public function __construct(string $appName,
5154
}
5255

5356
/**
54-
* @PublicPage
55-
* @NoCSRFRequired
56-
* @UseSession
57-
*
5857
* Authorize the user
5958
*
6059
* @param string $client_id Client ID
@@ -65,6 +64,9 @@ public function __construct(string $appName,
6564
* 200: Client not found
6665
* 303: Redirect to login URL
6766
*/
67+
#[PublicPage]
68+
#[NoCSRFRequired]
69+
#[UseSession]
6870
public function authorize($client_id,
6971
$state,
7072
$response_type): TemplateResponse|RedirectResponse {

apps/oauth2/lib/Controller/OauthApiController.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use OCA\OAuth2\Exceptions\ClientNotFoundException;
1616
use OCP\AppFramework\Controller;
1717
use OCP\AppFramework\Http;
18+
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
19+
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
20+
use OCP\AppFramework\Http\Attribute\PublicPage;
1821
use OCP\AppFramework\Http\JSONResponse;
1922
use OCP\AppFramework\Utility\ITimeFactory;
2023
use OCP\Authentication\Exceptions\ExpiredTokenException;
@@ -47,10 +50,6 @@ public function __construct(
4750
}
4851

4952
/**
50-
* @PublicPage
51-
* @NoCSRFRequired
52-
* @BruteForceProtection(action=oauth2GetToken)
53-
*
5453
* Get a token
5554
*
5655
* @param string $grant_type Token type that should be granted
@@ -64,6 +63,9 @@ public function __construct(
6463
* 200: Token returned
6564
* 400: Getting token is not possible
6665
*/
66+
#[PublicPage]
67+
#[NoCSRFRequired]
68+
#[BruteForceProtection(action: 'oauth2GetToken')]
6769
public function getToken(
6870
string $grant_type, ?string $code, ?string $refresh_token,
6971
?string $client_id, ?string $client_secret

0 commit comments

Comments
 (0)