chore: create the class OAuth

This commit is contained in:
FoskyM 2023-09-29 09:16:43 +08:00
parent aa39cc7361
commit d01a0778b8
No known key found for this signature in database
GPG key ID: 42C0ED6994AD7E9C
2 changed files with 36 additions and 1 deletions

35
src/OAuth.php Normal file
View file

@ -0,0 +1,35 @@
<?php
namespace FoskyM\OAuthCenter;
use OAuth2\Server;
use OAuth2\Response;
use OAuth2\Request;
use OAuth2\GrantType\ClientCredentials;
use OAuth2\GrantType\AuthorizationCode;
use OAuth2\GrantType\UserCredentials;
use OAuth2\GrantType\RefreshToken;
class OAuth
{
public function response(): Response
{
return new Response;
}
public function request(): Request
{
return new Request;
}
public function server(): Server
{
$storage = new Storage;
$server = new Server($storage, array(
'allow_implicit' => true,
));
$server->addGrantType(new AuthorizationCode($storage));
$server->addGrantType(new ClientCredentials($storage));
$server->addGrantType(new UserCredentials($storage));
$server->addGrantType(new RefreshToken($storage));
return $server;
}
}

View file

@ -14,7 +14,7 @@ use OAuth2\Storage\RefreshTokenInterface;
use OAuth2\Storage\ScopeInterface; use OAuth2\Storage\ScopeInterface;
use OAuth2\Storage\UserCredentialsInterface; use OAuth2\Storage\UserCredentialsInterface;
abstract class Storage implements class Storage implements
AuthorizationCodeInterface, AuthorizationCodeInterface,
AccessTokenInterface, AccessTokenInterface,
ClientCredentialsInterface, ClientCredentialsInterface,