1 | <?php |
||
2 | |||
3 | namespace CILogon\Service; |
||
4 | |||
5 | use CILogon\Service\Util; |
||
6 | use League\OAuth2\Client\Provider; |
||
7 | use League\OAuth2\Client\Provider\Github; |
||
8 | use League\OAuth2\Client\Provider\Google; |
||
9 | use CILogon\OAuth2\Client\Provider\ORCID; |
||
10 | |||
11 | /** |
||
12 | * OAuth2Provider |
||
13 | */ |
||
14 | class OAuth2Provider |
||
15 | { |
||
16 | /** |
||
17 | * @var League\OAuth2\Client\Provider $provider Member variable for |
||
0 ignored issues
–
show
|
|||
18 | * OAuth2 PHP provider object |
||
19 | */ |
||
20 | public $provider = null; |
||
21 | |||
22 | /** |
||
23 | * @var array $authzUrlOpts An array of parameters to be passed to |
||
24 | * getAuthorizationUrl(). |
||
25 | */ |
||
26 | public $authzUrlOpts = array(); |
||
27 | |||
28 | /** |
||
29 | * __construct |
||
30 | * |
||
31 | * Class constructor. Initializes the class variables using the passed-in |
||
32 | * Identity Provider Display Name ($idpdn). Sets the class variables |
||
33 | * 'provider' (the OAuth2 Client library provider object) and |
||
34 | * 'authzUrlOpts' (for use with getAuthorizationUrl()). |
||
35 | * |
||
36 | * @param string|null $idpdn The Display Name of the Identity Provider |
||
37 | * use for OAuth2 connection. |
||
38 | */ |
||
39 | public function __construct($idpdn) |
||
40 | { |
||
41 | if (is_null($idpdn)) { |
||
42 | $idpdn = Util::getSessionVar('idp_display_name'); |
||
43 | } |
||
44 | $idpdn = strtolower($idpdn); |
||
45 | |||
46 | $classname = ''; |
||
47 | $extraparams = array(); |
||
48 | |||
49 | // Set the client id and secret for the $idpdn |
||
50 | $client_id = constant(strtoupper($idpdn) . '_OAUTH2_CLIENT_ID'); |
||
51 | $client_secret = constant(strtoupper($idpdn) . '_OAUTH2_CLIENT_SECRET'); |
||
52 | |||
53 | if ((strlen($client_id) > 0) && (strlen($client_secret) > 0)) { |
||
54 | // Set options on a per-IdP basis |
||
55 | if ($idpdn == 'google') { |
||
56 | $classname = 'League\OAuth2\Client\Provider\Google'; |
||
57 | $this->authzUrlOpts = ['scope' => ['openid','email','profile']]; |
||
58 | $extraparams = array('accessType' => 'offline'); |
||
59 | } elseif ($idpdn == 'github') { |
||
60 | $classname = 'League\OAuth2\Client\Provider\Github'; |
||
61 | $this->authzUrlOpts = ['scope' => ['user:email']]; |
||
62 | } elseif ($idpdn == 'orcid') { |
||
63 | $classname = 'CILogon\OAuth2\Client\Provider\ORCID'; |
||
64 | // CIL-799 Use Member API and fetch id_token in order to get 'amr' claim |
||
65 | $this->authzUrlOpts = ['scope' => ['openid']]; |
||
66 | $extraparams = array('member' => 'true'); |
||
67 | } |
||
68 | |||
69 | $this->provider = new $classname(array_merge(array( |
||
70 | 'clientId' => $client_id, |
||
71 | 'clientSecret' => $client_secret, |
||
72 | 'redirectUri' => 'https://' . Util::getHN() . '/getuser/' |
||
73 | ), $extraparams)); |
||
74 | } |
||
75 | } |
||
76 | } |
||
77 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths