Compare commits

...
Author SHA1 Message Date
bence 845f1fe262 Merge pull request 'RVRNEXT-2 disable anti csrf check in case of oauth token' (!8) from feature/RVRNEXT-2-disable-anti-csrf-check-for-oauth-token into master
rvr-nextgen/pipeline/head This commit looks good
Reviewed-on: #8
2023-04-08 20:03:20 +02:00
bence bc9f1a1d1f RVRNEXT-2 disable anti csrf check in case of oauth token
rvr-nextgen/pipeline/pr-master This commit looks good
2023-04-08 20:02:02 +02:00
bence 84df948012 Merge pull request 'feature/RVRNEXT-2-fixes' (!7) from feature/RVRNEXT-2-fixes into master
rvr-nextgen/pipeline/head This commit looks good
Reviewed-on: #7
2023-04-08 19:38:16 +02:00
bence 1200489186 RVRNEXT-2 token endpoint should be POST
rvr-nextgen/pipeline/pr-master This commit looks good
2023-04-08 19:37:05 +02:00
bence 74d0b24f5f RVRNEXT-2 make endpoint names simpler 2023-04-08 19:37:02 +02:00
3 changed files with 7 additions and 4 deletions

No files matched your search

+1 -1
View File
@@ -35,7 +35,7 @@ if ($match !== null) {
return;
}
if ($method === 'post' && Container::$request->post('anti_csrf_token') !== Container::$request->session()->get('anti_csrf_token')) {
if ($method === 'post' && !in_array($url, $antiCsrfTokenExceptions) && Container::$request->post('anti_csrf_token') !== Container::$request->session()->get('anti_csrf_token')) {
$content = new SokoWeb\Response\JsonContent(['error' => 'no_valid_anti_csrf_token']);
header('Content-Type: text/html; charset=UTF-8', true, 403);
$content->render();
+1 -1
View File
@@ -89,7 +89,7 @@ class OAuthLoginController
{
$oAuthTokenRepository = new OAuthTokenRepository();
$userRepository = new UserRepository();
$token = $oAuthTokenRepository->getByCode($this->request->query('code'));
$token = $oAuthTokenRepository->getByCode($this->request->post('code'));
if ($token === null || $token->getExpiresDate() < new DateTime()) {
return new JsonContent([
+5 -2
View File
@@ -23,8 +23,8 @@ Container::$routeCollection->group('login', function (SokoWeb\Routing\RouteColle
Container::$routeCollection->group('oauth', function (SokoWeb\Routing\RouteCollection $routeCollection) {
$routeCollection->get('oauth-start', 'start', [RVR\Controller\OAuthLoginController::class, 'startOauth']);
$routeCollection->get('oauth-finish', 'finish', [RVR\Controller\OAuthLoginController::class, 'finishOauth']);
$routeCollection->get('oauth-getToken', 'getToken', [RVR\Controller\OAuthLoginController::class, 'getToken']);
$routeCollection->get('oauth-getJwtPublicKey', 'getJwtPublicKey', [RVR\Controller\OAuthLoginController::class, 'getJwtPublicKey']);
$routeCollection->post('oauth-token', 'token', [RVR\Controller\OAuthLoginController::class, 'getToken']);
$routeCollection->get('oauth-jwtPublicKey', 'jwtPublicKey', [RVR\Controller\OAuthLoginController::class, 'getJwtPublicKey']);
});
Container::$routeCollection->group('password', function (SokoWeb\Routing\RouteCollection $routeCollection) {
$routeCollection->get('password-requestReset', 'requestReset', [RVR\Controller\LoginController::class, 'getRequestPasswordResetForm']);
@@ -78,3 +78,6 @@ Container::$request = new SokoWeb\Request\Request(
if (!Container::$request->session()->has('anti_csrf_token')) {
Container::$request->session()->set('anti_csrf_token', bin2hex(random_bytes(16)));
}
//TODO: make a nicer logic
$antiCsrfTokenExceptions = ['oauth/token'];