aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Authorize.php
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2018-02-24 06:48:30 -0500
committerAndrew Manning <tamanning@zoho.com>2018-02-24 06:48:30 -0500
commit64ee42fc3d00765bc5c60e451b86230ea38ffdfb (patch)
tree17519229614dbc4887a6f3a8fd16ce306ac7bef9 /Zotlabs/Module/Authorize.php
parent70719c67d30810c8127707b0dd1fd7ed66aa4a9a (diff)
downloadvolse-hubzilla-64ee42fc3d00765bc5c60e451b86230ea38ffdfb.tar.gz
volse-hubzilla-64ee42fc3d00765bc5c60e451b86230ea38ffdfb.tar.bz2
volse-hubzilla-64ee42fc3d00765bc5c60e451b86230ea38ffdfb.zip
Add channel ID to user_id in clients table. Added TODO comments about dynamic client registration protocol.
Diffstat (limited to 'Zotlabs/Module/Authorize.php')
-rw-r--r--Zotlabs/Module/Authorize.php27
1 files changed, 17 insertions, 10 deletions
diff --git a/Zotlabs/Module/Authorize.php b/Zotlabs/Module/Authorize.php
index f98453fb5..2c0c9248f 100644
--- a/Zotlabs/Module/Authorize.php
+++ b/Zotlabs/Module/Authorize.php
@@ -32,17 +32,23 @@ class Authorize extends \Zotlabs\Web\Controller {
if (!local_channel()) {
return login();
} else {
- // display an authorization form
- $app = array('name' => 'Test App', 'icon' => '/images/icons/plugin.png');
+ // TODO: Fully implement the dynamic client registration protocol:
+ // OpenID Connect Dynamic Client Registration 1.0 Client Metadata
+ // http://openid.net/specs/openid-connect-registration-1_0.html
+ $app = array(
+ 'name' => (x($_REQUEST, 'client_name') ? urldecode($_REQUEST['client_name']) : 'Unknown App'),
+ 'icon' => (x($_REQUEST, 'logo_uri') ? urldecode($_REQUEST['logo_uri']) : '/images/icons/plugin.png'),
+ 'url' => (x($_REQUEST, 'client_uri') ? urldecode($_REQUEST['client_uri']) : ''),
+ );
$o .= replace_macros(get_markup_template('oauth_authorize.tpl'), array(
'$title' => '',
- '$authorize' => 'Do you authorize the app "' . $app['name'] . '" to access your channel data?',
+ '$authorize' => 'Do you authorize the app <a style="float: none;" href="' . $app['url'] . '">' . $app['name'] . '</a> to access your channel data?',
'$app' => $app,
'$yes' => t('Allow'),
'$no' => t('Deny'),
'$client_id' => (x($_REQUEST, 'client_id') ? $_REQUEST['client_id'] : ''),
'$redirect_uri' => (x($_REQUEST, 'redirect_uri') ? $_REQUEST['redirect_uri'] : ''),
- '$state' => (x($_REQUEST, 'state') ? $_REQUEST['state'] : '')
+ '$state' => (x($_REQUEST, 'state') ? $_REQUEST['state'] : ''),
));
return $o;
}
@@ -56,14 +62,15 @@ class Authorize extends \Zotlabs\Web\Controller {
$storage = new OAuth2Storage(\DBA::$dba->db);
$s = new \Zotlabs\Identity\OAuth2Server($storage);
-
+ // TODO: The automatic client registration protocol below should adhere more
+ // closely to "OAuth 2.0 Dynamic Client Registration Protocol" defined
+ // at https://tools.ietf.org/html/rfc7591
+
// If no client_id was provided, generate a new one.
if (x($_POST, 'client_id')) {
$client_id = $_POST['client_id'];
- logger('client_id was provided: ' . $client_id);
} else {
$client_id = $_POST['client_id'] = random_string(16);
- logger('client_id was not provided. Generated new id: ' . $client_id);
}
// If no redirect_uri was provided, generate a fake one.
if (x($_POST, 'redirect_uri')) {
@@ -72,15 +79,15 @@ class Authorize extends \Zotlabs\Web\Controller {
$redirect_uri = $_POST['redirect_uri'] = 'https://fake.example.com';
}
- logger('redirect_uri is : ' . $redirect_uri);
// If the client is not registered, add to the database
if (!$storage->getClientDetails($client_id)) {
$client_secret = random_string(16);
- $storage->setClientDetails($client_id, $client_secret, $redirect_uri);
+ // Client apps are registered per channel
+ $user_id = local_channel();
+ $storage->setClientDetails($client_id, $client_secret, $redirect_uri, null, null, $user_id);
}
$request = \OAuth2\Request::createFromGlobals();
- logger(json_encode($request, JSON_PRETTY_PRINT), LOGGER_DEBUG);
$response = new \OAuth2\Response();
// validate the authorize request