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

Appearance settings

Commit 25dd52e

Browse filesBrowse files
bug #59640 [Security] Return null instead of empty username to fix deprecation notice (phasdev)
This PR was merged into the 6.4 branch. Discussion ---------- [Security] Return null instead of empty username to fix deprecation notice | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #59584 | License | MIT `RemoteUserAuthenticator` may return an empty string when extracting a username from the configured `$_SERVER` parameter (e.g. `REMOTE_USER`). An empty username triggers the `User Deprecated: Since symfony/security-http 7.2: Using an empty string as user identifier is deprecated and will throw an exception in Symfony 8.0.` Return `null` instead of empty username to skip authenticator when username is empty and fix Symfony 8 deprecation notice. Commits ------- a8516b7 [Security] Return null instead of empty username to fix deprecation notice
2 parents c33333b + a8516b7 commit 25dd52e
Copy full SHA for 25dd52e

File tree

2 files changed

+2
-1
lines changed
Filter options

2 files changed

+2
-1
lines changed

‎src/Symfony/Component/Security/Http/Authenticator/RemoteUserAuthenticator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Authenticator/RemoteUserAuthenticator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ protected function extractUsername(Request $request): ?string
4545
throw new BadCredentialsException(sprintf('User key was not found: "%s".', $this->userKey));
4646
}
4747

48-
return $request->server->get($this->userKey);
48+
return $request->server->get($this->userKey) ?: null;
4949
}
5050
}

‎src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function testSupportNoUser()
3636
$authenticator = new RemoteUserAuthenticator(new InMemoryUserProvider(), new TokenStorage(), 'main');
3737

3838
$this->assertFalse($authenticator->supports($this->createRequest([])));
39+
$this->assertFalse($authenticator->supports($this->createRequest(['REMOTE_USER' => ''])));
3940
}
4041

4142
public function testSupportTokenStorageWithToken()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.