$authorizationCodeFactory = new sspmod_oauth2server_OAuth2_TokenFactory($authorizationCodeTTL, $accessTokenTTL, $tokenTTL); $token = $authorizationCodeFactory->createAuthorizationCode($state['clientId'], $state['redirectUri'], array(), $attributes[$idAttribute][0]); } else { $authorizationCodeFactory = new sspmod_oauth2server_OAuth2_TokenFactory($authorizationCodeTTL, $tokenTTL, $tokenTTL); $token = $authorizationCodeFactory->createBearerAccessToken($state['clientId'], array(), $attributes[$idAttribute][0]); } if (isset($_REQUEST['grantedScopes'])) { $scopesTemp = $_REQUEST['grantedScopes']; } else { $scopesTemp = array(); } \sspmod_oauth2server_Utility_Uri::augmentRequestedScopesWithRequiredScopes($client, $scopesTemp); $token['scopes'] = \sspmod_oauth2server_Utility_Uri::findValidScopes($client, $scopesTemp); $tokenStore = new sspmod_oauth2server_OAuth2_TokenStore($config); if ($state['response_type'] === 'code') { $tokenStore->addAuthorizationCode($token); } else { $tokenStore->addAccessToken($token); } $userStore = new sspmod_oauth2server_OAuth2_UserStore($config); $user = $userStore->getUser($token['userId']); if (is_array($user)) { $user['attributes'] = $as->getAttributes(); $liveTokens = array($token['id']); if ($state['response_type'] === 'code') { foreach ($user['authorizationCodes'] as $tokenId) { if (!is_null($tokenStore->getAuthorizationCode($tokenId))) { array_push($liveTokens, $tokenId); } } $user['authorizationCodes'] = $liveTokens;
/** * @group unit * @group oauth2 */ public function testAuthorizationCodeIsolation() { $store = new \sspmod_oauth2server_OAuth2_TokenStore($this->getDefaultConfiguration()); $token1 = array('id' => 'dummy', 'expire' => time() + 1000); $store->addAuthorizationCode($token1); $this->assertNull($store->getRefreshToken($token1['id'])); $this->assertNull($store->getAccessToken($token1['id'])); }