Skip to content

Commit 1d8f4b3

Browse files
authored
Deprecate the BearerToken trait (#73)
1 parent fb793be commit 1d8f4b3

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212

1313
### Changed
1414
- Internal refactoring
15+
16+
### Deprecated
1517
- Deprecate use of base RequestInterface (#48)
1618
- If a RequestInterface object is provided to the dispatcher, it will be internally converted to a ServerRequestInterface to ensure compatibility with Middleware and error handling.
1719
Relying on this functionality is deprecated from the start, **highly** discouraged, and may be imperfect.
20+
- Deprecated the `BearerToken` authentication trait
1821

1922
## [3.0.6] - 2018-04-30
2023
### Changed

src/Traits/Authentication/BearerToken.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
* itself, since it's unaware of the application at large. This just parses the
1818
* HTTP request and extracts the bearer token, handling invalid or missing
1919
* values. Provide said handler with `setHandleBearerTokenCallback()`.
20+
*
21+
* @deprecated - this will be removed in 4.0.0, in favor of the new
22+
* authenticaton and authorization tools.
2023
*/
2124
trait BearerToken
2225
{
@@ -25,6 +28,10 @@ trait BearerToken
2528

2629
public function authenticate(RequestInterface $request): EndpointInterface
2730
{
31+
trigger_error(
32+
'BearerToken will be removed in 4.0.0. Use the new authentication tools instead.',
33+
\E_USER_DEPRECATED
34+
);
2835
if (!$this->handleBearerTokenCallback) {
2936
throw new BadMethodCallException(
3037
'There is no callback to handle the Bearer token. Call '.

tests/Traits/Authentication/BearerTokenTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ class BearerTokenTest extends \PHPUnit\Framework\TestCase
2121
private $calledWithEndpoint;
2222
private $calledWithToken;
2323

24+
private $reporting;
25+
26+
public function setUp()
27+
{
28+
$this->reporting = error_reporting();
29+
error_reporting($this->reporting & ~E_USER_DEPRECATED);
30+
}
31+
32+
public function tearDown()
33+
{
34+
error_reporting($this->reporting);
35+
}
36+
2437
/**
2538
* @covers ::authenticate
2639
* @covers ::setHandleBearerTokenCallback

0 commit comments

Comments
 (0)