Skip to content

Commit

Permalink
Merge "UserStatementProvider: Cast 'sub' to be a string"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Dec 21, 2024
2 parents c309aa7 + f6c6be3 commit e2274d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/UserStatementProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public function getUserStatement() {
*/
public function getUserProfile() {
$profile = [
'sub' => Utils::getCentralIdFromLocalUser( $this->user ),
// 'sub' should be a StringOrURI - https://www.rfc-editor.org/rfc/rfc7519.html#section-4.1.2
'sub' => (string)Utils::getCentralIdFromLocalUser( $this->user ),
];
// Include some MediaWiki info about the user
if ( !$this->user->isHidden() ) {
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/UserStatementProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testGetUserStatement() {
$userProfile = $userStatementProvider->getUserProfile();

foreach ( [ $userStatement, $userProfile ] as $data ) {
$this->assertSame( $user->getId(), $data['sub'] );
$this->assertSame( (string)$user->getId(), $data['sub'] );
$this->assertSame( $user->getName(), $data['username'] );
$this->assertSame( 0, $data['editcount'] );
$this->assertSame( false, $data['confirmed_email'] );
Expand Down

0 comments on commit e2274d5

Please sign in to comment.