Skip to content

Commit f85b972

Browse files
committed
Fix breaking change in AccessTokenAuthenticator
fixes #50511
1 parent 0c396df commit f85b972

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

Tests/Functional/AccessTokenTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,18 @@ public function testSelfContainedTokens()
333333
$this->assertSame(['message' => 'Welcome @dunglas!'], json_decode($response->getContent(), true));
334334
}
335335

336+
public function testCustomUserLoader()
337+
{
338+
$client = $this->createClient(['test_case' => 'AccessToken', 'root_config' => 'config_custom_user_loader.yml']);
339+
$client->catchExceptions(false);
340+
$client->request('GET', '/foo', [], [], ['HTTP_AUTHORIZATION' => 'Bearer SELF_CONTAINED_ACCESS_TOKEN']);
341+
$response = $client->getResponse();
342+
343+
$this->assertInstanceOf(Response::class, $response);
344+
$this->assertSame(200, $response->getStatusCode());
345+
$this->assertSame(['message' => 'Welcome @dunglas!'], json_decode($response->getContent(), true));
346+
}
347+
336348
/**
337349
* @requires extension openssl
338350
*/
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
imports:
2+
- { resource: ./../config/framework.yml }
3+
4+
framework:
5+
http_method_override: false
6+
serializer: ~
7+
8+
security:
9+
password_hashers:
10+
Symfony\Component\Security\Core\User\InMemoryUser: plaintext
11+
12+
providers:
13+
in_memory:
14+
memory:
15+
users:
16+
dunglas: { password: foo, roles: [ROLE_MISSING] }
17+
18+
firewalls:
19+
main:
20+
pattern: ^/
21+
stateless: true
22+
access_token:
23+
token_handler: access_token.access_token_handler
24+
token_extractors: 'header'
25+
realm: 'My API'
26+
27+
access_control:
28+
- { path: ^/foo, roles: ROLE_USER }
29+
30+
services:
31+
access_token.access_token_handler:
32+
class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AccessTokenBundle\Security\Handler\AccessTokenHandler

0 commit comments

Comments
 (0)