Skip to content

Commit 02c1e3c

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: fix merge Add test for AccessTokenHeaderRegex and adjust regex
2 parents 924e4d8 + bee1999 commit 02c1e3c

File tree

4 files changed

+29
-46
lines changed

4 files changed

+29
-46
lines changed

src/Symfony/Component/Inflector/.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/Symfony/Component/Inflector/.github/workflows/check-subtree-split.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/Symfony/Component/Security/Http/AccessToken/HeaderAccessTokenExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct(
2929
private readonly string $tokenType = 'Bearer',
3030
) {
3131
$this->regex = sprintf(
32-
'/^%s([a-zA-Z0-9\-_\+~\/\.]+)$/',
32+
'/^%s([a-zA-Z0-9\-_\+~\/\.]+=*)$/',
3333
'' === $this->tokenType ? '' : preg_quote($this->tokenType).'\s+'
3434
);
3535
}

src/Symfony/Component/Security/Http/Tests/Authenticator/AccessTokenAuthenticatorTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Security\Core\User\InMemoryUserProvider;
1919
use Symfony\Component\Security\Http\AccessToken\AccessTokenExtractorInterface;
2020
use Symfony\Component\Security\Http\AccessToken\AccessTokenHandlerInterface;
21+
use Symfony\Component\Security\Http\AccessToken\HeaderAccessTokenExtractor;
2122
use Symfony\Component\Security\Http\Authenticator\AccessTokenAuthenticator;
2223
use Symfony\Component\Security\Http\Authenticator\FallbackUserLoader;
2324
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
@@ -159,4 +160,31 @@ public function testAuthenticateWithFallbackUserLoader()
159160

160161
$this->assertEquals('test', $passport->getUser()->getUserIdentifier());
161162
}
163+
164+
/**
165+
* @dataProvider provideAccessTokenHeaderRegex
166+
*/
167+
public function testAccessTokenHeaderRegex(string $input, ?string $expectedToken)
168+
{
169+
// Given
170+
$extractor = new HeaderAccessTokenExtractor();
171+
$request = Request::create('/test', 'GET', [], [], [], ['HTTP_AUTHORIZATION' => $input]);
172+
173+
// When
174+
$token = $extractor->extractAccessToken($request);
175+
176+
// Then
177+
$this->assertEquals($expectedToken, $token);
178+
}
179+
180+
public function provideAccessTokenHeaderRegex(): array
181+
{
182+
return [
183+
['Bearer token', 'token'],
184+
['Bearer mF_9.B5f-4.1JqM', 'mF_9.B5f-4.1JqM'],
185+
['Bearer d3JvbmdfcmVnZXhwX2V4bWFwbGU=', 'd3JvbmdfcmVnZXhwX2V4bWFwbGU='],
186+
['Bearer Not Valid', null],
187+
['Bearer (NotOK123)', null],
188+
];
189+
}
162190
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy