fix API login in subdirectory installations (#1181)

This commit is contained in:
Kevin Papst
2019-10-24 11:06:12 +02:00
committed by GitHub
parent 330ff6eb47
commit b4a45afce9

View File

@@ -45,11 +45,13 @@ class TokenAuthenticator extends AbstractGuardAuthenticator
*/ */
public function supports(Request $request) public function supports(Request $request)
{ {
if (strpos($request->getRequestUri(), '/api/doc') === 0) { // API docs can only be access, when the user is logged in
if (strpos($request->getRequestUri(), '/api/doc') !== false) {
return false; return false;
} }
if (strpos($request->getRequestUri(), '/api/') === 0) { // only try to use this authenticator, when the URL contains the /api/ path
if (strpos($request->getRequestUri(), '/api/') !== false) {
// javascript requests can set a header to disable this authenticator and use the existing session // javascript requests can set a header to disable this authenticator and use the existing session
return !$request->headers->has(self::HEADER_JAVASCRIPT); return !$request->headers->has(self::HEADER_JAVASCRIPT);
} }