Skip to content

Commit 913962e

Browse files
committed
Use already resolved client for authentication
1 parent 3a7f255 commit 913962e

File tree

4 files changed

+6
-15
lines changed

4 files changed

+6
-15
lines changed

src/Server/RequestRules/Rules/MaxAgeRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function checkRule(
9292
$loginParams['ReturnTo'] = (new HTTP())
9393
->addURLParameters((new HTTP())->getSelfURLNoQuery(), $requestParams);
9494

95-
$this->authenticationService->authenticate($request, $loginParams);
95+
$this->authenticationService->authenticate($client, $loginParams);
9696
}
9797

9898
return new Result($this->getKey(), $lastAuth);

src/Server/RequestRules/Rules/PromptRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function checkRule(
8686
$loginParams['ReturnTo'] = (new HTTP())
8787
->addURLParameters((new HTTP())->getSelfURLNoQuery(), $requestParams);
8888

89-
$this->authenticationService->authenticate($request, $loginParams);
89+
$this->authenticationService->authenticate($client, $loginParams);
9090
}
9191

9292
return null;

src/Services/AuthenticationService.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function processRequest(
9696
$this->authSourceId = $authSimple->getAuthSource()->getAuthId();
9797

9898
if (! $authSimple->isAuthenticated()) {
99-
$this->authenticate($request);
99+
$this->authenticate($oidcClient);
100100
} elseif ($this->sessionService->getIsAuthnPerformedInPreviousRequest()) {
101101
$this->sessionService->setIsAuthnPerformedInPreviousRequest(false);
102102

@@ -268,23 +268,17 @@ public function getSessionId(): ?string
268268
}
269269

270270
/**
271-
* @param ServerRequestInterface $request
272-
* @param array $loginParams
273-
*
274-
* @return void
275271
* @throws Error\BadRequest
276272
* @throws Error\NotFound
277273
* @throws \JsonException
278274
* @throws \SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException
279275
*/
280276

281277
public function authenticate(
282-
ServerRequestInterface $request,
278+
ClientEntityInterface $clientEntity,
283279
array $loginParams = [],
284280
): void {
285-
// TODO mivanci Fix: client has already been resolved up to this point, but we are again fetching it from DB.
286-
$oidcClient = $this->helpers->client()->getFromRequest($request, $this->clientRepository);
287-
$authSimple = $this->authSimpleFactory->build($oidcClient);
281+
$authSimple = $this->authSimpleFactory->build($clientEntity);
288282

289283
$this->sessionService->setIsCookieBasedAuthn(false);
290284
$this->sessionService->setIsAuthnPerformedInPreviousRequest(true);

tests/unit/src/Services/AuthenticationServiceTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,8 @@ public function testGetAuthenticateUserItThrowsIfClaimsNotExist(): void
331331
public function testItAuthenticates(): void
332332
{
333333
$this->authSimpleMock->expects($this->once())->method('login')->with([]);
334-
$this->clientHelperMock->expects($this->once())
335-
->method('getFromRequest')
336-
->willReturn($this->clientEntityMock);
337334

338-
$this->mock()->authenticate($this->serverRequestMock);
335+
$this->mock()->authenticate($this->clientEntityMock);
339336
}
340337

341338
/**

0 commit comments

Comments
 (0)