oauth2/oidc testing (please do not port - this requires several extra DB tables to work)

This commit is contained in:
zotlabs
2017-05-03 22:37:06 -07:00
parent 05cbdc6915
commit b08af13872
3 changed files with 132 additions and 0 deletions

21
include/oauth2.php Normal file
View File

@@ -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');