mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Update oauth flow
This commit is contained in:
parent
f79900bb44
commit
1c02afb1a1
5 changed files with 628 additions and 572 deletions
25
app/Auth/BearerTokenResponse.php
Normal file
25
app/Auth/BearerTokenResponse.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Auth;
|
||||||
|
|
||||||
|
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
||||||
|
|
||||||
|
class BearerTokenResponse extends \League\OAuth2\Server\ResponseTypes\BearerTokenResponse
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Add custom fields to your Bearer Token response here, then override
|
||||||
|
* AuthorizationServer::getResponseType() to pull in your version of
|
||||||
|
* this class rather than the default.
|
||||||
|
*
|
||||||
|
* @param AccessTokenEntityInterface $accessToken
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getExtraParams(AccessTokenEntityInterface $accessToken)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'created_at' => time(),
|
||||||
|
'scope' => 'read write follow push'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
27
app/Providers/PassportServiceProvider.php
Normal file
27
app/Providers/PassportServiceProvider.php
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Auth\BearerTokenResponse;
|
||||||
|
use Laravel\Passport\Bridge;
|
||||||
|
use League\OAuth2\Server\AuthorizationServer;
|
||||||
|
|
||||||
|
class PassportServiceProvider extends \Laravel\Passport\PassportServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Make the authorization service instance.
|
||||||
|
*
|
||||||
|
* @return \League\OAuth2\Server\AuthorizationServer
|
||||||
|
*/
|
||||||
|
public function makeAuthorizationServer()
|
||||||
|
{
|
||||||
|
return new AuthorizationServer(
|
||||||
|
$this->app->make(Bridge\ClientRepository::class),
|
||||||
|
$this->app->make(Bridge\AccessTokenRepository::class),
|
||||||
|
$this->app->make(Bridge\ScopeRepository::class),
|
||||||
|
$this->makeCryptKey('private'),
|
||||||
|
app('encrypter')->getKey(),
|
||||||
|
new BearerTokenResponse()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -73,6 +73,7 @@
|
||||||
"extra": {
|
"extra": {
|
||||||
"laravel": {
|
"laravel": {
|
||||||
"dont-discover": [
|
"dont-discover": [
|
||||||
|
"laravel/passport"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
1146
composer.lock
generated
1146
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -165,6 +165,7 @@ return [
|
||||||
App\Providers\HorizonServiceProvider::class,
|
App\Providers\HorizonServiceProvider::class,
|
||||||
App\Providers\EventServiceProvider::class,
|
App\Providers\EventServiceProvider::class,
|
||||||
App\Providers\RouteServiceProvider::class,
|
App\Providers\RouteServiceProvider::class,
|
||||||
|
App\Providers\PassportServiceProvider::class,
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue