aboutsummaryrefslogtreecommitdiffstats
path: root/library/oauth2/src/OAuth2/OpenID/ResponseType
diff options
context:
space:
mode:
Diffstat (limited to 'library/oauth2/src/OAuth2/OpenID/ResponseType')
-rw-r--r--library/oauth2/src/OAuth2/OpenID/ResponseType/AuthorizationCode.php60
-rw-r--r--library/oauth2/src/OAuth2/OpenID/ResponseType/AuthorizationCodeInterface.php27
-rw-r--r--library/oauth2/src/OAuth2/OpenID/ResponseType/CodeIdToken.php24
-rw-r--r--library/oauth2/src/OAuth2/OpenID/ResponseType/CodeIdTokenInterface.php9
-rw-r--r--library/oauth2/src/OAuth2/OpenID/ResponseType/IdToken.php124
-rw-r--r--library/oauth2/src/OAuth2/OpenID/ResponseType/IdTokenInterface.php29
-rw-r--r--library/oauth2/src/OAuth2/OpenID/ResponseType/IdTokenToken.php27
-rw-r--r--library/oauth2/src/OAuth2/OpenID/ResponseType/IdTokenTokenInterface.php9
8 files changed, 0 insertions, 309 deletions
diff --git a/library/oauth2/src/OAuth2/OpenID/ResponseType/AuthorizationCode.php b/library/oauth2/src/OAuth2/OpenID/ResponseType/AuthorizationCode.php
deleted file mode 100644
index 8971954c5..000000000
--- a/library/oauth2/src/OAuth2/OpenID/ResponseType/AuthorizationCode.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-
-namespace OAuth2\OpenID\ResponseType;
-
-use OAuth2\ResponseType\AuthorizationCode as BaseAuthorizationCode;
-use OAuth2\OpenID\Storage\AuthorizationCodeInterface as AuthorizationCodeStorageInterface;
-
-/**
- *
- * @author Brent Shaffer <bshafs at gmail dot com>
- */
-class AuthorizationCode extends BaseAuthorizationCode implements AuthorizationCodeInterface
-{
- public function __construct(AuthorizationCodeStorageInterface $storage, array $config = array())
- {
- parent::__construct($storage, $config);
- }
-
- public function getAuthorizeResponse($params, $user_id = null)
- {
- // build the URL to redirect to
- $result = array('query' => array());
-
- $params += array('scope' => null, 'state' => null, 'id_token' => null);
-
- $result['query']['code'] = $this->createAuthorizationCode($params['client_id'], $user_id, $params['redirect_uri'], $params['scope'], $params['id_token']);
-
- if (isset($params['state'])) {
- $result['query']['state'] = $params['state'];
- }
-
- return array($params['redirect_uri'], $result);
- }
-
- /**
- * Handle the creation of the authorization code.
- *
- * @param $client_id
- * Client identifier related to the authorization code
- * @param $user_id
- * User ID associated with the authorization code
- * @param $redirect_uri
- * An absolute URI to which the authorization server will redirect the
- * user-agent to when the end-user authorization step is completed.
- * @param $scope
- * (optional) Scopes to be stored in space-separated string.
- * @param $id_token
- * (optional) The OpenID Connect id_token.
- *
- * @see http://tools.ietf.org/html/rfc6749#section-4
- * @ingroup oauth2_section_4
- */
- public function createAuthorizationCode($client_id, $user_id, $redirect_uri, $scope = null, $id_token = null)
- {
- $code = $this->generateAuthorizationCode();
- $this->storage->setAuthorizationCode($code, $client_id, $user_id, $redirect_uri, time() + $this->config['auth_code_lifetime'], $scope, $id_token);
-
- return $code;
- }
-}
diff --git a/library/oauth2/src/OAuth2/OpenID/ResponseType/AuthorizationCodeInterface.php b/library/oauth2/src/OAuth2/OpenID/ResponseType/AuthorizationCodeInterface.php
deleted file mode 100644
index ea4779255..000000000
--- a/library/oauth2/src/OAuth2/OpenID/ResponseType/AuthorizationCodeInterface.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-namespace OAuth2\OpenID\ResponseType;
-
-use OAuth2\ResponseType\AuthorizationCodeInterface as BaseAuthorizationCodeInterface;
-
-/**
- *
- * @author Brent Shaffer <bshafs at gmail dot com>
- */
-interface AuthorizationCodeInterface extends BaseAuthorizationCodeInterface
-{
- /**
- * Handle the creation of the authorization code.
- *
- * @param $client_id Client identifier related to the authorization code
- * @param $user_id User ID associated with the authorization code
- * @param $redirect_uri An absolute URI to which the authorization server will redirect the
- * user-agent to when the end-user authorization step is completed.
- * @param $scope OPTIONAL Scopes to be stored in space-separated string.
- * @param $id_token OPTIONAL The OpenID Connect id_token.
- *
- * @see http://tools.ietf.org/html/rfc6749#section-4
- * @ingroup oauth2_section_4
- */
- public function createAuthorizationCode($client_id, $user_id, $redirect_uri, $scope = null, $id_token = null);
-}
diff --git a/library/oauth2/src/OAuth2/OpenID/ResponseType/CodeIdToken.php b/library/oauth2/src/OAuth2/OpenID/ResponseType/CodeIdToken.php
deleted file mode 100644
index ac7764d6c..000000000
--- a/library/oauth2/src/OAuth2/OpenID/ResponseType/CodeIdToken.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-namespace OAuth2\OpenID\ResponseType;
-
-class CodeIdToken implements CodeIdTokenInterface
-{
- protected $authCode;
- protected $idToken;
-
- public function __construct(AuthorizationCodeInterface $authCode, IdTokenInterface $idToken)
- {
- $this->authCode = $authCode;
- $this->idToken = $idToken;
- }
-
- public function getAuthorizeResponse($params, $user_id = null)
- {
- $result = $this->authCode->getAuthorizeResponse($params, $user_id);
- $resultIdToken = $this->idToken->getAuthorizeResponse($params, $user_id);
- $result[1]['query']['id_token'] = $resultIdToken[1]['fragment']['id_token'];
-
- return $result;
- }
-}
diff --git a/library/oauth2/src/OAuth2/OpenID/ResponseType/CodeIdTokenInterface.php b/library/oauth2/src/OAuth2/OpenID/ResponseType/CodeIdTokenInterface.php
deleted file mode 100644
index 629adcca8..000000000
--- a/library/oauth2/src/OAuth2/OpenID/ResponseType/CodeIdTokenInterface.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-
-namespace OAuth2\OpenID\ResponseType;
-
-use OAuth2\ResponseType\ResponseTypeInterface;
-
-interface CodeIdTokenInterface extends ResponseTypeInterface
-{
-}
diff --git a/library/oauth2/src/OAuth2/OpenID/ResponseType/IdToken.php b/library/oauth2/src/OAuth2/OpenID/ResponseType/IdToken.php
deleted file mode 100644
index 97777fbf2..000000000
--- a/library/oauth2/src/OAuth2/OpenID/ResponseType/IdToken.php
+++ /dev/null
@@ -1,124 +0,0 @@
-<?php
-
-namespace OAuth2\OpenID\ResponseType;
-
-use OAuth2\Encryption\EncryptionInterface;
-use OAuth2\Encryption\Jwt;
-use OAuth2\Storage\PublicKeyInterface;
-use OAuth2\OpenID\Storage\UserClaimsInterface;
-
-class IdToken implements IdTokenInterface
-{
- protected $userClaimsStorage;
- protected $publicKeyStorage;
- protected $config;
- protected $encryptionUtil;
-
- public function __construct(UserClaimsInterface $userClaimsStorage, PublicKeyInterface $publicKeyStorage, array $config = array(), EncryptionInterface $encryptionUtil = null)
- {
- $this->userClaimsStorage = $userClaimsStorage;
- $this->publicKeyStorage = $publicKeyStorage;
- if (is_null($encryptionUtil)) {
- $encryptionUtil = new Jwt();
- }
- $this->encryptionUtil = $encryptionUtil;
-
- if (!isset($config['issuer'])) {
- throw new \LogicException('config parameter "issuer" must be set');
- }
- $this->config = array_merge(array(
- 'id_lifetime' => 3600,
- ), $config);
- }
-
- public function getAuthorizeResponse($params, $userInfo = null)
- {
- // build the URL to redirect to
- $result = array('query' => array());
- $params += array('scope' => null, 'state' => null, 'nonce' => null);
-
- // create the id token.
- list($user_id, $auth_time) = $this->getUserIdAndAuthTime($userInfo);
- $userClaims = $this->userClaimsStorage->getUserClaims($user_id, $params['scope']);
-
- $id_token = $this->createIdToken($params['client_id'], $userInfo, $params['nonce'], $userClaims, null);
- $result["fragment"] = array('id_token' => $id_token);
- if (isset($params['state'])) {
- $result["fragment"]["state"] = $params['state'];
- }
-
- return array($params['redirect_uri'], $result);
- }
-
- public function createIdToken($client_id, $userInfo, $nonce = null, $userClaims = null, $access_token = null)
- {
- // pull auth_time from user info if supplied
- list($user_id, $auth_time) = $this->getUserIdAndAuthTime($userInfo);
-
- $token = array(
- 'iss' => $this->config['issuer'],
- 'sub' => $user_id,
- 'aud' => $client_id,
- 'iat' => time(),
- 'exp' => time() + $this->config['id_lifetime'],
- 'auth_time' => $auth_time,
- );
-
- if ($nonce) {
- $token['nonce'] = $nonce;
- }
-
- if ($userClaims) {
- $token += $userClaims;
- }
-
- if ($access_token) {
- $token['at_hash'] = $this->createAtHash($access_token, $client_id);
- }
-
- return $this->encodeToken($token, $client_id);
- }
-
- protected function createAtHash($access_token, $client_id = null)
- {
- // maps HS256 and RS256 to sha256, etc.
- $algorithm = $this->publicKeyStorage->getEncryptionAlgorithm($client_id);
- $hash_algorithm = 'sha' . substr($algorithm, 2);
- $hash = hash($hash_algorithm, $access_token, true);
- $at_hash = substr($hash, 0, strlen($hash) / 2);
-
- return $this->encryptionUtil->urlSafeB64Encode($at_hash);
- }
-
- protected function encodeToken(array $token, $client_id = null)
- {
- $private_key = $this->publicKeyStorage->getPrivateKey($client_id);
- $algorithm = $this->publicKeyStorage->getEncryptionAlgorithm($client_id);
-
- return $this->encryptionUtil->encode($token, $private_key, $algorithm);
- }
-
- private function getUserIdAndAuthTime($userInfo)
- {
- $auth_time = null;
-
- // 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');
- }
-
- $auth_time = isset($userInfo['auth_time']) ? $userInfo['auth_time'] : null;
- $user_id = $userInfo['user_id'];
- } else {
- $user_id = $userInfo;
- }
-
- if (is_null($auth_time)) {
- $auth_time = time();
- }
-
- // userInfo is a scalar, and so this is the $user_id. Auth Time is null
- return array($user_id, $auth_time);
- }
-}
diff --git a/library/oauth2/src/OAuth2/OpenID/ResponseType/IdTokenInterface.php b/library/oauth2/src/OAuth2/OpenID/ResponseType/IdTokenInterface.php
deleted file mode 100644
index 0bd2f8391..000000000
--- a/library/oauth2/src/OAuth2/OpenID/ResponseType/IdTokenInterface.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-namespace OAuth2\OpenID\ResponseType;
-
-use OAuth2\ResponseType\ResponseTypeInterface;
-
-interface IdTokenInterface extends ResponseTypeInterface
-{
- /**
- * Create the id token.
- *
- * If Authorization Code Flow is used, the id_token is generated when the
- * authorization code is issued, and later returned from the token endpoint
- * together with the access_token.
- * If the Implicit Flow is used, the token and id_token are generated and
- * returned together.
- *
- * @param string $client_id The client id.
- * @param string $user_id The user id.
- * @param string $nonce OPTIONAL The nonce.
- * @param string $userClaims OPTIONAL Claims about the user.
- * @param string $access_token OPTIONAL The access token, if known.
- *
- * @return string The ID Token represented as a JSON Web Token (JWT).
- *
- * @see http://openid.net/specs/openid-connect-core-1_0.html#IDToken
- */
- public function createIdToken($client_id, $userInfo, $nonce = null, $userClaims = null, $access_token = null);
-}
diff --git a/library/oauth2/src/OAuth2/OpenID/ResponseType/IdTokenToken.php b/library/oauth2/src/OAuth2/OpenID/ResponseType/IdTokenToken.php
deleted file mode 100644
index f0c59799b..000000000
--- a/library/oauth2/src/OAuth2/OpenID/ResponseType/IdTokenToken.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-namespace OAuth2\OpenID\ResponseType;
-
-use OAuth2\ResponseType\AccessTokenInterface;
-
-class IdTokenToken implements IdTokenTokenInterface
-{
- protected $accessToken;
- protected $idToken;
-
- public function __construct(AccessTokenInterface $accessToken, IdTokenInterface $idToken)
- {
- $this->accessToken = $accessToken;
- $this->idToken = $idToken;
- }
-
- public function getAuthorizeResponse($params, $user_id = null)
- {
- $result = $this->accessToken->getAuthorizeResponse($params, $user_id);
- $access_token = $result[1]['fragment']['access_token'];
- $id_token = $this->idToken->createIdToken($params['client_id'], $user_id, $params['nonce'], null, $access_token);
- $result[1]['fragment']['id_token'] = $id_token;
-
- return $result;
- }
-}
diff --git a/library/oauth2/src/OAuth2/OpenID/ResponseType/IdTokenTokenInterface.php b/library/oauth2/src/OAuth2/OpenID/ResponseType/IdTokenTokenInterface.php
deleted file mode 100644
index ac13e2032..000000000
--- a/library/oauth2/src/OAuth2/OpenID/ResponseType/IdTokenTokenInterface.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-
-namespace OAuth2\OpenID\ResponseType;
-
-use OAuth2\ResponseType\ResponseTypeInterface;
-
-interface IdTokenTokenInterface extends ResponseTypeInterface
-{
-}