Skip to content

Commit 7c62a40

Browse files
committed
Deprecate auth implementations
1 parent 0722468 commit 7c62a40

14 files changed

+266
-22
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@
2929
}
3030
],
3131
"require": {
32-
"php": "^8.2",
32+
"php": "^8.3",
3333
"laravel/framework": "^12.0"
3434
},
3535
"require-dev": {
36+
"google/apiclient": "^2.18",
3637
"aws/aws-sdk-php": "^3.306",
3738
"elasticsearch/elasticsearch": "^8.17",
3839
"jetbrains/phpstorm-attributes": "^1.0",

composer.lock

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

src/Lodash/Auth/Events/StartEmulateEvent.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Longman\LaravelLodash\Auth\Events;
66

7-
use Illuminate\Broadcasting\Channel;
87
use Illuminate\Broadcasting\InteractsWithSockets;
98
use Illuminate\Broadcasting\PrivateChannel;
109
use Illuminate\Foundation\Events\Dispatchable;
@@ -24,7 +23,7 @@ public function __construct(
2423
//
2524
}
2625

27-
public function broadcastOn(): Channel | array
26+
public function broadcastOn(): PrivateChannel
2827
{
2928
return new PrivateChannel('channel-name');
3029
}

src/Lodash/Auth/Events/StopEmulateEvent.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Longman\LaravelLodash\Auth\Events;
66

7-
use Illuminate\Broadcasting\Channel;
87
use Illuminate\Broadcasting\InteractsWithSockets;
98
use Illuminate\Broadcasting\PrivateChannel;
109
use Illuminate\Foundation\Events\Dispatchable;
@@ -28,7 +27,7 @@ public function __construct(
2827
//
2928
}
3029

31-
public function broadcastOn(): Channel | array
30+
public function broadcastOn(): PrivateChannel
3231
{
3332
return new PrivateChannel('channel-name');
3433
}

src/Lodash/Auth/Passport/Grants/InternalRefreshTokenGrant.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function getIdentifier(): string
4848
public function respondToAccessTokenRequest(
4949
ServerRequestInterface $request,
5050
ResponseTypeInterface $responseType,
51-
DateInterval $accessTokenTTL,
51+
DateInterval $accessTokenTtl,
5252
) {
5353
// Validate request
5454
$client = $this->validateClient($request);
@@ -76,7 +76,7 @@ public function respondToAccessTokenRequest(
7676
}
7777

7878
// Issue and persist new access token
79-
$accessToken = $this->issueAccessToken($accessTokenTTL, $client, $oldRefreshToken['user_id'], $scopes);
79+
$accessToken = $this->issueAccessToken($accessTokenTtl, $client, $oldRefreshToken['user_id'], $scopes);
8080
$this->getEmitter()->emit(new RequestAccessTokenEvent(RequestEvent::ACCESS_TOKEN_ISSUED, $request, $accessToken));
8181
$responseType->setAccessToken($accessToken);
8282

src/Lodash/Auth/Passport/PassportServiceProvider.php

+18-9
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,48 @@
3030
use Longman\LaravelLodash\Auth\Repositories\TokenRepository;
3131
use Longman\LaravelLodash\Auth\Repositories\UserRepository;
3232
use Longman\LaravelLodash\Auth\Services\AuthService;
33+
use Override;
3334

3435
use function tap;
3536

3637
class PassportServiceProvider extends BasePassportServiceProvider
3738
{
39+
#[Override]
3840
public function register(): void
3941
{
4042
parent::register();
4143

4244
$this->registerCustomRepositories();
4345
}
4446

47+
#[Override]
4548
protected function registerAuthorizationServer(): void
4649
{
4750
$this->app->singleton(AuthorizationServer::class, function () {
4851
return tap($this->makeAuthorizationServer(), function (AuthorizationServer $server) {
49-
$accessTokenTtl = new DateInterval('PT1H');
52+
$this->enableGrants($server);
53+
});
54+
});
55+
}
5056

51-
$server->setDefaultScope(Passport::$defaultScope);
57+
protected function enableGrants(AuthorizationServer $server): void
58+
{
59+
$accessTokenTtl = new DateInterval('PT1H');
5260

53-
$server->enableGrantType($this->makeInternalGrant(), $accessTokenTtl);
61+
$server->setDefaultScope(Passport::$defaultScope);
5462

55-
$server->enableGrantType($this->makeInternalRefreshTokenGrant(), $accessTokenTtl);
63+
$server->enableGrantType($this->makeInternalGrant(), $accessTokenTtl);
5664

57-
$server->enableGrantType($this->makeGoogleAccessTokenGrant(), $accessTokenTtl);
65+
$server->enableGrantType($this->makeInternalRefreshTokenGrant(), $accessTokenTtl);
5866

59-
$server->enableGrantType($this->makeGoogleIdTokenGrant(), $accessTokenTtl);
67+
$server->enableGrantType($this->makeGoogleAccessTokenGrant(), $accessTokenTtl);
6068

61-
$server->enableGrantType($this->makeEmulateGrant(), $accessTokenTtl);
62-
});
63-
});
69+
$server->enableGrantType($this->makeGoogleIdTokenGrant(), $accessTokenTtl);
70+
71+
$server->enableGrantType($this->makeEmulateGrant(), $accessTokenTtl);
6472
}
6573

74+
#[Override]
6675
protected function makeGuard(array $config): RequestGuard
6776
{
6877
return new RequestGuard(function (Request $request) use ($config) {

src/Lodash/Auth/Repositories/ClientRepository.php

+2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
namespace Longman\LaravelLodash\Auth\Repositories;
66

7+
use JetBrains\PhpStorm\Deprecated;
78
use Laravel\Passport\ClientRepository as BaseClientRepository;
89
use Longman\LaravelLodash\Auth\Contracts\ClientRepositoryContract;
910

11+
#[Deprecated('Use custom implementation')]
1012
class ClientRepository extends BaseClientRepository implements ClientRepositoryContract
1113
{
1214
//

0 commit comments

Comments
 (0)