Skip to content

[Security] Add clock dependency to OidcTokenHandler #50477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2023

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 6.3
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

From "web-token/jwt-checker":
The parameter "$clock" will become mandatory in 4.0.0. Please set a valid PSR Clock implementation instead of "null".

Also fixing some other issues found meanwhile.

use Psr\Log\LoggerInterface;
use Symfony\Component\Clock\NativeClock;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NativeClock should never be used directly since 6.3

@nicolas-grekas nicolas-grekas force-pushed the oidc-clock branch 3 times, most recently from 1eb6720 to 2349d1b Compare May 30, 2023 16:25
->setArguments([$config['signature']['algorithm']]);
$container->register('security.access_token_handler.oidc.jwk', JWK::class)
->setFactory([JWK::class, 'createFromJson'])
->setArguments([$config['signature']['key']]);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the wiring. Before this change, all firewalls would share a single jwk+algo definition, since varying key/algo were registered under the same id

->isRequired()
->children()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing one unneeded nesting level in the config /cc @vincentchalamon for the doc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signature level was useful in anticipation of #50441. But removing it is more MVP. Let's talk about it later on #50441

@@ -49,7 +49,7 @@ public function getUserBadgeFrom(string $accessToken): UserBadge

// UserLoader argument can be overridden by a UserProvider on AccessTokenAuthenticator::authenticate
return new UserBadge($claims[$this->claim], fn () => $this->createUser($claims), $claims);
} catch (\Throwable $e) {
} catch (\Exception $e) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should never catch Throwable unless reasons which should be explicit/obvious

From "web-token/jwt-checker":
The parameter "$clock" will become mandatory in 4.0.0. Please set a valid PSR Clock implementation instead of "null".
@nicolas-grekas nicolas-grekas merged commit 2654e7b into symfony:6.3 May 30, 2023
@nicolas-grekas nicolas-grekas deleted the oidc-clock branch May 30, 2023 17:30
@fabpot fabpot mentioned this pull request May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants