Skip to content

Commit

Permalink
Merge branch 'release/2.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Feb 24, 2020
2 parents 3a11c09 + 0bd9f0e commit e14ee35
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.idea
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v2.0.3
## 02/24/2019

1. [](#improved)
* Added `copy-to-clipboard` support for Callback URIs
* Added support for providers that callback via POST (ie, Apple)
* Fixed issues with saving in Admin 1.7 with strict form validation

# v2.0.2
## 04/28/2019

Expand Down
2 changes: 2 additions & 0 deletions blueprints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ form:
site_callback_url:
type: text
disabled: true
copy_to_clipboard: true
label: PLUGIN_LOGIN_OAUTH2.SITE_CALLBACK_URI
help: PLUGIN_LOGIN_OAUTH2.SITE_CALLBACK_URI_HELP
data-default@: ['Grav\Plugin\Login\OAuth2\Providers\BaseProvider::getCallbackUri', false]

admin_callback_url:
type: text
disabled: true
copy_to_clipboard: true
label: PLUGIN_LOGIN_OAUTH2.ADMIN_CALLBACK_URI
help: PLUGIN_LOGIN_OAUTH2.ADMIN_CALLBACK_URI_HELP
data-default@: ['Grav\Plugin\Login\OAuth2\Providers\BaseProvider::getCallbackUri', true]
Expand Down
4 changes: 2 additions & 2 deletions classes/Providers/BaseProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static function getCallbackUri($admin = 'auto')

$callback_uri = ((bool) $admin ? Grav::instance()['config']->get('plugins.admin.route', '') : '') . static::CALLBACK_URI;

$base_url = Grav::instance()['base_url_absolute'];
$base_url = rtrim(Grav::instance()['uri']->rootUrl(true), '/');

return $base_url . '/' . ltrim($callback_uri, '/');
}
Expand Down Expand Up @@ -118,4 +118,4 @@ public function getResourceOwner(AccessToken $token)
{
return $this->provider->getResourceOwner($token);
}
}
}
12 changes: 12 additions & 0 deletions login-oauth2.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,17 @@ public function loginCallback()
/** @var Message $messages */
$messages = $this->grav['messages'];



if ($oauth2->isValidProvider($provider_name)) {

$state = filter_input(INPUT_GET, 'state', FILTER_SANITIZE_STRING, !FILTER_FLAG_STRIP_LOW);

// try POST
if (empty($state)) {
$state = filter_input(INPUT_POST, 'state', FILTER_SANITIZE_STRING, !FILTER_FLAG_STRIP_LOW);
}

if (empty($state) || ($state !== $session->oauth2_state)) {
unset($session->oauth2_state);
// TODO: better error message?
Expand Down Expand Up @@ -242,6 +249,11 @@ public function userLoginAuthenticate(UserLoginEvent $event)
if (isset($options['oauth2'])) {

$code = filter_input(INPUT_GET, 'code', FILTER_SANITIZE_STRING, !FILTER_FLAG_STRIP_LOW);

// try POST
if (!$code) {
$code = filter_input(INPUT_POST, 'code', FILTER_SANITIZE_STRING, !FILTER_FLAG_STRIP_LOW);
}
$provider_name = $options['provider'];
$provider = ProviderFactory::create($provider_name, $options);

Expand Down
4 changes: 2 additions & 2 deletions login-oauth2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ providers:
enabled: true
client_id: ''
client_secret: ''
hd: '*'
options:
scope: ['email', 'profile']
avatar_size: 200
hd: '*'

linkedin:
enabled: true
Expand Down Expand Up @@ -84,10 +84,10 @@ admin:
enabled: false
client_id: ''
client_secret: ''
hd: '*'
options:
scope: ['email', 'profile']
avatar_size: 200
hd: '*'

linkedin:
enabled: false
Expand Down

0 comments on commit e14ee35

Please sign in to comment.