Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Security] Add ability for authenticators to explain why they didn’t support a request#60538

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
MatTheCat wants to merge2 commits intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromMatTheCat:authenticator-support-reason

Conversation

MatTheCat
Copy link
Contributor

@MatTheCatMatTheCat commentedMay 25, 2025
edited by OskarStark
Loading

QA
Branch?7.4
Bug fix?no
New feature?yes
Deprecations?no
IssuesN/A
LicenseMIT

Inspired by#59771 this PR allows authenticators to advertise why they didn’t support a request by passing a newRequestSupport argument to theirsupports method. Calling itsaddReason method will cause the profiler to display them:

If this is accepted, this will pave the way for firewall listeners to expose informations about their calls tosupports (this is why theRequestSupport class also holds$result and$lazy properties) andauthenticate, thus closing#36668.

OskarStark reacted with heart emoji
@carsonbotcarsonbot added this to the7.3 milestoneMay 25, 2025
@MatTheCatMatTheCat changed the title[Security] Add ability for authenticators to explain why they support the request or not[Security] Add ability for authenticators to explain why they supported the request or notMay 25, 2025
@MatTheCatMatTheCatforce-pushed theauthenticator-support-reason branch 2 times, most recently froma175f93 tob0cdff7CompareMay 25, 2025 13:20
@@ -11,6 +11,7 @@ CHANGELOG
* Add support for closures in `#[IsGranted]`
* Add `OAuth2TokenHandler` with OAuth2 Token Introspection support for `AccessTokenAuthenticator`
* Add discovery support to `OidcTokenHandler` and `OidcUserInfoTokenHandler`
* Add ability for authenticators to explain why they support the request or not
Copy link
Contributor

@OskarStarkOskarStarkMay 25, 2025
edited
Loading

Choose a reason for hiding this comment

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

Suggested change
* Add ability for authenticators to explain why they support the request or not
* Add ability for authenticators to explain why theydo notsupport the request

If they support it, no reason is set, right?

Copy link
Member

Choose a reason for hiding this comment

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

s/does/do

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated, thanks

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

If they support it, no reason is set, right?

I was not sure if the userland could benefit from it, but since it is only displayed when the authenticator doesn’t support the request let’s not advertise it indeed.

OskarStark reacted with thumbs up emoji
@MatTheCatMatTheCat changed the title[Security] Add ability for authenticators to explain why they supported the request or not[Security] Add ability for authenticators to explain why they didn’t support a requestMay 26, 2025
@MatTheCatMatTheCatforce-pushed theauthenticator-support-reason branch 6 times, most recently from12f9679 tocc4097bCompareMay 26, 2025 13:15
@alexandre-daubois

This comment has been minimized.

@MatTheCat

This comment has been minimized.

@fabpotfabpot modified the milestones:7.3,7.4May 26, 2025
@MatTheCatMatTheCatforce-pushed theauthenticator-support-reason branch 4 times, most recently from541085e to66af8a6CompareMay 30, 2025 10:01
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

Nice :)

I'm just wondering about the name. What aboutRequestDecision instead?

@MatTheCat
Copy link
ContributorAuthor

I'm just wondering about the name. What aboutRequestDecision instead?

Why not; then what about

  • the parameter’s name?$requestDecision? Or just$decision?
  • TraceableAuthenticator’s property? Still$supportReasons?

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedMay 30, 2025
edited
Loading

It'd say $requestDecision and $decisionReasons.
(One could also use addReason to explain why they decided to ACCEPT the request, isn't it?)

@MatTheCat
Copy link
ContributorAuthor

MatTheCat commentedMay 30, 2025
edited
Loading

One could also use addReason to explain why they decided to ACCEPT the request, isn't it?

It wouldn’t serve any purpose in the current state of this PR but yes.

The problem I have with$decisionReasons is that it doesn’t mention the decision is about request support (could also be about authentication).

@nicolas-grekas
Copy link
Member

$requestDecisionReasons?

@MatTheCatMatTheCatforce-pushed theauthenticator-support-reason branch fromf4ade34 to0cecef5CompareMay 30, 2025 16:23
@MatTheCat
Copy link
ContributorAuthor

Fine by me; just pushed the changes.

@MatTheCatMatTheCatforce-pushed theauthenticator-support-reason branch from0cecef5 to9bdf856CompareMay 30, 2025 16:26
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

One more iteration :)

class RequestDecision
{
publicbool$support;
public ?bool$lazy =null;

Choose a reason for hiding this comment

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

when is this used? what could be built with that?

Suggested change
public?bool$lazy =null;
public bool$isLazy;

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I planned to use this class for firewall listeners.

Choose a reason for hiding this comment

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

Oh, so let's remove it from this PR and add it in the one about listeners then.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Should theTraceableAuthenticator set them then?

Comment on lines 78 to 83
if ($this->supports === false) {
$requestDecision->support = false;
} else {
$requestDecision->support = true;
$requestDecision->lazy = null === $this->supports;
}

Choose a reason for hiding this comment

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

Suggested change
if ($this->supports ===false) {
$requestDecision->support =false;
}else {
$requestDecision->support =true;
$requestDecision->lazy =null ===$this->supports;
}
$requestDecision->isSupported =false !==$this->supports;
$requestDecision->isLazy =null ===$this->supports;

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I thinkisLazy should staynull if the request is not supported.

Choose a reason for hiding this comment

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

the decision was not lazy, so why?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Causelazy only makes sense if the request is supported.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

BTW it is not the decision which is lazy but the request support; not sure about this naming then 🤔

@MatTheCatMatTheCatforce-pushed theauthenticator-support-reason branch from9bdf856 tof7520a5CompareMay 30, 2025 16:38
@MatTheCatMatTheCatforce-pushed theauthenticator-support-reason branch fromf7520a5 to50a70cbCompareMay 30, 2025 16:39
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@OskarStarkOskarStarkOskarStark left review comments

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

7 participants
@MatTheCat@alexandre-daubois@nicolas-grekas@OskarStark@chalasr@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp