Skip to content

Commit

Permalink
MDL-71119 core_badges: Initialise scopes param in backpack-connect.php
Browse files Browse the repository at this point in the history
The scopes parameter should be passed when creating the OAuth2 badges
client. As it is an optional parameter, when it's empty, it will
be initilised with the supported scopes for the backpack issuer.

It will happen, for instance, when a call is done to oauth2callback.php
because, as defined in RFC6749, OAuth2 authorization response only
supports code and state.
  • Loading branch information
sarjona committed Apr 14, 2021
1 parent 511a87f commit c974a59
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions badges/backpack-connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
$returnurl = new moodle_url('/badges/backpack-connect.php',
['action' => 'authorization', 'sesskey' => sesskey(), 'backpackid' => $backpackid]);

// If scope is not passed as parameter, use the issuer supported scopes.
if (empty($scope)) {
$scope = $issuer->get('scopessupported');
}
$client = new core_badges\oauth2\client($issuer, $returnurl, $scope, $externalbackpack);
if ($client) {
if (!$client->is_logged_in()) {
Expand Down

0 comments on commit c974a59

Please sign in to comment.