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

Commitdd6cae4

Browse files
author
Nassim
committed
Improved code of custom authentication provider cookbook article
1 parent8ff4543 commitdd6cae4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎cookbook/security/custom_authentication_provider.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ set an authenticated token in the security context if successful.
138138
try {
139139
$authToken = $this->authenticationManager->authenticate($token);
140140
141-
$this->securityContext->setToken($authToken);
141+
return$this->securityContext->setToken($authToken);
142142
} catch (AuthenticationException $failed) {
143143
// ... you might log something here
144144
@@ -152,6 +152,11 @@ set an authenticated token in the security context if successful.
152152
$event->setResponse($response);
153153
154154
}
155+
156+
// By default deny authorization
157+
$response = new Response();
158+
$response->setStatusCode(403);
159+
$event->setResponse($response);
155160
}
156161
}
157162
@@ -233,6 +238,10 @@ the ``PasswordDigest`` header value matches with the user's password.
233238
if (file_exists($this->cacheDir.'/'.$nonce) && file_get_contents($this->cacheDir.'/'.$nonce) + 300 > time()) {
234239
throw new NonceExpiredException('Previously used nonce detected');
235240
}
241+
// If cache directory does not exist we create it
242+
if ( !is_dir($this->cacheDir) ) {
243+
mkdir($this->cacheDir, 0777, true);
244+
}
236245
file_put_contents($this->cacheDir.'/'.$nonce, time());
237246
238247
// Validate Secret

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp