forum-oauth-center/src/OAuth.php

45 lines
1.1 KiB
PHP
Raw Normal View History

2023-09-29 09:16:43 +08:00
<?php
2023-09-29 14:49:12 +08:00
/*
* This file is part of foskym/flarum-oauth-center.
*
* Copyright (c) 2023 FoskyM.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
2023-09-29 09:16:43 +08:00
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,
2023-09-29 14:49:12 +08:00
'enforce_state' => false
2023-09-29 09:16:43 +08:00
));
$server->addGrantType(new AuthorizationCode($storage));
$server->addGrantType(new ClientCredentials($storage));
$server->addGrantType(new UserCredentials($storage));
$server->addGrantType(new RefreshToken($storage));
return $server;
}
}