feat(oauth server): basic settings
This commit is contained in:
parent
e1283b013b
commit
6fc62fc269
1 changed files with 13 additions and 2 deletions
|
@ -18,8 +18,16 @@ use OAuth2\GrantType\ClientCredentials;
|
||||||
use OAuth2\GrantType\AuthorizationCode;
|
use OAuth2\GrantType\AuthorizationCode;
|
||||||
use OAuth2\GrantType\UserCredentials;
|
use OAuth2\GrantType\UserCredentials;
|
||||||
use OAuth2\GrantType\RefreshToken;
|
use OAuth2\GrantType\RefreshToken;
|
||||||
|
|
||||||
|
use Flarum\Settings\SettingsRepositoryInterface;
|
||||||
class OAuth
|
class OAuth
|
||||||
{
|
{
|
||||||
|
protected $settings;
|
||||||
|
|
||||||
|
public function __construct(SettingsRepositoryInterface $settings)
|
||||||
|
{
|
||||||
|
$this->settings = $settings;
|
||||||
|
}
|
||||||
public function response(): Response
|
public function response(): Response
|
||||||
{
|
{
|
||||||
return new Response;
|
return new Response;
|
||||||
|
@ -30,10 +38,13 @@ class OAuth
|
||||||
}
|
}
|
||||||
public function server(): Server
|
public function server(): Server
|
||||||
{
|
{
|
||||||
|
|
||||||
$storage = new Storage;
|
$storage = new Storage;
|
||||||
$server = new Server($storage, array(
|
$server = new Server($storage, array(
|
||||||
'allow_implicit' => true,
|
'allow_implicit' => $this->settings->get('foskym-oauth-center.allow_implicit') == "1",
|
||||||
'enforce_state' => false
|
'enforce_state' => $this->settings->get('foskym-oauth-center.enforce_state') == "1",
|
||||||
|
'require_exact_redirect_uri' => $this->settings->get('foskym-oauth-center.require_exact_redirect_uri') == "1",
|
||||||
|
'access_lifetime' => $this->settings->get('foskym-oauth-center.access_lifetime') == "" ? 3600 : $this->settings->get('foskym-oauth-center.access_lifetime'),
|
||||||
));
|
));
|
||||||
$server->addGrantType(new AuthorizationCode($storage));
|
$server->addGrantType(new AuthorizationCode($storage));
|
||||||
$server->addGrantType(new ClientCredentials($storage));
|
$server->addGrantType(new ClientCredentials($storage));
|
||||||
|
|
Loading…
Reference in a new issue