aboutsummaryrefslogtreecommitdiffstats
path: root/include/oauth2.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/oauth2.php')
-rw-r--r--include/oauth2.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/oauth2.php b/include/oauth2.php
new file mode 100644
index 000000000..a0d65a995
--- /dev/null
+++ b/include/oauth2.php
@@ -0,0 +1,21 @@
+<?php
+
+ $storage = new OAuth2\Storage\Pdo(\DBA::$dba->db);
+ $config = [
+ 'use_openid_connect'] => true,
+ 'issuer' => \Zotlabs\Lib\System::get_site_name()
+ ];
+
+ $oauth2_server = new OAuth2\Server($storage,$config);
+
+ $oauth2_server->addGrantType(new OAuth2\GrantType\ClientCredentials($storage));
+ $oauth2_server->addGrantType(new OAuth2\GrantType\AuthorizationCode($storage));
+
+ $keyStorage = new OAuth2\Storage\Memory( [
+ 'keys' => [
+ 'public_key' => get_config('system','pubkey'),
+ 'private_key' => get_config('system','prvkey')
+ ]
+ ]);
+
+ $oauth2_server->addStorage($keyStorage,'public_key');