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

[Bridge][Twig] Decouple the SecurityExtension from its runtime#24692

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

Closed
CarsonF wants to merge2 commits intosymfony:3.4fromCarsonF:bugfix/twig-security-runtime
Closed

[Bridge][Twig] Decouple the SecurityExtension from its runtime#24692

CarsonF wants to merge2 commits intosymfony:3.4fromCarsonF:bugfix/twig-security-runtime

Conversation

@CarsonF
Copy link
Contributor

@CarsonFCarsonF commentedOct 25, 2017
edited
Loading

QA
Branch?3.4
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsN/A
LicenseMIT
Doc PRN/A

This indirectly fixes two bugs in Silex regarding Security and Twig.

The first is iftwig is loaded beforeboot() some services/parameters are not defined.

  • twig asks forsecurity.authorization_checker
  • security.authorization_checker asks forsecurity.authentication_manager
  • security.authentication_manager asks forsecurity.authentication_providers
  • security.authentication_providers are not completely defined untilsecurity.firewall_map is loaded (here).

I fixed this locally by wrapping thesecurity.authorization_checker service and loading thesecurity.firewall_map before hand:

// Load firewall map before this, because it defines a dependency needed.$factory =$app->raw('security.authorization_checker');$app['security.authorization_checker'] =function ($app)use ($factory) {$app['security.firewall_map'];return$factory($app);};

This technically fixed the problem, but it wouldn't be needed if the service wasn't loaded untilboot() where the firewall is loaded by default.


The second problem is a circular dependency. I was implementing an AccessDeniedHandler that rendered a template.

  • security.firewall_map asks for AccessDeniedHandler service
  • AccessDeniedHandler service asks fortwig
  • twig asks forsecurity.firewall_map ....:boom:

And again this wouldn't be a problem iftwig didn't need theSecurityRuntime until it'sis_granted is called.


I don't see this as afeature since it only modifies private services. And Ido see this as abugfix even though it's for Silex and not Symfony. But I know it's a gray area. Twig Runtimes seem to be the way we are heading so I don't think this is a step in the wrong direction either.

I have a PR ready for Silex depending on the direction of this issue. Here's thediff.

sstok reacted with hooray emoji
$this->securityChecker =$securityChecker;
}

publicfunctionisGranted($role,$object =null,$field =null)
Copy link
Member

Choose a reason for hiding this comment

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

This is a BC break, it has to be deprecated first.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Even though it's never called directly only through the twig function?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@fabpot did the same thing without a BC break to HttpKernelExtension
812fbb4

Copy link
Member

@chalasrchalasrOct 25, 2017
edited
Loading

Choose a reason for hiding this comment

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

Anyone extending this class (e.g. to replace the security extension by a custom one relying on these methods) would be broken. IMO it's not acceptable.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I can fix BC break if it really is considered a BC break. I don't want that to be a blocker.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO this is acceptable, for the reason stated: i.e.812fbb4 … namely, this is moving what always should have been to where it, um, should have been … calling it a BC break versus history is just bikeshedding

Copy link
Member

@chalasrchalasrOct 26, 2017
edited
Loading

Choose a reason for hiding this comment

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

Well, it was a BC break, we just accepted it (and merged as a feature, not a bugfix).
There is a lot of classes in the codebase that should not be used as extension points, and we don't change their public API from minor to minor, per semver and our BC promise.
I would flag it as@final (same for other extensions) and stop injecting the authorization checker in the extension service for 4.1, then remove its methods in 5.0. At least the class would remain as is for 4.x.
Let's see what others think

@chalasrchalasr added this to the4.1 milestoneOct 25, 2017
$this->securityChecker =$securityChecker;
}

publicfunctionisGranted($role,$object =null,$field =null)
Copy link
Member

Choose a reason for hiding this comment

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

needs a docblock with@deprecated

@CarsonF
Copy link
ContributorAuthor

Due to Silex being EoL I'm closing this.

@nicolas-grekasnicolas-grekas modified the milestones:next,4.2Nov 1, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@chalasrchalasrchalasr left review comments

+1 more reviewer

@GwendolenLynchGwendolenLynchGwendolenLynch left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

5 participants

@CarsonF@GwendolenLynch@chalasr@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp