3
3
*
4
4
* Copyright MITRE 2020
5
5
*
6
- * OpenIDConnectClient for PHP5
6
+ * OpenIDConnectClient for PHP7+
7
7
* Author: Michael Jett <[email protected] >
8
8
*
9
9
* Licensed under the Apache License, Version 2.0 (the "License"); you may
25
25
26
26
use Error ;
27
27
use Exception ;
28
- use phpseclib3 \Crypt \PublicKeyLoader ;
29
28
use phpseclib3 \Crypt \RSA ;
30
29
use phpseclib3 \Math \BigInteger ;
31
30
use stdClass ;
@@ -380,7 +379,7 @@ public function authenticate(): bool
380
379
$ accessToken = $ _REQUEST ['access_token ' ] ?? null ;
381
380
382
381
// Do an OpenID Connect session check
383
- if (!isset ($ _REQUEST ['state ' ]) || ($ _REQUEST ['state ' ] !== $ this ->getState ())) {
382
+ if (!isset ($ _REQUEST ['state ' ]) || ($ _REQUEST ['state ' ] !== $ this ->getState ())) {
384
383
throw new OpenIDConnectClientException ('Unable to determine state ' );
385
384
}
386
385
@@ -691,7 +690,7 @@ public function getRedirectURL(): string
691
690
if (isset ($ _SERVER ['HTTP_X_FORWARDED_PORT ' ])) {
692
691
$ port = (int )$ _SERVER ['HTTP_X_FORWARDED_PORT ' ];
693
692
} elseif (isset ($ _SERVER ['SERVER_PORT ' ])) {
694
- $ port = ( int ) $ _SERVER ['SERVER_PORT ' ];
693
+ $ port = $ _SERVER ['SERVER_PORT ' ];
695
694
} elseif ($ protocol === 'https ' ) {
696
695
$ port = 443 ;
697
696
} else {
@@ -1221,10 +1220,9 @@ protected function urlEncode(string $str): string
1221
1220
/**
1222
1221
* @param string $jwt encoded JWT
1223
1222
* @param int $section the section we would like to decode
1224
- * @return object
1223
+ * @return object|null
1225
1224
*/
1226
- protected function decodeJWT (string $ jwt , int $ section = 0 ): stdClass {
1227
-
1225
+ protected function decodeJWT (string $ jwt , int $ section = 0 ) {
1228
1226
$ parts = explode ('. ' , $ jwt );
1229
1227
return json_decode (base64url_decode ($ parts [$ section ]), false );
1230
1228
}
@@ -1688,7 +1686,10 @@ public function revokeToken(string $token, string $token_type_hint = '', string
1688
1686
return json_decode ($ this ->fetchURL ($ revocation_endpoint , $ post_params , $ headers ), false );
1689
1687
}
1690
1688
1691
- public function getClientName (): string
1689
+ /**
1690
+ * @return string|null
1691
+ */
1692
+ public function getClientName ()
1692
1693
{
1693
1694
return $ this ->clientName ;
1694
1695
}
@@ -1698,14 +1699,14 @@ public function setClientName(string $clientName) {
1698
1699
}
1699
1700
1700
1701
/**
1701
- * @return string
1702
+ * @return string|null
1702
1703
*/
1703
1704
public function getClientID () {
1704
1705
return $ this ->clientID ;
1705
1706
}
1706
1707
1707
1708
/**
1708
- * @return string
1709
+ * @return string|null
1709
1710
*/
1710
1711
public function getClientSecret () {
1711
1712
return $ this ->clientSecret ;
@@ -1720,17 +1721,26 @@ public function setAccessToken(string $accessToken) {
1720
1721
$ this ->accessToken = $ accessToken ;
1721
1722
}
1722
1723
1723
- public function getAccessToken (): string
1724
+ /**
1725
+ * @return string|null
1726
+ */
1727
+ public function getAccessToken ()
1724
1728
{
1725
1729
return $ this ->accessToken ;
1726
1730
}
1727
1731
1728
- public function getRefreshToken (): string
1732
+ /**
1733
+ * @return string|null
1734
+ */
1735
+ public function getRefreshToken ()
1729
1736
{
1730
1737
return $ this ->refreshToken ;
1731
1738
}
1732
1739
1733
- public function getIdToken (): string
1740
+ /**
1741
+ * @return string|null
1742
+ */
1743
+ public function getIdToken ()
1734
1744
{
1735
1745
return $ this ->idToken ;
1736
1746
}
0 commit comments