mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-12-12 13:33:46 +08:00
Merge branch 'oidc-content-type-issue' into development
Some checks failed
analyse-php / build (push) Has been cancelled
lint-php / build (push) Has been cancelled
test-php / build (8.1) (push) Has been cancelled
test-php / build (8.2) (push) Has been cancelled
test-migrations / build (8.1) (push) Has been cancelled
test-migrations / build (8.2) (push) Has been cancelled
test-migrations / build (8.3) (push) Has been cancelled
test-php / build (8.3) (push) Has been cancelled
Some checks failed
analyse-php / build (push) Has been cancelled
lint-php / build (push) Has been cancelled
test-php / build (8.1) (push) Has been cancelled
test-php / build (8.2) (push) Has been cancelled
test-migrations / build (8.1) (push) Has been cancelled
test-migrations / build (8.2) (push) Has been cancelled
test-migrations / build (8.3) (push) Has been cancelled
test-php / build (8.3) (push) Has been cancelled
This commit is contained in:
commit
978acecdcf
|
@ -11,7 +11,9 @@ class OidcUserinfoResponse implements ProvidesClaims
|
|||
|
||||
public function __construct(ResponseInterface $response, string $issuer, array $keys)
|
||||
{
|
||||
$contentType = $response->getHeader('Content-Type')[0];
|
||||
$contentTypeHeaderValue = $response->getHeader('Content-Type')[0] ?? '';
|
||||
$contentType = strtolower(trim(explode(';', $contentTypeHeaderValue, 2)[0]));
|
||||
|
||||
if ($contentType === 'application/json') {
|
||||
$this->claims = json_decode($response->getBody()->getContents(), true);
|
||||
}
|
||||
|
|
|
@ -787,6 +787,20 @@ class OidcTest extends TestCase
|
|||
$this->assertTrue($user->hasRole($roleA->id));
|
||||
}
|
||||
|
||||
public function test_userinfo_endpoint_response_with_complex_json_content_type_handled()
|
||||
{
|
||||
$userinfoResponseData = [
|
||||
'sub' => OidcJwtHelper::defaultPayload()['sub'],
|
||||
'name' => 'Barry',
|
||||
];
|
||||
$userinfoResponse = new Response(200, ['Content-Type' => 'Application/Json ; charset=utf-8'], json_encode($userinfoResponseData));
|
||||
$resp = $this->runLogin(['name' => null], [$userinfoResponse]);
|
||||
$resp->assertRedirect('/');
|
||||
|
||||
$user = User::where('email', OidcJwtHelper::defaultPayload()['email'])->first();
|
||||
$this->assertEquals('Barry', $user->name);
|
||||
}
|
||||
|
||||
public function test_userinfo_endpoint_jwks_response_handled()
|
||||
{
|
||||
$userinfoResponseData = OidcJwtHelper::idToken(['name' => 'Barry Jwks']);
|
||||
|
|
Loading…
Reference in New Issue
Block a user