diff options
author | zotlabs <mike@macgirvin.com> | 2018-08-12 15:10:19 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2018-08-12 15:10:19 -0700 |
commit | 2d29095348eb8ab73bac7c22b4f87bfed7ea06c0 (patch) | |
tree | 0385828542ba0b8c930b10b8cac503777b696e45 /Zotlabs/Module/Authorize.php | |
parent | ac03b4ccd74e52d8f1c78ad6393e8d90171516ce (diff) | |
parent | 759a18685b75e631d5884d610cc3a6fe483b821d (diff) | |
download | volse-hubzilla-2d29095348eb8ab73bac7c22b4f87bfed7ea06c0.tar.gz volse-hubzilla-2d29095348eb8ab73bac7c22b4f87bfed7ea06c0.tar.bz2 volse-hubzilla-2d29095348eb8ab73bac7c22b4f87bfed7ea06c0.zip |
Merge branch 'dev' of https://framagit.org/hubzilla/core into xdev_merge
Diffstat (limited to 'Zotlabs/Module/Authorize.php')
-rw-r--r-- | Zotlabs/Module/Authorize.php | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Zotlabs/Module/Authorize.php b/Zotlabs/Module/Authorize.php index bfb76150f..e042848d8 100644 --- a/Zotlabs/Module/Authorize.php +++ b/Zotlabs/Module/Authorize.php @@ -60,12 +60,16 @@ class Authorize extends \Zotlabs\Web\Controller { $request = \OAuth2\Request::createFromGlobals(); $response = new \OAuth2\Response(); + // Note, "sub" field must match type and content. $user_id is used to populate - make sure it's a string. + $channel = channelx_by_n(local_channel()); + $user_id = $channel["channel_id"]; + // If the client is not registered, add to the database if (!$client = $storage->getClientDetails($client_id)) { - $client_secret = random_string(16); + // Until "Dynamic Client Registration" is pursued - allow new clients to assign their own secret in the REQUEST + $client_secret = (isset($_REQUEST["client_secret"])) ? $_REQUEST["client_secret"] : random_string(16); // Client apps are registered per channel - $user_id = local_channel(); - $storage->setClientDetails($client_id, $client_secret, $redirect_uri, 'authorization_code', null, $user_id); + $storage->setClientDetails($client_id, $client_secret, $redirect_uri, 'authorization_code', urldecode($_REQUEST["scope"]), $user_id); } if (!$client = $storage->getClientDetails($client_id)) { @@ -83,7 +87,7 @@ class Authorize extends \Zotlabs\Web\Controller { // print the authorization code if the user has authorized your client $is_authorized = ($_POST['authorize'] === 'allow'); - $s->handleAuthorizeRequest($request, $response, $is_authorized, local_channel()); + $s->handleAuthorizeRequest($request, $response, $is_authorized, $user_id); if ($is_authorized) { $code = substr($response->getHttpHeader('Location'), strpos($response->getHttpHeader('Location'), 'code=') + 5, 40); logger('Authorization Code: ' . $code); |