Skip to content

Commit 331cffc

Browse files
committed
Rename back authentication_result with authenticated_with
1 parent ba8fe88 commit 331cffc

8 files changed

+25
-25
lines changed

composer.lock

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Adapter/AdapterInterface.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface AdapterInterface
2121
* Initialize authentication layer and see if we have a user who's already logged in.
2222
*
2323
* @param ServerRequestInterface $request
24-
* @return array|null Example:['authenticated_user' => AuthenticatedUserInterface, 'authentication_result' => AuthenticationResultInterface];
24+
* @return array|null Example:['authenticated_user' => AuthenticatedUserInterface, 'authenticated_with' => AuthenticationResultInterface];
2525
*/
2626
public function initialize(ServerRequestInterface $request);
2727

@@ -36,7 +36,7 @@ public function authenticate(AuthenticatedUserInterface $authenticated_user);
3636
/**
3737
* Terminate an instance that was used to authenticate a user.
3838
*
39-
* @param AuthenticationResultInterface $authentication_result
39+
* @param AuthenticationResultInterface $authenticated_with
4040
*/
41-
public function terminate(AuthenticationResultInterface $authentication_result);
41+
public function terminate(AuthenticationResultInterface $authenticated_with);
4242
}

src/Adapter/BrowserSession.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function initialize(ServerRequestInterface $request)
7878
if ($user = $session->getAuthenticatedUser($this->user_repository)) {
7979
$this->session_repository->recordUsageBySession($session);
8080

81-
return ['authenticated_user' => $user, 'authentication_result' => $session];
81+
return ['authenticated_user' => $user, 'authenticated_with' => $session];
8282
}
8383
}
8484

@@ -96,10 +96,10 @@ public function authenticate(AuthenticatedUserInterface $authenticated_user)
9696
/**
9797
* {@inheritdoc}
9898
*/
99-
public function terminate(AuthenticationResultInterface $authentication_result)
99+
public function terminate(AuthenticationResultInterface $authenticated_with)
100100
{
101-
if ($authentication_result instanceof SessionInterface) {
102-
$this->session_repository->terminateSession($authentication_result);
101+
if ($authenticated_with instanceof SessionInterface) {
102+
$this->session_repository->terminateSession($authenticated_with);
103103
} else {
104104
throw new InvalidArgumentException('Instance is not a browser session');
105105
}

src/Adapter/TokenBearer.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function initialize(ServerRequestInterface $request)
6363
if ($user = $token->getAuthenticatedUser($this->user_repository)) {
6464
$this->token_repository->recordUsageByToken($token);
6565

66-
return ['authenticated_user' => $user, 'authentication_result' => $token];
66+
return ['authenticated_user' => $user, 'authenticated_with' => $token];
6767
}
6868
}
6969

@@ -81,10 +81,10 @@ public function authenticate(AuthenticatedUserInterface $authenticated_user)
8181
/**
8282
* {@inheritdoc}
8383
*/
84-
public function terminate(AuthenticationResultInterface $authentication_result)
84+
public function terminate(AuthenticationResultInterface $authenticated_with)
8585
{
86-
if ($authentication_result instanceof TokenInterface) {
87-
$this->token_repository->terminateToken($authentication_result);
86+
if ($authenticated_with instanceof TokenInterface) {
87+
$this->token_repository->terminateToken($authenticated_with);
8888
} else {
8989
throw new InvalidArgumentException('Instance is not a token');
9090
}

src/Authentication.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ public function __construct(array $adapters)
4242
public function initialize(RequestInterface $request)
4343
{
4444
$exception = null;
45-
$results = ['authenticated_user' => [], 'authentication_result' => []];
45+
$results = ['authenticated_user' => [], 'authenticated_with' => []];
4646

4747
foreach ($this->adapters as $adapter) {
4848
try {
4949
$result = $adapter->initialize($request);
5050
if ($result) {
5151
$results['authenticated_user'][] = $result['authenticated_user'];
52-
$results['authentication_result'][] = $result['authentication_result'];
52+
$results['authenticated_with'][] = $result['authenticated_with'];
5353
}
5454
} catch (Exception $e) {
5555
$exception = $e;
@@ -70,7 +70,7 @@ public function initialize(RequestInterface $request)
7070

7171
return $request
7272
->withAttribute('authenticated_user', $results['authenticated_user'][0])
73-
->withAttribute('authentication_result', $results['authentication_result'][0]);
73+
->withAttribute('authenticated_with', $results['authenticated_with'][0]);
7474
}
7575

7676
/**

test/src/AuthenticationTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ public function testUserIsAuthorized()
114114

115115
$authentication = new Authentication([$token_bearer]);
116116
$request = $authentication->initialize($this->request);
117-
$authentication_result = $authentication->authorize($this->authorizer, $token_bearer, ['username' => '[email protected]']);
117+
$authenticated_with = $authentication->authorize($this->authorizer, $token_bearer, ['username' => '[email protected]']);
118118

119-
$this->assertInstanceOf(AuthenticationResultInterface::class, $authentication_result);
119+
$this->assertInstanceOf(AuthenticationResultInterface::class, $authenticated_with);
120120
}
121121
}

test/src/BrowserSessionInitializeTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testAuthenticationWithGoodSessionId()
6262
$results = (new BrowserSession($user_repository, $session_repository, $this->cookies))->initialize($this->request);
6363

6464
$this->assertInstanceOf(AuthenticatedUser::class, $results['authenticated_user']);
65-
$this->assertInstanceOf(Session::class, $results['authentication_result']);
65+
$this->assertInstanceOf(Session::class, $results['authenticated_with']);
6666
}
6767

6868
/**
@@ -82,7 +82,7 @@ public function testAuthenticationRecordsSessionUsage()
8282
$results = (new BrowserSession($user_repository, $session_repository, $this->cookies))->initialize($this->request);
8383

8484
$this->assertInstanceOf(AuthenticatedUser::class, $results['authenticated_user']);
85-
$this->assertInstanceOf(Session::class, $results['authentication_result']);
85+
$this->assertInstanceOf(Session::class, $results['authenticated_with']);
8686

8787
$this->assertSame(1, $session_repository->getUsageById($test_session_id));
8888
}

test/src/TokenBearerInitializeTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testAuthenticationWithGoodToken()
6565
$results = (new TokenBearer($user_repository, $token_repository))->initialize($this->request->withHeader('Authorization', "Bearer {$test_token}"));
6666

6767
$this->assertInstanceOf(AuthenticatedUser::class, $results['authenticated_user']);
68-
$this->assertInstanceOf(Token::class, $results['authentication_result']);
68+
$this->assertInstanceOf(Token::class, $results['authenticated_with']);
6969
}
7070

7171
/**
@@ -83,7 +83,7 @@ public function testAuthenticationRecordsTokenUsage()
8383
$results = (new TokenBearer($user_repository, $token_repository))->initialize($this->request->withHeader('Authorization', "Bearer {$test_token}"));
8484

8585
$this->assertInstanceOf(AuthenticatedUser::class, $results['authenticated_user']);
86-
$this->assertInstanceOf(Token::class, $results['authentication_result']);
86+
$this->assertInstanceOf(Token::class, $results['authenticated_with']);
8787

8888
$this->assertSame(1, $token_repository->getUsageById($test_token));
8989
}

0 commit comments

Comments
 (0)