forked from symfony/symfony
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add security.firewalls.not_full_fledged_handler option
if not authenticated at all
- Loading branch information
Showing
13 changed files
with
255 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/Symfony/Component/Security/Http/Authorization/NotFullFledgedHandlerInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Security\Http\Authorization; | ||
|
||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Security\Core\Exception\AccessDeniedException; | ||
|
||
/** | ||
* This is used by the ExceptionListener to translate an AccessDeniedException | ||
* to a Response object. | ||
* | ||
* @author Roman JOLY <[email protected]> | ||
*/ | ||
interface NotFullFledgedHandlerInterface | ||
{ | ||
/** | ||
* Handles a not full fledged case for acces denied failure. | ||
* @return bool|Response : bool|Response | ||
* true : user have to be fully authenticated, continu to startAuthentication | ||
* false : user have'nt to be fully authenticated, throw original AcessDeniedException | ||
* Response: you can return your own response, AccesDeniedException wil be ignored | ||
*/ | ||
public function handle(Request $request, AccessDeniedException $accessDeniedException): bool|Response; | ||
} |
37 changes: 37 additions & 0 deletions
37
src/Symfony/Component/Security/Http/Authorization/SameAsNotFullFledgedHandle.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Security\Http\Authorization; | ||
|
||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter; | ||
use Symfony\Component\Security\Core\Exception\AccessDeniedException; | ||
|
||
/** | ||
* This is a basic NotFullFledgedHandle | ||
* If IS_AUTHENTICATED_FULLY is in access denied Exception Attrribute, behavior will be as before, | ||
* Otherwise The original AccessDeniedException is throw | ||
* | ||
* @author Roman JOLY <[email protected]> | ||
*/ | ||
class SameAsNotFullFledgedHandle implements NotFullFledgedHandlerInterface | ||
{ | ||
public function handle(Request $request, AccessDeniedException $accessDeniedException): bool|Response | ||
{ | ||
foreach($accessDeniedException->getAttributes() as $attribute) { | ||
if(in_array($attribute, [AuthenticatedVoter::IS_AUTHENTICATED_FULLY])) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.