Skip to content

Commit 1210f98

Browse files
committed
Rename IdTokenResponse to TokenResponse
1 parent cc1256d commit 1210f98

File tree

8 files changed

+33
-30
lines changed

8 files changed

+33
-30
lines changed

routing/services/services.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ services:
6464
factory: ['@SimpleSAML\Module\oidc\Factories\Grant\PreAuthCodeGrantFactory', 'build']
6565

6666
# Responses
67-
SimpleSAML\Module\oidc\Server\ResponseTypes\IdTokenResponse:
68-
factory: ['@SimpleSAML\Module\oidc\Factories\IdTokenResponseFactory', 'build']
67+
SimpleSAML\Module\oidc\Server\ResponseTypes\TokenResponse:
68+
factory: ['@SimpleSAML\Module\oidc\Factories\TokenResponseFactory', 'build']
6969

7070
oidc.key.private:
7171
class: League\OAuth2\Server\CryptKey
@@ -81,7 +81,7 @@ services:
8181
SimpleSAML\Module\oidc\Factories\AuthorizationServerFactory:
8282
arguments:
8383
$privateKey: '@oidc.key.private'
84-
SimpleSAML\Module\oidc\Factories\IdTokenResponseFactory:
84+
SimpleSAML\Module\oidc\Factories\TokenResponseFactory:
8585
arguments:
8686
$privateKey: '@oidc.key.private'
8787
SimpleSAML\Module\oidc\Factories\Entities\AccessTokenEntityFactory:

src/Entities/AuthCodeEntity.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ public function getState(): array
7474
'nonce' => $this->getNonce(),
7575
'flow_type' => $this->flowTypeEnum?->value,
7676
'tx_code' => $this->txCode,
77-
'authorization_details' => json_encode($this->authorizationDetails, JSON_THROW_ON_ERROR),
77+
'authorization_details' => is_array($this->authorizationDetails) ?
78+
json_encode($this->authorizationDetails, JSON_THROW_ON_ERROR) :
79+
null,
7880
];
7981
}
8082

src/Factories/AuthorizationServerFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
use SimpleSAML\Module\oidc\Server\Grants\PreAuthCodeGrant;
2828
use SimpleSAML\Module\oidc\Server\Grants\RefreshTokenGrant;
2929
use SimpleSAML\Module\oidc\Server\RequestRules\RequestRulesManager;
30-
use SimpleSAML\Module\oidc\Server\ResponseTypes\IdTokenResponse;
30+
use SimpleSAML\Module\oidc\Server\ResponseTypes\TokenResponse;
3131

