Skip to content

Commit 8519c97

Browse files
committed
v1.3.0: 2 bug fixes, 2 new features
* Fix execute permissions on interface pages (visit ACP > Community > OAuth2 Server > Applications to fix) * Fix double-login required on initial visit (RFC3986 compatible argument passing) * Enable site template on authorization page * Allow localisation of "Yes" and "No" on authorization page Closes #16 Closes #6 Closes #7
1 parent f961cbd commit 8519c97

8 files changed

Lines changed: 49 additions & 10 deletions

File tree

data/versions.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"102001": "1.2.1",
77
"102002": "1.2.2",
88
"102003": "1.2.3",
9-
"102004": "1.2.4"
10-
}
9+
"102004": "1.2.4",
10+
"103000": "1.3.0"
11+
}

dev/html/front/server/authorize.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{{endforeach}}
88
</ul>
99
<form method="post">
10-
<input type="submit" class="input_submit" name="authorized" value="Yes" />
11-
<input type="submit" class="input_submit ipsButton_secondary" name="authorized" value="No" />
10+
<button name="authorized" class="input_submit" value="Yes" type="submit">{lang="authorize_yes"}</button>
11+
<button name="authorized" class="input_submit ipsButton_secondary" value="No">{lang="authorize_no"}</button>
1212
<input type="hidden" name="csrfKey" value="{expression="\IPS\Session::i()->csrfKey"}" />
1313
</form>

dev/lang.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,8 @@
2828
'task__expiretokens' => "Expires obsolete access tokens, refresh tokens and authorization codes.",
2929
'perm_request_prefix' => "Do you authorize the application",
3030
'perm_request_suffix' => "to access this site?",
31-
'perm_list_prefix' => "The following access permissions will be granted to the application:"
31+
'perm_list_prefix' => "The following access permissions will be granted to the application:",
32+
'authorize_title' => "Authorize external application",
33+
'authorize_yes' => "Yes",
34+
'authorize_no' => "No",
3235
);

interface/oauth/authorize.php

100644100755
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* @brief OAuth 2 Server Authorization Gateway
44
* @author Joan Touzet
5-
* @copyright (c) 2016 Joan Touzet
5+
* @copyright (c) 2016-2017 Joan Touzet
66
* @license GPL 2
77
*/
88

@@ -17,7 +17,7 @@
1717
$member_id = \IPS\Member::loggedIn()->member_id;
1818
if ( ! $member_id ) {
1919
// ref parameter is base64 encoding of destination URL
20-
$ref_url = \IPS\Settings::i()->base_url . "applications/oauth2server/interface/oauth/authorize.php?" . http_build_query($_GET);
20+
$ref_url = \IPS\Settings::i()->base_url . "applications/oauth2server/interface/oauth/authorize.php?" . http_build_query($_GET, null, ini_get('arg_separator.output'), PHP_QUERY_RFC3986);
2121
$ref = base64_encode( $ref_url );
2222
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=system&controller=login&ref=' . $ref, 'front', 'login' ) );
2323
}
@@ -76,11 +76,10 @@
7676
$scope = explode( ' ', $client['scope'] );
7777
}
7878

79-
// scope is contained, request permission from user
80-
$header = \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->logo();
8179
// TODO: Surface scope in template output
8280
$form = \IPS\Theme::i()->getTemplate( 'server', 'oauth2server', 'front' )->authorize( $client, $scope );
83-
\IPS\Output::i()->sendOutput( $header . $form, 200, 'text/html', \IPS\Output::i()->httpHeaders );
81+
$title = \IPS\Member::loggedIn()->language()->addToStack('authorize_title');
82+
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->globalTemplate( $title, $form, true, \IPS\ROOT_PATH ) , 200, 'text/html', \IPS\Output::i()->httpHeaders );
8483
}
8584

8685
// print the authorization code if the user has authorized your client

interface/oauth/me.php

100644100755
File mode changed.

interface/oauth/token.php

100644100755
File mode changed.

modules/admin/oauthserver/clients.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class _clients extends \IPS\Node\Controller
3232
public function execute()
3333
{
3434
\IPS\Dispatcher::i()->checkAcpPermission( 'clients_manage' );
35+
chmod( \IPS\ROOT_PATH . '/applications/oauth2server/interface/oauth/authorize.php', 0755 );
36+
chmod( \IPS\ROOT_PATH . '/applications/oauth2server/interface/oauth/me.php', 0755 );
37+
chmod( \IPS\ROOT_PATH . '/applications/oauth2server/interface/oauth/token.php', 0755 );
3538
parent::execute();
3639
}
3740

setup/upg_103000/upgrade.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
4+
namespace IPS\oauth2server\setup\upg_103000;
5+
6+
/* To prevent PHP errors (extending class does not exist) revealing path */
7+
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
8+
{
9+
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
10+
exit;
11+
}
12+
13+
/**
14+
* 1.3.0 Upgrade Code
15+
*/
16+
class _Upgrade
17+
{
18+
/**
19+
* ...
20+
*
21+
* @return array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
22+
*/
23+
public function step1()
24+
{
25+
chmod( \IPS\ROOT_PATH . '/applications/oauth2server/interface/oauth/authorize.php', 0755 );
26+
chmod( \IPS\ROOT_PATH . '/applications/oauth2server/interface/oauth/me.php', 0755 );
27+
chmod( \IPS\ROOT_PATH . '/applications/oauth2server/interface/oauth/token.php', 0755 );
28+
return TRUE;
29+
}
30+
31+
// You can create as many additional methods (step2, step3, etc.) as is necessary.
32+
// Each step will be executed in a new HTTP request
33+
}

0 commit comments

Comments
 (0)