8000 GuardAuthenticator implementation for Symfony 2.8 and later by niels-nijens · Pull Request #75 · auth0/symfony · GitHub
[go: up one dir, main page]

Skip to content

GuardAuthenticator implementation for Symfony 2.8 and later #75

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 10 commits into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change Response::HTTP_FORBIDDEN to JsonResponse::HTTP_UNAUTHORIZED in…
… JwtGuardAuthenticator
  • Loading branch information
niels-nijens committed Sep 24, 2019
commit 4a51efe10859bf6d965ab835eca12a7cf9264a59
2 changes: 1 addition & 1 deletion Tests/Security/Guard/JwtGuardAuthenticatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public function testOnAuthenticationFailure()
$response = $this->guardAuthenticator->onAuthenticationFailure($request, $exception);

$this->assertInstanceOf(JsonResponse::class, $response);
$this->assertSame(JsonResponse::HTTP_FORBIDDEN, $response->getStatusCode());
$this->assertSame(JsonResponse::HTTP_UNAUTHORIZED, $response->getStatusCode());
$this->assertJsonStringEqualsJsonString(
'{"message": "Authentication failed: Malformed token."}',
$response->getContent()
Expand Down
5 changes: 2 additions & 3 deletions src/Security/Guard/JwtGuardAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Auth0\SDK\Exception\CoreException;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\User\User;
Expand Down Expand Up @@ -142,7 +141,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
),
);

return new JsonResponse($responseBody, Response::HTTP_FORBIDDEN);
return new JsonResponse($responseBody, JsonResponse::HTTP_UNAUTHORIZED);
}

/**
Expand All @@ -159,7 +158,7 @@ public function start(Request $request, AuthenticationException $authenticationE
'message' => 'Authentication required.',
);

return new JsonResponse($responseBody, Response::HTTP_UNAUTHORIZED);
return new JsonResponse($responseBody, JsonResponse::HTTP_UNAUTHORIZED);
}

/**
Expand Down
0