mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
NEW: Replace AuthenticationRequestFilter with AuthenticationMiddleware
This commit is contained in:
parent
e855622890
commit
254204a3a6
@ -19,14 +19,13 @@ SilverStripe\Core\Injector\Injector:
|
||||
---
|
||||
Name: coresecurity
|
||||
---
|
||||
SilverStripe\Control\Director:
|
||||
middlewares:
|
||||
- %$SilverStripe\Security\AuthenticationMiddleware
|
||||
SilverStripe\Core\Injector\Injector:
|
||||
SilverStripe\Security\AuthenticationRequestFilter:
|
||||
SilverStripe\Security\AuthenticationMiddleware:
|
||||
properties:
|
||||
AuthenticationHandler: %$SilverStripe\Security\AuthenticationHandler
|
||||
SilverStripe\Control\RequestProcessor:
|
||||
properties:
|
||||
filters:
|
||||
- %$SilverStripe\Security\AuthenticationRequestFilter
|
||||
SilverStripe\Security\Security:
|
||||
properties:
|
||||
Authenticators:
|
||||
|
@ -5,11 +5,11 @@ namespace SilverStripe\Security;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Control\RequestFilter;
|
||||
use SilverStripe\Control\HTTPMiddleware;
|
||||
use SilverStripe\Core\Config\Configurable;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
|
||||
class AuthenticationRequestFilter implements RequestFilter
|
||||
class AuthenticationMiddleware implements HTTPMiddleware
|
||||
{
|
||||
use Configurable;
|
||||
|
||||
@ -43,32 +43,21 @@ class AuthenticationRequestFilter implements RequestFilter
|
||||
* @return bool|void
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
public function preRequest(HTTPRequest $request)
|
||||
public function process(HTTPRequest $request, callable $delegate)
|
||||
{
|
||||
if (!Security::database_is_ready()) {
|
||||
return;
|
||||
if (Security::database_is_ready()) {
|
||||
try {
|
||||
$this
|
||||
->getAuthenticationHandler()
|
||||
->authenticateRequest($request);
|
||||
} catch (ValidationException $e) {
|
||||
return new HTTPResponse(
|
||||
"Bad log-in details: " . $e->getMessage(),
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$this
|
||||
->getAuthenticationHandler()
|
||||
->authenticateRequest($request);
|
||||
} catch (ValidationException $e) {
|
||||
throw new HTTPResponse_Exception(
|
||||
"Bad log-in details: " . $e->getMessage(),
|
||||
400
|
||||
);
|
||||
}
|
||||
return $delegate($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op
|
||||
*
|
||||
* @param HTTPRequest $request
|
||||
* @param HTTPResponse $response
|
||||
* @return bool|void
|
||||
*/
|
||||
public function postRequest(HTTPRequest $request, HTTPResponse $response)
|
||||
{
|
||||
}
|
||||
}
|
@ -415,7 +415,7 @@ class Member extends DataObject
|
||||
*/
|
||||
public function beforeMemberLoggedIn()
|
||||
{
|
||||
// @todo Move to middleware on the AuthenticationRequestFilter IdentityStore
|
||||
// @todo Move to middleware on the AuthenticationMiddleware IdentityStore
|
||||
$this->extend('beforeMemberLoggedIn');
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user