Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Security] Add a ChainUserChecker to allow calling multiple user checkers for a firewall #46064

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
Sep 13, 2022

Conversation

mbabker
Copy link
Contributor

@mbabker mbabker commented Apr 15, 2022

Q A
Branch? 6.2
Bug fix? no
New feature? yes
Deprecations? no
Tickets N/A
License MIT
Doc PR TODO

I had a case in one of my apps where I have some shared logic for user checkers across multiple firewalls (API and traditional web login) while also needing extra logic for the API. Instead of duplicating the checker for each firewall or using a decorator, I thought a chained user checker would be nice to have and that it might be useful to users of the framework.

This will add a ChainUserChecker class to the security-core component, and the SecurityBundle will create a security.user_checker.chain.<firewall> service for each firewall. User checkers can then be tagged with a security.user_checker.<firewall> tag for each firewall the checker applies to, and users would set this chain service as the user checker for their firewall.

<?php

namespace App\Security\User;

use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
use Symfony\Component\Security\Core\User\UserCheckerInterface;

#[Autoconfigure(tags: [['security.user_checker.main' => ['priority' => 10]]])]
#[Autoconfigure(tags: [['security.user_checker.api' => ['priority' => 10]]])]
final class DisabledAccountUserChecker implements UserCheckerInterface {}

#[Autoconfigure(tags: [['security.user_checker.api' => ['priority' => 5]]])]
final class ApiAccessAllowedUserChecker implements UserCheckerInterface {}

@mbabker mbabker requested review from wouterj and chalasr as code owners April 15, 2022 16:32
@carsonbot carsonbot added this to the 6.1 milestone Apr 15, 2022
@mbabker mbabker force-pushed the chained-user-checker branch 2 times, most recently from b79f4f8 to fdf2d0f Compare April 15, 2022 16:34
@carsonbot carsonbot changed the title Add a ChainUserChecker to allow calling multiple user checkers for a firewall [Security] Add a ChainUserChecker to allow calling multiple user checkers for a firewall Apr 15, 2022
@derrabus derrabus modified the milestones: 6.1, 6.2 Apr 15, 2022
@mbabker mbabker force-pushed the chained-user-checker branch from fdf2d0f to 4661374 Compare April 15, 2022 17:14
@OskarStark OskarStark changed the title [Security] Add a ChainUserChecker to allow calling multiple user checkers for a firewall [Security] Add a ChainUserChecker to allow calling multiple user checkers for a firewall Apr 25, 2022
@mbabker mbabker force-pushed the chained-user-checker branch from 4661374 to e111ec8 Compare June 7, 2022 23:27
@mbabker mbabker force-pushed the chained-user-checker branch from e111ec8 to d5aef06 Compare July 22, 2022 14:55
@mbabker mbabker force-pushed the chained-user-checker branch from d5aef06 to 23fbfe1 Compare August 5, 2022 18:20
@mbabker mbabker force-pushed the chained-user-checker branch 2 times, most recently from 1b73f8f to 711b918 Compare September 6, 2022 13:33
@mbabker mbabker force-pushed the chained-user-checker branch from 711b918 to 0a1ad4b Compare September 12, 2022 23:37
@fabpot
Copy link
Member

fabpot commented Sep 13, 2022

Thank you @mbabker.

@mbabker mbabker deleted the chained-user-checker branch September 13, 2022 11:20
@fabpot fabpot mentioned this pull request Oct 24, 2022
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.

6 participants