Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
catch CallbackException, do not add groups to attributes in that case…
Browse files Browse the repository at this point in the history
… and continue
  • Loading branch information
François Kooman committed Jul 18, 2013
1 parent a255042 commit 6921267
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Release History

## 0.1.1
* fix issue #3 where simpleSAMLphp would display a nasty error in case the user
did not accept to release groups to the service.
* make_release.sh script no longer included in release
* updated README

## 0.1.0
* Initial release
39 changes: 23 additions & 16 deletions www/callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,29 @@
$config = $state['vootgroups:config'];
$diContainer = new sspmod_vootgroups_SspDiContainer($config);

$cb = new \fkooman\OAuth\Client\Callback();
$cb->setClientConfig("ssp-voot-groups", $diContainer['clientConfig']);
$cb->setStorage($diContainer['storage']);
$cb->setHttpClient(new \Guzzle\Http\Client());

$accessToken = $cb->handleCallback($_GET);

// obtain attributes from state
$attributes =& $state['Attributes'];

$vootCall = new sspmod_vootgroups_VootCall();
$vootCall->setHttpClient(new \Guzzle\Http\Client());

if (false === $vootCall->makeCall($diContainer['vootEndpoint'], $accessToken->getAccessToken(), $attributes, $diContainer['targetAttribute'])) {
// unable to fetch groups, something is wrong with the token?
throw new Exception("unable to fetch groups with seemingly valid bearer token");
try {
$cb = new \fkooman\OAuth\Client\Callback();
$cb->setClientConfig("ssp-voot-groups", $diContainer['clientConfig']);
$cb->setStorage($diContainer['storage']);
$cb->setHttpClient(new \Guzzle\Http\Client());
$accessToken = $cb->handleCallback($_GET);

// obtain attributes from state
$attributes =& $state['Attributes'];

$vootCall = new sspmod_vootgroups_VootCall();
$vootCall->setHttpClient(new \Guzzle\Http\Client());

if (false === $vootCall->makeCall($diContainer['vootEndpoint'], $accessToken->getAccessToken(), $attributes, $diContainer['targetAttribute'])) {
// unable to fetch groups, something is wrong with the token?
throw new Exception("unable to fetch groups with seemingly valid bearer token");
}
} catch (\fkooman\OAuth\Client\CallbackException $e) {
// something went wrong with the callback, maybe the user did not
// agree to the release, or maybe something else was up.
// FIXME: we should be more fine grained here!
// for now we just continue without notifying the user, without adding the
// groups...
}

// FIXME: the resumeProcessing does not work yet... how do you deal with this?!
Expand Down

0 comments on commit 6921267

Please sign in to comment.