Skip to content

Commit 0874c11

Browse files
authored
Merge branch 'thephpleague:master' into fix/authorization-code-error-redirect
2 parents 6322066 + 161ba05 commit 0874c11

25 files changed

+80
-77
lines changed

.github/workflows/unit-tests.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
php: ['8.1', '8.2', '8.3']
18-
symfony: ['5.4.*', '6.4.*', '7.0.*']
17+
php: ['8.1', '8.2', '8.3', '8.4']
18+
symfony: ['5.4.*', '6.4.*', '7.1.*', '7.2.*']
1919
doctrine-orm: ['^2.14', '^3.0']
2020
composer-flags: ['--prefer-stable']
2121
can-fail: [false]
@@ -27,7 +27,9 @@ jobs:
2727
can-fail: false
2828
exclude:
2929
- php: "8.1"
30-
symfony: "7.0.*"
30+
symfony: "7.1.*"
31+
- php: "8.1"
32+
symfony: "7.2.*"
3133

3234
name: "PHP ${{ matrix.php }} - Doctrine ${{ matrix.doctrine-orm }} - Symfony ${{ matrix.symfony }}${{ matrix.composer-flags != '' && format(' - Composer {0}', matrix.composer-flags) || '' }}"
3335

@@ -39,7 +41,7 @@ jobs:
3941
uses: "actions/checkout@v4"
4042

4143
- name: "build the PHP environment"
42-
run: "dev/bin/docker-compose build --build-arg PHP_VERSION=${{ matrix.php }} --build-arg XDEBUG_VERSION='3.3.1' php"
44+
run: "dev/bin/docker-compose build --build-arg PHP_VERSION=${{ matrix.php }} --build-arg XDEBUG_VERSION='3.4.0' php"
4345

4446
- name: "require specific Doctrine ORM version"
4547
run: "dev/bin/php composer require --ansi ${{ matrix.composer-flags }} --no-install doctrine/orm:${{ matrix.doctrine-orm }}"

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"ext-openssl": "*",
2121
"doctrine/doctrine-bundle": "^2.8.0",
2222
"doctrine/orm": "^2.14|^3.0",
23-
"league/oauth2-server": "^9",
23+
"league/oauth2-server": "^9.1",
2424
"nyholm/psr7": "^1.4",
2525
"psr/http-factory": "^1.0",
2626
"symfony/event-dispatcher": "^5.4|^6.2|^7.0",

dev/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LABEL maintainer="Petar Obradović <[email protected]>"
77
RUN mkdir -p /app/bin
88
ENV PATH /app/bin:$PATH
99

10-
ARG XDEBUG_VERSION=3.3.1
10+
ARG XDEBUG_VERSION=3.4.0
1111

1212
# Install needed core and PECL extensions
1313
RUN apk add --update --no-cache --virtual .build-deps \