3232
class AuthorizationServerFactory
3333
{
@@ -39,7 +39,7 @@ public function __construct(
3939
private readonly AuthCodeGrant $authCodeGrant,
4040
private readonly ImplicitGrant $implicitGrant,
4141
private readonly RefreshTokenGrant $refreshTokenGrant,
42-
private readonly IdTokenResponse $idTokenResponse,
42+
private readonly TokenResponse $tokenResponse,
4343
private readonly RequestRulesManager $requestRulesManager,
4444
private readonly CryptKey $privateKey,
4545
private readonly PreAuthCodeGrant $preAuthCodeGrant,
@@ -54,7 +54,7 @@ public function build(): AuthorizationServer
5454
$this->scopeRepository,
5555
$this->privateKey,
5656
$this->moduleConfig->getEncryptionKey(),
57-
$this->idTokenResponse,
57+
$this->tokenResponse,
5858
$this->requestRulesManager,
5959
);
6060

src/Factories/IdTokenResponseFactory.php renamed to src/Factories/TokenResponseFactory.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
use League\OAuth2\Server\CryptKey;
2020
use SimpleSAML\Module\oidc\ModuleConfig;
2121
use SimpleSAML\Module\oidc\Repositories\UserRepository;
22-
use SimpleSAML\Module\oidc\Server\ResponseTypes\IdTokenResponse;
22+
use SimpleSAML\Module\oidc\Server\ResponseTypes\TokenResponse;
2323
use SimpleSAML\Module\oidc\Services\IdTokenBuilder;
2424

25-
class IdTokenResponseFactory
25+
class TokenResponseFactory
2626
{
2727
public function __construct(
2828
private readonly ModuleConfig $moduleConfig,
@@ -32,15 +32,15 @@ public function __construct(
3232
) {
3333
}
3434

35-
public function build(): IdTokenResponse
35+
public function build(): TokenResponse
3636
{
37-
$idTokenResponse = new IdTokenResponse(
37+
$tokenResponse = new TokenResponse(
3838
$this->userRepository,
3939
$this->idTokenBuilder,
4040
$this->privateKey,
4141
);
42-
$idTokenResponse->setEncryptionKey($this->moduleConfig->getEncryptionKey());
42+
$tokenResponse->setEncryptionKey($this->moduleConfig->getEncryptionKey());
4343

44-
return $idTokenResponse;
44+
return $tokenResponse;
4545
}
4646
}

src/Server/ResponseTypes/IdTokenResponse.php renamed to src/Server/ResponseTypes/TokenResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
* @see https://github.com/steverhoades/oauth2-openid-connect-server/blob/master/src/IdTokenResponse.php
3939
*/
40-
class IdTokenResponse extends BearerTokenResponse implements
40+
class TokenResponse extends BearerTokenResponse implements
4141
// phpcs:ignore
4242
NonceResponseTypeInterface,
4343
// phpcs:ignore

src/Services/Container.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@
5454
use SimpleSAML\Module\oidc\Factories\Grant\ImplicitGrantFactory;
5555
use SimpleSAML\Module\oidc\Factories\Grant\PreAuthCodeGrantFactory;
5656
use SimpleSAML\Module\oidc\Factories\Grant\RefreshTokenGrantFactory;
57-
use SimpleSAML\Module\oidc\Factories\IdTokenResponseFactory;
5857
use SimpleSAML\Module\oidc\Factories\JwksFactory;
5958
use SimpleSAML\Module\oidc\Factories\ProcessingChainFactory;
6059
use SimpleSAML\Module\oidc\Factories\ResourceServerFactory;
6160
use SimpleSAML\Module\oidc\Factories\TemplateFactory;
61+
use SimpleSAML\Module\oidc\Factories\TokenResponseFactory;
6262
use SimpleSAML\Module\oidc\Forms\Controls\CsrfProtection;
6363
use SimpleSAML\Module\oidc\Helpers;
6464
use SimpleSAML\Module\oidc\ModuleConfig;
@@ -98,7 +98,7 @@
9898
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\ScopeRule;
9999
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\StateRule;
100100
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\UiLocalesRule;
101-
use SimpleSAML\Module\oidc\Server\ResponseTypes\IdTokenResponse;
101+
use SimpleSAML\Module\oidc\Server\ResponseTypes\TokenResponse;
102102
use SimpleSAML\Module\oidc\Server\TokenIssuers\RefreshTokenIssuer;
103103
use SimpleSAML\Module\oidc\Server\Validators\BearerTokenValidator;
104104
use SimpleSAML\Module\oidc\Stores\Session\LogoutTicketStoreBuilder;
@@ -438,13 +438,13 @@ public function __construct()
438438
$sessionLogoutTicketStoreBuilder = new LogoutTicketStoreBuilder($sessionLogoutTicketStoreDb);
439439
$this->services[LogoutTicketStoreBuilder::class] = $sessionLogoutTicketStoreBuilder;
440440

441-
$idTokenResponseFactory = new IdTokenResponseFactory(
441+
$tokenResponseFactory = new TokenResponseFactory(
442442
$moduleConfig,
443443
$userRepository,
444444
$this->services[IdTokenBuilder::class],
445445
$privateKey,
446446
);
447-
$this->services[IdTokenResponse::class] = $idTokenResponseFactory->build();
447+
$this->services[TokenResponse::class] = $tokenResponseFactory->build();
448448

449449
$this->services[Helpers::class] = $helpers;
450450

@@ -512,7 +512,7 @@ public function __construct()
512512
$this->services[AuthCodeGrant::class],
513513
$this->services[ImplicitGrant::class],
514514
$this->services[RefreshTokenGrant::class],
515-
$this->services[IdTokenResponse::class],
515+
$this->services[TokenResponse::class],
516516
$requestRuleManager,
517517
$privateKey,
518518
$this->services[PreAuthCodeGrant::class],

tests/unit/src/Entities/AuthCodeEntityTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public function testCanGetState(): void
103103
'nonce' => 'nonce',
104104
'flow_type' => null,
105105
'tx_code' => null,
106+
'authorization_details' => null,
106107
],
107108
);
108109
}

tests/unit/src/Server/ResponseTypes/IdTokenResponseTest.php renamed to tests/unit/src/Server/ResponseTypes/TokenResponseTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
use SimpleSAML\Module\oidc\Factories\Entities\ClaimSetEntityFactory;
3232
use SimpleSAML\Module\oidc\ModuleConfig;
3333
use SimpleSAML\Module\oidc\Repositories\Interfaces\IdentityProviderInterface;
34-
use SimpleSAML\Module\oidc\Server\ResponseTypes\IdTokenResponse;
34+
use SimpleSAML\Module\oidc\Server\ResponseTypes\TokenResponse;
3535
use SimpleSAML\Module\oidc\Services\IdTokenBuilder;
3636
use SimpleSAML\Module\oidc\Services\JsonWebTokenBuilderService;
3737
use SimpleSAML\Module\oidc\Utils\ClaimTranslatorExtractor;
3838

3939
/**
40-
* @covers \SimpleSAML\Module\oidc\Server\ResponseTypes\IdTokenResponse
40+
* @covers \SimpleSAML\Module\oidc\Server\ResponseTypes\TokenResponse
4141
*/
42-
class IdTokenResponseTest extends TestCase
42+
class TokenResponseTest extends TestCase
4343
{
4444
final public const TOKEN_ID = 'tokenId';
4545
final public const ISSUER = 'someIssuer';
@@ -121,26 +121,26 @@ protected function setUp(): void
121121
);
122122
}
123123

124-
protected function prepareMockedInstance(): IdTokenResponse
124+
protected function prepareMockedInstance(): TokenResponse
125125
{
126-
$idTokenResponse = new IdTokenResponse(
126+
$tokenResponse = new TokenResponse(
127127
$this->identityProviderMock,
128128
$this->idTokenBuilder,
129129
$this->privateKey,
130130
);
131131

132-
$idTokenResponse->setNonce(null);
133-
$idTokenResponse->setAuthTime(null);
134-
$idTokenResponse->setAcr(null);
135-
$idTokenResponse->setSessionId(null);
132+
$tokenResponse->setNonce(null);
133+
$tokenResponse->setAuthTime(null);
134+
$tokenResponse->setAcr(null);
135+
$tokenResponse->setSessionId(null);
136136

137-
return $idTokenResponse;
137+
return $tokenResponse;
138138
}
139139

140140
public function testItIsInitializable(): void
141141
{
142142
$this->assertInstanceOf(
143-
IdTokenResponse::class,
143+
TokenResponse::class,
144144
$this->prepareMockedInstance(),
145145
);
146146
}

0 commit comments

Comments
 (0)