Skip to content
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

Use the same issuer in token and discovery responses #24

Merged
merged 7 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 1 addition & 8 deletions src/IdTokenResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,10 @@ protected function getBuilder(
($this->useMicroseconds ? microtime(true) : time())
);

if ($this->currentRequestService) {
$uri = $this->currentRequestService->getRequest()->getUri();
$issuer = $uri->getScheme() . '://' . $uri->getHost() . ($uri->getPort() ? ':' . $uri->getPort() : '');
} else {
$issuer = 'https://' . $_SERVER['HTTP_HOST'];
}

return $this->config
->builder()
->permittedFor($accessToken->getClient()->getIdentifier())
->issuedBy($issuer)
->issuedBy('https://' . $_SERVER['HTTP_HOST'])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should force the https here, we could use the default value from laravel and fallback on https only if missing.
Locally, we may want to work on unsecured connection.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be fair it was 'https://' . $_SERVER['HTTP_HOST'] before #13

->issuedAt($dateTimeImmutableObject)
->expiresAt($dateTimeImmutableObject->add(new DateInterval('PT1H')))
->relatedTo($userEntity->getIdentifier());
Expand Down
5 changes: 4 additions & 1 deletion src/Laravel/DiscoveryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\URL;
use Laravel\Passport\Passport;

class DiscoveryController
Expand All @@ -13,8 +14,10 @@ class DiscoveryController
*/
public function __invoke(Request $request)
{
URL::forceScheme('https'); // for route() calls below

$response = [
'issuer' => url('/'),
'issuer' => 'https://' . $_SERVER['HTTP_HOST'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeremy379 This broke my unit test which was calling it without a HTTP_HOST. Maybe a good idea to fallback on both to route('/'), so also for the Id & Access tokens?

Copy link
Contributor

@bbredewold bbredewold Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@christiaangoossens @jeremy379 Same here. Since this is a Laravel package, I think we need to stop using $_SERVER variables, and use the Request object to obtain the needed urls.

Made an issue #32

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello
I'm sorry for these issue

Request isn't directly available here, so I choose to provide option on how this should be filled.

Here is a fix MR: #33

'authorization_endpoint' => route('passport.authorizations.authorize'),
'token_endpoint' => route('passport.token'),
'grant_types_supported' => $this->getSupportedGrantTypes(),
Expand Down
Loading