docs/index.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,13 @@ security:
137137
type: php
138138
```
139139

140+
## Post-installation
141+
140142
You can verify that everything is working by issuing a `POST` request to the `/token` endpoint.
141143

142-
**❮ NOTE ❯** It is recommended to control the access to the authorization endpoint
143-
so that only logged in users can approve authorization requests.
144+
It is required to control access to the authorization endpoint
145+
so that only logged-in users can approve authorization requests.
146+
144147
You should review your `config/security.yaml` file. Here is a sample configuration:
145148

146149
```yaml
@@ -149,6 +152,9 @@ security:
149152
- { path: ^/authorize, roles: IS_AUTHENTICATED_REMEMBERED }
150153
```
151154
155+
> [!IMPORTANT]
156+
> The requirement for a logged-in user to approve authorization requests was introduced in version `0.9.0`. In previous versions, it was only a recommendation.
157+
152158
## Configuration
153159
154160
* [Basic setup](basic-setup.md)

src/Command/ClearExpiredTokensCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class ClearExpiredTokensCommand extends Command
3535
public function __construct(
3636
AccessTokenManagerInterface $accessTokenManager,
3737
RefreshTokenManagerInterface $refreshTokenManager,
38-
AuthorizationCodeManagerInterface $authorizationCodeManager
38+
AuthorizationCodeManagerInterface $authorizationCodeManager,
3939
) {
4040
parent::__construct();
4141

src/Command/GenerateKeyPairCommand.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Symfony\Component\Console\Attribute\AsCommand;
88
use Symfony\Component\Console\Command\Command;
9+
use Symfony\Component\Console\Input\InputArgument;
910
use Symfony\Component\Console\Input\InputInterface;
1011
use Symfony\Component\Console\Input\InputOption;
1112
use Symfony\Component\Console\Output\OutputInterface;
@@ -43,16 +44,13 @@ final class GenerateKeyPairCommand extends Command
4344

4445
private ?string $passphrase;
4546

46-
private string $algorithm;
47-
48-
public function __construct(Filesystem $filesystem, string $secretKey, string $publicKey, ?string $passphrase, string $algorithm)
47+
public function __construct(Filesystem $filesystem, string $secretKey, string $publicKey, ?string $passphrase)
4948
{
5049
parent::__construct();
5150
$this->filesystem = $filesystem;
5251
$this->secretKey = $secretKey;
5352
$this->publicKey = $publicKey;
5453
$this->passphrase = $passphrase;
55-
$this->algorithm = $algorithm;
5654
}
5755

5856
protected function configure(): void
@@ -61,19 +59,20 @@ protected function configure(): void
6159
$this->addOption('dry-run', null, InputOption::VALUE_NONE, 'Do not update key files.');
6260
$this->addOption('skip-if-exists', null, InputOption::VALUE_NONE, 'Do not update key files if they already exist.');
6361
$this->addOption('overwrite', null, InputOption::VALUE_NONE, 'Overwrite key files if they already exist.');
62+
$this->addArgument('algorithm', InputArgument::OPTIONAL, \sprintf('The algorithm code, possible values : %s', implode('', self::ACCEPTED_ALGORITHMS)), 'RS256');
6463
}
6564

6665
protected function execute(InputInterface $input, OutputInterface $output): int
6766
{
6867
$io = new SymfonyStyle($input, $output);
69-
70-
if (!\in_array($this->algorithm, self::ACCEPTED_ALGORITHMS, true)) {
71-
$io->error(\sprintf('Cannot generate key pair with the provided algorithm `%s`.', $this->algorithm));
68+
$algorithm = $input->getArgument('algorithm');
69+
if (!\in_array($algorithm, self::ACCEPTED_ALGORITHMS, true)) {
70+
$io->error(\sprintf('Cannot generate key pair with the provided algorithm `%s`.', $algorithm));
7271

7372
return Command::FAILURE;
7473
}
7574

76-
[$secretKey, $publicKey] = $this->generateKeyPair($this->passphrase);
75+
[$secretKey, $publicKey] = $this->generateKeyPair($this->passphrase, $algorithm);
7776

7877
if ($input->getOption('dry-run')) {
7978
$io->success('Your keys have been generated!');
@@ -137,9 +136,9 @@ private function handleExistingKeys(InputInterface $input): void
137136
/**
138137
* @return array{0: string, 1: string}
139138
*/
140-
private function generateKeyPair(?string $passphrase): array
139+
private function generateKeyPair(?string $passphrase, string $algorithm): array
141140
{
142-
$config = $this->buildOpenSSLConfiguration();
141+
$config = $this->buildOpenSSLConfiguration($algorithm);
143142

144143
$resource = openssl_pkey_new($config);
145144
if (false === $resource) {
@@ -165,7 +164,7 @@ private function generateKeyPair(?string $passphrase): array
165164
return [$privateKey, $publicKeyData['key']];
166165
}
167166

168-
private function buildOpenSSLConfiguration(): array
167+
private function buildOpenSSLConfiguration(string $algorithm): array
169168
{
170169
$digestAlgorithms = [
171170
'RS256' => 'sha256',
@@ -208,13 +207,13 @@ private function buildOpenSSLConfiguration(): array
208207
];
209208

210209
$config = [
211-
'digest_alg' => $digestAlgorithms[$this->algorithm],
212-
'private_key_type' => $privateKeyTypes[$this->algorithm],
213-
'private_key_bits' => $privateKeyBits[$this->algorithm],
210+
'digest_alg' => $digestAlgorithms[$algorithm],
211+
'private_key_type' => $privateKeyTypes[$algorithm],
212+
'private_key_bits' => $privateKeyBits[$algorithm],
214213
];
215214

216-
if (isset($curves[$this->algorithm])) {
217-
$config['curve_name'] = $curves[$this->algorithm];
215+
if (isset($curves[$algorithm])) {
216+
$config['curve_name'] = $curves[$algorithm];
218217
}
219218

220219
return $config;

src/Controller/AuthorizationController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function __construct(
6868
ClientManagerInterface $clientManager,
6969
HttpMessageFactoryInterface $httpMessageFactory,
7070
HttpFoundationFactoryInterface $httpFoundationFactory,
71-
ResponseFactoryInterface $responseFactory
71+
ResponseFactoryInterface $responseFactory,
7272
) {
7373
$this->server = $server;
7474
$this->eventDispatcher = $eventDispatcher;

src/Controller/TokenController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct(
4747
HttpMessageFactoryInterface $httpMessageFactory,
4848
HttpFoundationFactoryInterface $httpFoundationFactory,
4949
ResponseFactoryInterface $responseFactory,
50-
EventDispatcherInterface $eventDispatcher
50+
EventDispatcherInterface $eventDispatcher,
5151
) {
5252
$this->server = $server;
5353
$this->httpMessageFactory = $httpMessageFactory;

src/Manager/Doctrine/ClientManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ final class ClientManager implements ClientManagerInterface
3939
public function __construct(
4040
EntityManagerInterface $entityManager,
4141
EventDispatcherInterface $dispatcher,
42-
string $clientFqcn
42+
string $clientFqcn,
4343
) {
4444
$this->entityManager = $entityManager;
4545
$this->dispatcher = $dispatcher;

src/Model/AccessToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(
4848
\DateTimeInterface $expiry,
4949
ClientInterface $client,
5050
?string $userIdentifier,
51-
array $scopes
51+
array $scopes,
5252
) {
5353
$this->identifier = $identifier;
5454
$this->expiry = $expiry;

0 commit comments

Comments
 (0)