aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/bshaffer/oauth2-server-php/src/OAuth2/OpenID/ResponseType/IdToken.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2018-03-09 11:12:18 +0100
committerMario <mario@mariovavti.com>2018-03-09 11:12:18 +0100
commit4baf5eab16d809977a44e7911ddcab0ff8383897 (patch)
tree393f618c4cfc20f53264ecd8a26a08de0823d35d /vendor/bshaffer/oauth2-server-php/src/OAuth2/OpenID/ResponseType/IdToken.php
parent577da0eb9eb1f90a4cf7a70cfb3582cfb49007ac (diff)
parent7361af85b5488fc8bd1744389a3a332dc74276b0 (diff)
downloadvolse-hubzilla-4baf5eab16d809977a44e7911ddcab0ff8383897.tar.gz
volse-hubzilla-4baf5eab16d809977a44e7911ddcab0ff8383897.tar.bz2
volse-hubzilla-4baf5eab16d809977a44e7911ddcab0ff8383897.zip
Merge branch '3.2RC'3.2
Diffstat (limited to 'vendor/bshaffer/oauth2-server-php/src/OAuth2/OpenID/ResponseType/IdToken.php')
-rw-r--r--vendor/bshaffer/oauth2-server-php/src/OAuth2/OpenID/ResponseType/IdToken.php58
1 files changed, 56 insertions, 2 deletions
diff --git a/vendor/bshaffer/oauth2-server-php/src/OAuth2/OpenID/ResponseType/IdToken.php b/vendor/bshaffer/oauth2-server-php/src/OAuth2/OpenID/ResponseType/IdToken.php
index 97777fbf2..55e446074 100644
--- a/vendor/bshaffer/oauth2-server-php/src/OAuth2/OpenID/ResponseType/IdToken.php
+++ b/vendor/bshaffer/oauth2-server-php/src/OAuth2/OpenID/ResponseType/IdToken.php
@@ -6,14 +6,38 @@ use OAuth2\Encryption\EncryptionInterface;
use OAuth2\Encryption\Jwt;
use OAuth2\Storage\PublicKeyInterface;
use OAuth2\OpenID\Storage\UserClaimsInterface;
+use LogicException;
class IdToken implements IdTokenInterface
{
+ /**
+ * @var UserClaimsInterface
+ */
protected $userClaimsStorage;
+ /**
+ * @var PublicKeyInterface
+ */
protected $publicKeyStorage;
+
+ /**
+ * @var array
+ */
protected $config;
+
+ /**
+ * @var EncryptionInterface
+ */
protected $encryptionUtil;
+ /**
+ * Constructor
+ *
+ * @param UserClaimsInterface $userClaimsStorage
+ * @param PublicKeyInterface $publicKeyStorage
+ * @param array $config
+ * @param EncryptionInterface $encryptionUtil
+ * @throws LogicException
+ */
public function __construct(UserClaimsInterface $userClaimsStorage, PublicKeyInterface $publicKeyStorage, array $config = array(), EncryptionInterface $encryptionUtil = null)
{
$this->userClaimsStorage = $userClaimsStorage;
@@ -24,13 +48,18 @@ class IdToken implements IdTokenInterface
$this->encryptionUtil = $encryptionUtil;
if (!isset($config['issuer'])) {
- throw new \LogicException('config parameter "issuer" must be set');
+ throw new LogicException('config parameter "issuer" must be set');
}
$this->config = array_merge(array(
'id_lifetime' => 3600,
), $config);
}
+ /**
+ * @param array $params
+ * @param null $userInfo
+ * @return array|mixed
+ */
public function getAuthorizeResponse($params, $userInfo = null)
{
// build the URL to redirect to
@@ -50,6 +79,16 @@ class IdToken implements IdTokenInterface
return array($params['redirect_uri'], $result);
}
+ /**
+ * Create id token
+ *
+ * @param string $client_id
+ * @param mixed $userInfo
+ * @param mixed $nonce
+ * @param mixed $userClaims
+ * @param mixed $access_token
+ * @return mixed|string
+ */
public function createIdToken($client_id, $userInfo, $nonce = null, $userClaims = null, $access_token = null)
{
// pull auth_time from user info if supplied
@@ -79,6 +118,11 @@ class IdToken implements IdTokenInterface
return $this->encodeToken($token, $client_id);
}
+ /**
+ * @param $access_token
+ * @param null $client_id
+ * @return mixed|string
+ */
protected function createAtHash($access_token, $client_id = null)
{
// maps HS256 and RS256 to sha256, etc.
@@ -90,6 +134,11 @@ class IdToken implements IdTokenInterface
return $this->encryptionUtil->urlSafeB64Encode($at_hash);
}
+ /**
+ * @param array $token
+ * @param null $client_id
+ * @return mixed|string
+ */
protected function encodeToken(array $token, $client_id = null)
{
$private_key = $this->publicKeyStorage->getPrivateKey($client_id);
@@ -98,6 +147,11 @@ class IdToken implements IdTokenInterface
return $this->encryptionUtil->encode($token, $private_key, $algorithm);
}
+ /**
+ * @param $userInfo
+ * @return array
+ * @throws LogicException
+ */
private function getUserIdAndAuthTime($userInfo)
{
$auth_time = null;
@@ -105,7 +159,7 @@ class IdToken implements IdTokenInterface
// support an array for user_id / auth_time
if (is_array($userInfo)) {
if (!isset($userInfo['user_id'])) {
- throw new \LogicException('if $user_id argument is an array, user_id index must be set');
+ throw new LogicException('if $user_id argument is an array, user_id index must be set');
}
$auth_time = isset($userInfo['auth_time']) ? $userInfo['auth_time'] : null;