-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix Authenticator Class (getCredentials) example #7065
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
Changes from 4 commits
234d537
a5832a2
df4266e
90de243
ebb8153
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,14 +164,18 @@ This requires you to implement six methods:: | |
| class TokenAuthenticator extends AbstractGuardAuthenticator | ||
| { | ||
| /** | ||
| * Called on every request. Return whatever credentials you want, | ||
| * or null to stop authentication. | ||
| * Called on every request. Return whatever credentials you want to | ||
| * be passed to getUser(). Returning null will cause this authenticator | ||
| * to be skipped. | ||
| */ | ||
| public function getCredentials(Request $request) | ||
| { | ||
| if (!$token = $request->headers->get('X-AUTH-TOKEN')) { | ||
| // no token? Return null and no other methods will be called | ||
| return; | ||
| // No token? | ||
| // Throwing an exception will cause authentication | ||
| // to fail and prevent other authenticators from | ||
|
||
| // attempting to authenticate. | ||
| throw new AuthenticationException('No token provided.'); | ||
|
||
| } | ||
|
|
||
| // What you return here will be passed to getUser() as $credentials | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.