diff options
author | Mario <mario@mariovavti.com> | 2018-03-09 11:12:18 +0100 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2018-03-09 11:12:18 +0100 |
commit | 4baf5eab16d809977a44e7911ddcab0ff8383897 (patch) | |
tree | 393f618c4cfc20f53264ecd8a26a08de0823d35d /Zotlabs/Identity/OAuth2Server.php | |
parent | 577da0eb9eb1f90a4cf7a70cfb3582cfb49007ac (diff) | |
parent | 7361af85b5488fc8bd1744389a3a332dc74276b0 (diff) | |
download | volse-hubzilla-4baf5eab16d809977a44e7911ddcab0ff8383897.tar.gz volse-hubzilla-4baf5eab16d809977a44e7911ddcab0ff8383897.tar.bz2 volse-hubzilla-4baf5eab16d809977a44e7911ddcab0ff8383897.zip |
Merge branch '3.2RC'3.2
Diffstat (limited to 'Zotlabs/Identity/OAuth2Server.php')
-rw-r--r-- | Zotlabs/Identity/OAuth2Server.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Zotlabs/Identity/OAuth2Server.php b/Zotlabs/Identity/OAuth2Server.php new file mode 100644 index 000000000..cbb4748fe --- /dev/null +++ b/Zotlabs/Identity/OAuth2Server.php @@ -0,0 +1,34 @@ +<?php + +namespace Zotlabs\Identity; + +class OAuth2Server extends \OAuth2\Server { + + public function __construct(OAuth2Storage $storage, $config = []) { + + if(! is_array($config)) { + $config = [ + 'use_openid_connect' => true, + 'issuer' => \Zotlabs\Lib\System::get_site_name() + ]; + } + + parent::__construct($storage, $config); + + // Add the "Client Credentials" grant type (it is the simplest of the grant types) + $this->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage)); + + // Add the "Authorization Code" grant type (this is where the oauth magic happens) + $this->addGrantType(new \OAuth2\GrantType\AuthorizationCode($storage)); + + $keyStorage = new \OAuth2\Storage\Memory( [ + 'keys' => [ + 'public_key' => get_config('system', 'pubkey'), + 'private_key' => get_config('system', 'prvkey') + ] + ]); + + $this->addStorage($keyStorage, 'public_key'); + } + +} |