update
This commit is contained in:
5
modules/pshowsso/vendor/league/oauth2-github/.gitignore
vendored
Normal file
5
modules/pshowsso/vendor/league/oauth2-github/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/build
|
||||
/vendor
|
||||
composer.phar
|
||||
composer.lock
|
||||
.DS_Store
|
||||
35
modules/pshowsso/vendor/league/oauth2-github/.scrutinizer.yml
vendored
Normal file
35
modules/pshowsso/vendor/league/oauth2-github/.scrutinizer.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
filter:
|
||||
excluded_paths: [test/*]
|
||||
checks:
|
||||
php:
|
||||
code_rating: true
|
||||
remove_extra_empty_lines: true
|
||||
remove_php_closing_tag: true
|
||||
remove_trailing_whitespace: true
|
||||
fix_use_statements:
|
||||
remove_unused: true
|
||||
preserve_multiple: false
|
||||
preserve_blanklines: true
|
||||
order_alphabetically: true
|
||||
fix_php_opening_tag: true
|
||||
fix_linefeed: true
|
||||
fix_line_ending: true
|
||||
fix_identation_4spaces: true
|
||||
fix_doc_comments: true
|
||||
tools:
|
||||
external_code_coverage:
|
||||
timeout: 600
|
||||
runs: 3
|
||||
php_analyzer: true
|
||||
php_code_coverage: false
|
||||
php_code_sniffer:
|
||||
config:
|
||||
standard: PSR2
|
||||
filter:
|
||||
paths: ['src']
|
||||
php_loc:
|
||||
enabled: true
|
||||
excluded_dirs: [vendor, test]
|
||||
php_cpd:
|
||||
enabled: true
|
||||
excluded_dirs: [vendor, test]
|
||||
27
modules/pshowsso/vendor/league/oauth2-github/.travis.yml
vendored
Normal file
27
modules/pshowsso/vendor/league/oauth2-github/.travis.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
language: php
|
||||
|
||||
sudo: false
|
||||
|
||||
php:
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- hhvm
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.6
|
||||
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"'
|
||||
|
||||
before_script:
|
||||
- travis_retry composer self-update
|
||||
- travis_retry composer install --no-interaction --prefer-source --dev
|
||||
- travis_retry phpenv rehash
|
||||
|
||||
script:
|
||||
- ./vendor/bin/phpcs --standard=psr2 src/
|
||||
- ./vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
|
||||
|
||||
after_script:
|
||||
- wget https://scrutinizer-ci.com/ocular.phar
|
||||
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
|
||||
92
modules/pshowsso/vendor/league/oauth2-github/CHANGELOG.md
vendored
Normal file
92
modules/pshowsso/vendor/league/oauth2-github/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
# Changelog
|
||||
All Notable changes to `oauth2-github` will be documented in this file
|
||||
|
||||
## 2.0.0 - 2017-01-25
|
||||
|
||||
### Added
|
||||
- PHP 7.1 Support
|
||||
|
||||
### Deprecated
|
||||
- Nothing
|
||||
|
||||
### Fixed
|
||||
- Nothing
|
||||
|
||||
### Removed
|
||||
- PHP 5.5 Support
|
||||
|
||||
### Security
|
||||
- Nothing
|
||||
|
||||
## 1.0.0 - 2017-01-25
|
||||
|
||||
Bump for base package parity
|
||||
|
||||
## 0.2.2 - 2016-11-21
|
||||
|
||||
### Added
|
||||
- Update base package version from 1.0 to 1.4
|
||||
- Update GithubResourceOwner to utilize ArrayAccessorTrait from base package
|
||||
|
||||
### Deprecated
|
||||
- Nothing
|
||||
|
||||
### Fixed
|
||||
- Nothing
|
||||
|
||||
### Removed
|
||||
- Nothing
|
||||
|
||||
### Security
|
||||
- Nothing
|
||||
|
||||
## 0.2.1 - 2016-04-13
|
||||
|
||||
### Added
|
||||
- Support OAuth exceptions from Github with non-standard status codes (https://developer.github.com/v3/oauth/#common-errors-for-the-access-token-request)
|
||||
|
||||
### Deprecated
|
||||
- Nothing
|
||||
|
||||
### Fixed
|
||||
- Nothing
|
||||
|
||||
### Removed
|
||||
- Nothing
|
||||
|
||||
### Security
|
||||
- Nothing
|
||||
|
||||
## 0.2.0 - 2015-08-20
|
||||
|
||||
### Added
|
||||
- Upgrade to support version 1.0 release of core client
|
||||
|
||||
### Deprecated
|
||||
- Nothing
|
||||
|
||||
### Fixed
|
||||
- Nothing
|
||||
|
||||
### Removed
|
||||
- Nothing
|
||||
|
||||
### Security
|
||||
- Nothing
|
||||
|
||||
## 0.1.0 - 2015-04-13
|
||||
|
||||
### Added
|
||||
- Initial release!
|
||||
|
||||
### Deprecated
|
||||
- Nothing
|
||||
|
||||
### Fixed
|
||||
- Nothing
|
||||
|
||||
### Removed
|
||||
- Nothing
|
||||
|
||||
### Security
|
||||
- Nothing
|
||||
42
modules/pshowsso/vendor/league/oauth2-github/CONTRIBUTING.md
vendored
Normal file
42
modules/pshowsso/vendor/league/oauth2-github/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
# Contributing
|
||||
|
||||
Contributions are **welcome** and will be fully **credited**.
|
||||
|
||||
We accept contributions via Pull Requests on [Github](https://github.com/thephpleague/oauth2-github).
|
||||
|
||||
|
||||
## Pull Requests
|
||||
|
||||
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
|
||||
|
||||
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
|
||||
|
||||
- **Document any change in behaviour** - Make sure the README and any other relevant documentation are kept up-to-date.
|
||||
|
||||
- **Consider our release cycle** - We try to follow SemVer. Randomly breaking public APIs is not an option.
|
||||
|
||||
- **Create topic branches** - Don't ask us to pull from your master branch.
|
||||
|
||||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
|
||||
|
||||
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.
|
||||
|
||||
- **Ensure tests pass!** - Please run the tests (see below) before submitting your pull request, and make sure they pass. We won't accept a patch until all tests pass.
|
||||
|
||||
- **Ensure no coding standards violations** - Please run PHP Code Sniffer using the PSR-2 standard (see below) before submitting your pull request. A violation will cause the build to fail, so please make sure there are no violations. We can't accept a patch if the build fails.
|
||||
|
||||
|
||||
## Running Tests
|
||||
|
||||
``` bash
|
||||
$ ./vendor/bin/phpunit
|
||||
```
|
||||
|
||||
|
||||
## Running PHP Code Sniffer
|
||||
|
||||
``` bash
|
||||
$ ./vendor/bin/phpcs src --standard=psr2 -sp
|
||||
```
|
||||
|
||||
**Happy coding**!
|
||||
21
modules/pshowsso/vendor/league/oauth2-github/LICENSE
vendored
Normal file
21
modules/pshowsso/vendor/league/oauth2-github/LICENSE
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Steven Maguire
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
129
modules/pshowsso/vendor/league/oauth2-github/README.md
vendored
Normal file
129
modules/pshowsso/vendor/league/oauth2-github/README.md
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
# Github Provider for OAuth 2.0 Client
|
||||
[](https://github.com/thephpleague/oauth2-github/releases)
|
||||
[](LICENSE.md)
|
||||
[](https://travis-ci.org/thephpleague/oauth2-github)
|
||||
[](https://scrutinizer-ci.com/g/thephpleague/oauth2-github/code-structure)
|
||||
[](https://scrutinizer-ci.com/g/thephpleague/oauth2-github)
|
||||
[](https://packagist.org/packages/league/oauth2-github)
|
||||
|
||||
This package provides Github OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).
|
||||
|
||||
## Installation
|
||||
|
||||
To install, use composer:
|
||||
|
||||
```
|
||||
composer require league/oauth2-github
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Usage is the same as The League's OAuth client, using `\League\OAuth2\Client\Provider\Github` as the provider.
|
||||
|
||||
### Authorization Code Flow
|
||||
|
||||
```php
|
||||
$provider = new League\OAuth2\Client\Provider\Github([
|
||||
'clientId' => '{github-client-id}',
|
||||
'clientSecret' => '{github-client-secret}',
|
||||
'redirectUri' => 'https://example.com/callback-url',
|
||||
]);
|
||||
|
||||
if (!isset($_GET['code'])) {
|
||||
|
||||
// If we don't have an authorization code then get one
|
||||
$authUrl = $provider->getAuthorizationUrl();
|
||||
$_SESSION['oauth2state'] = $provider->getState();
|
||||
header('Location: '.$authUrl);
|
||||
exit;
|
||||
|
||||
// Check given state against previously stored one to mitigate CSRF attack
|
||||
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
|
||||
|
||||
unset($_SESSION['oauth2state']);
|
||||
exit('Invalid state');
|
||||
|
||||
} else {
|
||||
|
||||
// Try to get an access token (using the authorization code grant)
|
||||
$token = $provider->getAccessToken('authorization_code', [
|
||||
'code' => $_GET['code']
|
||||
]);
|
||||
|
||||
// Optional: Now you have a token you can look up a users profile data
|
||||
try {
|
||||
|
||||
// We got an access token, let's now get the user's details
|
||||
$user = $provider->getResourceOwner($token);
|
||||
|
||||
// Use these details to create a new profile
|
||||
printf('Hello %s!', $user->getNickname());
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
// Failed to get user details
|
||||
exit('Oh dear...');
|
||||
}
|
||||
|
||||
// Use this to interact with an API on the users behalf
|
||||
echo $token->getToken();
|
||||
}
|
||||
```
|
||||
|
||||
### Managing Scopes
|
||||
|
||||
When creating your Github authorization URL, you can specify the state and scopes your application may authorize.
|
||||
|
||||
```php
|
||||
$options = [
|
||||
'state' => 'OPTIONAL_CUSTOM_CONFIGURED_STATE',
|
||||
'scope' => ['user','user:email','repo'] // array or string
|
||||
];
|
||||
|
||||
$authorizationUrl = $provider->getAuthorizationUrl($options);
|
||||
```
|
||||
If neither are defined, the provider will utilize internal defaults.
|
||||
|
||||
At the time of authoring this documentation, the [following scopes are available](https://developer.github.com/v3/oauth/#scopes).
|
||||
|
||||
- user
|
||||
- user:email
|
||||
- user:follow
|
||||
- public_repo
|
||||
- repo
|
||||
- repo_deployment
|
||||
- repo:status
|
||||
- delete_repo
|
||||
- notifications
|
||||
- gist
|
||||
- read:repo_hook
|
||||
- write:repo_hook
|
||||
- admin:repo_hook
|
||||
- admin:org_hook
|
||||
- read:org
|
||||
- write:org
|
||||
- admin:org
|
||||
- read:public_key
|
||||
- write:public_key
|
||||
- admin:public_key
|
||||
|
||||
## Testing
|
||||
|
||||
``` bash
|
||||
$ ./vendor/bin/phpunit
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Please see [CONTRIBUTING](https://github.com/thephpleague/oauth2-github/blob/master/CONTRIBUTING.md) for details.
|
||||
|
||||
|
||||
## Credits
|
||||
|
||||
- [Steven Maguire](https://github.com/stevenmaguire)
|
||||
- [All Contributors](https://github.com/thephpleague/oauth2-github/contributors)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT). Please see [License File](https://github.com/thephpleague/oauth2-github/blob/master/LICENSE) for more information.
|
||||
43
modules/pshowsso/vendor/league/oauth2-github/composer.json
vendored
Normal file
43
modules/pshowsso/vendor/league/oauth2-github/composer.json
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "league\/oauth2-github",
|
||||
"description": "Github OAuth 2.0 Client Provider for The PHP League OAuth2-Client",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Steven Maguire",
|
||||
"email": "stevenmaguire@gmail.com",
|
||||
"homepage": "https:\/\/github.com\/stevenmaguire"
|
||||
}
|
||||
],
|
||||
"keywords": [
|
||||
"oauth",
|
||||
"oauth2",
|
||||
"client",
|
||||
"authorization",
|
||||
"authorisation",
|
||||
"github"
|
||||
],
|
||||
"require": {
|
||||
"league\/oauth2-client": "^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit\/phpunit": "~4.0",
|
||||
"mockery\/mockery": "~0.9",
|
||||
"squizlabs\/php_codesniffer": "~2.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Pshowsso\\Scope68f5e85e9608b\\League\\OAuth2\\Client\\": "src\/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Pshowsso\\Scope68f5e85e9608b\\League\\OAuth2\\Client\\Test\\": "test\/src\/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
37
modules/pshowsso/vendor/league/oauth2-github/phpunit.xml
vendored
Normal file
37
modules/pshowsso/vendor/league/oauth2-github/phpunit.xml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
>
|
||||
<logging>
|
||||
<log type="coverage-html"
|
||||
target="./build/coverage/html"
|
||||
charset="UTF-8"
|
||||
highlight="false"
|
||||
lowUpperBound="35"
|
||||
highLowerBound="70"/>
|
||||
<log type="coverage-clover"
|
||||
target="./build/coverage/log/coverage.xml"/>
|
||||
</logging>
|
||||
<testsuites>
|
||||
<testsuite name="Package Test Suite">
|
||||
<directory suffix=".php">./test/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">./</directory>
|
||||
<exclude>
|
||||
<directory suffix=".php">./vendor</directory>
|
||||
<directory suffix=".php">./test</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Provider\Exception;
|
||||
|
||||
use Pshowsso\Scope68f5e85e9608b\Psr\Http\Message\ResponseInterface;
|
||||
class GithubIdentityProviderException extends IdentityProviderException
|
||||
{
|
||||
/**
|
||||
* Creates client exception from response.
|
||||
*
|
||||
* @param ResponseInterface $response
|
||||
* @param string $data Parsed response data
|
||||
*
|
||||
* @return IdentityProviderException
|
||||
*/
|
||||
public static function clientException(ResponseInterface $response, $data)
|
||||
{
|
||||
return static::fromResponse($response, isset($data['message']) ? $data['message'] : $response->getReasonPhrase());
|
||||
}
|
||||
/**
|
||||
* Creates oauth exception from response.
|
||||
*
|
||||
* @param ResponseInterface $response
|
||||
* @param string $data Parsed response data
|
||||
*
|
||||
* @return IdentityProviderException
|
||||
*/
|
||||
public static function oauthException(ResponseInterface $response, $data)
|
||||
{
|
||||
return static::fromResponse($response, isset($data['error']) ? $data['error'] : $response->getReasonPhrase());
|
||||
}
|
||||
/**
|
||||
* Creates identity exception from response.
|
||||
*
|
||||
* @param ResponseInterface $response
|
||||
* @param string $message
|
||||
*
|
||||
* @return IdentityProviderException
|
||||
*/
|
||||
protected static function fromResponse(ResponseInterface $response, $message = null)
|
||||
{
|
||||
return new static($message, $response->getStatusCode(), (string) $response->getBody());
|
||||
}
|
||||
}
|
||||
100
modules/pshowsso/vendor/league/oauth2-github/src/Provider/Github.php
vendored
Normal file
100
modules/pshowsso/vendor/league/oauth2-github/src/Provider/Github.php
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Provider;
|
||||
|
||||
use Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Provider\Exception\GithubIdentityProviderException;
|
||||
use Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Token\AccessToken;
|
||||
use Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Tool\BearerAuthorizationTrait;
|
||||
use Pshowsso\Scope68f5e85e9608b\Psr\Http\Message\ResponseInterface;
|
||||
class Github extends AbstractProvider
|
||||
{
|
||||
use BearerAuthorizationTrait;
|
||||
/**
|
||||
* Domain
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $domain = 'https://github.com';
|
||||
/**
|
||||
* Api domain
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $apiDomain = 'https://api.github.com';
|
||||
/**
|
||||
* Get authorization url to begin OAuth flow
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBaseAuthorizationUrl()
|
||||
{
|
||||
return $this->domain . '/login/oauth/authorize';
|
||||
}
|
||||
/**
|
||||
* Get access token url to retrieve token
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBaseAccessTokenUrl(array $params)
|
||||
{
|
||||
return $this->domain . '/login/oauth/access_token';
|
||||
}
|
||||
/**
|
||||
* Get provider url to fetch user details
|
||||
*
|
||||
* @param AccessToken $token
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceOwnerDetailsUrl(AccessToken $token)
|
||||
{
|
||||
if ($this->domain === 'https://github.com') {
|
||||
return $this->apiDomain . '/user';
|
||||
}
|
||||
return $this->domain . '/api/v3/user';
|
||||
}
|
||||
/**
|
||||
* Get the default scopes used by this provider.
|
||||
*
|
||||
* This should not be a complete list of all scopes, but the minimum
|
||||
* required for the provider user interface!
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getDefaultScopes()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
/**
|
||||
* Check a provider response for errors.
|
||||
*
|
||||
* @link https://developer.github.com/v3/#client-errors
|
||||
* @link https://developer.github.com/v3/oauth/#common-errors-for-the-access-token-request
|
||||
* @throws IdentityProviderException
|
||||
* @param ResponseInterface $response
|
||||
* @param string $data Parsed response data
|
||||
* @return void
|
||||
*/
|
||||
protected function checkResponse(ResponseInterface $response, $data)
|
||||
{
|
||||
if ($response->getStatusCode() >= 400) {
|
||||
throw GithubIdentityProviderException::clientException($response, $data);
|
||||
} elseif (isset($data['error'])) {
|
||||
throw GithubIdentityProviderException::oauthException($response, $data);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Generate a user object from a successful user details request.
|
||||
*
|
||||
* @param array $response
|
||||
* @param AccessToken $token
|
||||
* @return League\OAuth2\Client\Provider\ResourceOwnerInterface
|
||||
*/
|
||||
protected function createResourceOwner(array $response, AccessToken $token)
|
||||
{
|
||||
$user = new GithubResourceOwner($response);
|
||||
return $user->setDomain($this->domain);
|
||||
}
|
||||
}
|
||||
97
modules/pshowsso/vendor/league/oauth2-github/src/Provider/GithubResourceOwner.php
vendored
Normal file
97
modules/pshowsso/vendor/league/oauth2-github/src/Provider/GithubResourceOwner.php
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Provider;
|
||||
|
||||
use Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Tool\ArrayAccessorTrait;
|
||||
class GithubResourceOwner implements ResourceOwnerInterface
|
||||
{
|
||||
use ArrayAccessorTrait;
|
||||
/**
|
||||
* Domain
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $domain;
|
||||
/**
|
||||
* Raw response
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $response;
|
||||
/**
|
||||
* Creates new resource owner.
|
||||
*
|
||||
* @param array $response
|
||||
*/
|
||||
public function __construct(array $response = array())
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
/**
|
||||
* Get resource owner id
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->getValueByKey($this->response, 'id');
|
||||
}
|
||||
/**
|
||||
* Get resource owner email
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->getValueByKey($this->response, 'email');
|
||||
}
|
||||
/**
|
||||
* Get resource owner name
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->getValueByKey($this->response, 'name');
|
||||
}
|
||||
/**
|
||||
* Get resource owner nickname
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getNickname()
|
||||
{
|
||||
return $this->getValueByKey($this->response, 'login');
|
||||
}
|
||||
/**
|
||||
* Get resource owner url
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
$urlParts = array_filter([$this->domain, $this->getNickname()]);
|
||||
return count($urlParts) ? implode('/', $urlParts) : null;
|
||||
}
|
||||
/**
|
||||
* Set resource owner domain
|
||||
*
|
||||
* @param string $domain
|
||||
*
|
||||
* @return ResourceOwner
|
||||
*/
|
||||
public function setDomain($domain)
|
||||
{
|
||||
$this->domain = $domain;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Return all of the owner details available as an array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
}
|
||||
29
modules/pshowsso/vendor/league/oauth2-github/test/src/Provider/GithubResourceOwnerTest.php
vendored
Normal file
29
modules/pshowsso/vendor/league/oauth2-github/test/src/Provider/GithubResourceOwnerTest.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use Mockery as m;
|
||||
class GithubResourceOwnerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testUrlIsNullWithoutDomainOrNickname()
|
||||
{
|
||||
$user = new \Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Provider\GithubResourceOwner();
|
||||
$url = $user->getUrl();
|
||||
$this->assertNull($url);
|
||||
}
|
||||
public function testUrlIsDomainWithoutNickname()
|
||||
{
|
||||
$domain = uniqid();
|
||||
$user = new \Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Provider\GithubResourceOwner();
|
||||
$user->setDomain($domain);
|
||||
$url = $user->getUrl();
|
||||
$this->assertEquals($domain, $url);
|
||||
}
|
||||
public function testUrlIsNicknameWithoutDomain()
|
||||
{
|
||||
$nickname = uniqid();
|
||||
$user = new \Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Provider\GithubResourceOwner(['login' => $nickname]);
|
||||
$url = $user->getUrl();
|
||||
$this->assertEquals($nickname, $url);
|
||||
}
|
||||
}
|
||||
172
modules/pshowsso/vendor/league/oauth2-github/test/src/Provider/GithubTest.php
vendored
Normal file
172
modules/pshowsso/vendor/league/oauth2-github/test/src/Provider/GithubTest.php
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
namespace Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use Mockery as m;
|
||||
class GithubTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $provider;
|
||||
protected function setUp()
|
||||
{
|
||||
$this->provider = new \Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Provider\Github(['clientId' => 'mock_client_id', 'clientSecret' => 'mock_secret', 'redirectUri' => 'none']);
|
||||
}
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
$uri = parse_url($url);
|
||||
parse_str($uri['query'], $query);
|
||||
$this->assertArrayHasKey('client_id', $query);
|
||||
$this->assertArrayHasKey('redirect_uri', $query);
|
||||
$this->assertArrayHasKey('state', $query);
|
||||
$this->assertArrayHasKey('scope', $query);
|
||||
$this->assertArrayHasKey('response_type', $query);
|
||||
$this->assertArrayHasKey('approval_prompt', $query);
|
||||
$this->assertNotNull($this->provider->getState());
|
||||
}
|
||||
public function testScopes()
|
||||
{
|
||||
$options = ['scope' => [uniqid(), uniqid()]];
|
||||
$url = $this->provider->getAuthorizationUrl($options);
|
||||
$this->assertContains(urlencode(implode(',', $options['scope'])), $url);
|
||||
}
|
||||
public function testGetAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
$uri = parse_url($url);
|
||||
$this->assertEquals('/login/oauth/authorize', $uri['path']);
|
||||
}
|
||||
public function testGetBaseAccessTokenUrl()
|
||||
{
|
||||
$params = [];
|
||||
$url = $this->provider->getBaseAccessTokenUrl($params);
|
||||
$uri = parse_url($url);
|
||||
$this->assertEquals('/login/oauth/access_token', $uri['path']);
|
||||
}
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Pshowsso\Scope68f5e85e9608b\Psr\Http\Message\ResponseInterface');
|
||||
$response->shouldReceive('getBody')->andReturn('{"access_token":"mock_access_token", "scope":"repo,gist", "token_type":"bearer"}');
|
||||
$response->shouldReceive('getHeader')->andReturn(['content-type' => 'json']);
|
||||
$response->shouldReceive('getStatusCode')->andReturn(200);
|
||||
$client = m::mock('Pshowsso\Scope68f5e85e9608b\GuzzleHttp\ClientInterface');
|
||||
$client->shouldReceive('send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
$this->assertEquals('mock_access_token', $token->getToken());
|
||||
$this->assertNull($token->getExpires());
|
||||
$this->assertNull($token->getRefreshToken());
|
||||
$this->assertNull($token->getResourceOwnerId());
|
||||
}
|
||||
public function testGithubEnterpriseDomainUrls()
|
||||
{
|
||||
$this->provider->domain = 'https://github.company.com';
|
||||
$response = m::mock('Pshowsso\Scope68f5e85e9608b\Psr\Http\Message\ResponseInterface');
|
||||
$response->shouldReceive('getBody')->times(1)->andReturn('access_token=mock_access_token&expires=3600&refresh_token=mock_refresh_token&otherKey={1234}');
|
||||
$response->shouldReceive('getHeader')->andReturn(['content-type' => 'application/x-www-form-urlencoded']);
|
||||
$response->shouldReceive('getStatusCode')->andReturn(200);
|
||||
$client = m::mock('Pshowsso\Scope68f5e85e9608b\GuzzleHttp\ClientInterface');
|
||||
$client->shouldReceive('send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
$this->assertEquals($this->provider->domain . '/login/oauth/authorize', $this->provider->getBaseAuthorizationUrl());
|
||||
$this->assertEquals($this->provider->domain . '/login/oauth/access_token', $this->provider->getBaseAccessTokenUrl([]));
|
||||
$this->assertEquals($this->provider->domain . '/api/v3/user', $this->provider->getResourceOwnerDetailsUrl($token));
|
||||
//$this->assertEquals($this->provider->domain.'/api/v3/user/emails', $this->provider->urlUserEmails($token));
|
||||
}
|
||||
public function testUserData()
|
||||
{
|
||||
$userId = rand(1000, 9999);
|
||||
$name = uniqid();
|
||||
$nickname = uniqid();
|
||||
$email = uniqid();
|
||||
$postResponse = m::mock('Pshowsso\Scope68f5e85e9608b\Psr\Http\Message\ResponseInterface');
|
||||
$postResponse->shouldReceive('getBody')->andReturn('access_token=mock_access_token&expires=3600&refresh_token=mock_refresh_token&otherKey={1234}');
|
||||
$postResponse->shouldReceive('getHeader')->andReturn(['content-type' => 'application/x-www-form-urlencoded']);
|
||||
$postResponse->shouldReceive('getStatusCode')->andReturn(200);
|
||||
$userResponse = m::mock('Pshowsso\Scope68f5e85e9608b\Psr\Http\Message\ResponseInterface');
|
||||
$userResponse->shouldReceive('getBody')->andReturn('{"id": ' . $userId . ', "login": "' . $nickname . '", "name": "' . $name . '", "email": "' . $email . '"}');
|
||||
$userResponse->shouldReceive('getHeader')->andReturn(['content-type' => 'json']);
|
||||
$userResponse->shouldReceive('getStatusCode')->andReturn(200);
|
||||
$client = m::mock('Pshowsso\Scope68f5e85e9608b\GuzzleHttp\ClientInterface');
|
||||
$client->shouldReceive('send')->times(2)->andReturn($postResponse, $userResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
$user = $this->provider->getResourceOwner($token);
|
||||
$this->assertEquals($userId, $user->getId());
|
||||
$this->assertEquals($userId, $user->toArray()['id']);
|
||||
$this->assertEquals($name, $user->getName());
|
||||
$this->assertEquals($name, $user->toArray()['name']);
|
||||
$this->assertEquals($nickname, $user->getNickname());
|
||||
$this->assertEquals($nickname, $user->toArray()['login']);
|
||||
$this->assertEquals($email, $user->getEmail());
|
||||
$this->assertEquals($email, $user->toArray()['email']);
|
||||
$this->assertContains($nickname, $user->getUrl());
|
||||
}
|
||||
public function testUserEmails()
|
||||
{
|
||||
/*
|
||||
$userId = rand(1000,9999);
|
||||
$name = uniqid();
|
||||
$nickname = uniqid();
|
||||
$email = uniqid();
|
||||
|
||||
$postResponse = m::mock('Psr\Http\Message\ResponseInterface');
|
||||
$postResponse->shouldReceive('getBody')->andReturn('access_token=mock_access_token&expires=3600&refresh_token=mock_refresh_token&otherKey={1234}');
|
||||
$postResponse->shouldReceive('getHeader')->andReturn(['content-type' => 'application/x-www-form-urlencoded']);
|
||||
|
||||
$userResponse = m::mock('Psr\Http\Message\ResponseInterface');
|
||||
$userResponse->shouldReceive('getBody')->andReturn('[{"email":"mock_email_1","primary":false,"verified":true},{"email":"mock_email_2","primary":false,"verified":true},{"email":"mock_email_3","primary":true,"verified":true}]');
|
||||
$userResponse->shouldReceive('getHeader')->andReturn(['content-type' => 'json']);
|
||||
|
||||
$client = m::mock('GuzzleHttp\ClientInterface');
|
||||
$client->shouldReceive('send')
|
||||
->times(2)
|
||||
->andReturn($postResponse, $userResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
$emails = $this->provider->getUserEmails($token);
|
||||
|
||||
$this->assertEquals($userId, $user->getUserId());
|
||||
$this->assertEquals($name, $user->getName());
|
||||
$this->assertEquals($nickname, $user->getNickname());
|
||||
$this->assertEquals($email, $user->getEmail());
|
||||
$this->assertContains($nickname, $user->getUrl());
|
||||
*/
|
||||
}
|
||||
/**
|
||||
* @expectedException League\OAuth2\Client\Provider\Exception\IdentityProviderException
|
||||
**/
|
||||
public function testExceptionThrownWhenErrorObjectReceived()
|
||||
{
|
||||
$status = rand(400, 600);
|
||||
$postResponse = m::mock('Pshowsso\Scope68f5e85e9608b\Psr\Http\Message\ResponseInterface');
|
||||
$postResponse->shouldReceive('getBody')->andReturn('{"message": "Validation Failed","errors": [{"resource": "Issue","field": "title","code": "missing_field"}]}');
|
||||
$postResponse->shouldReceive('getHeader')->andReturn(['content-type' => 'json']);
|
||||
$postResponse->shouldReceive('getStatusCode')->andReturn($status);
|
||||
$client = m::mock('Pshowsso\Scope68f5e85e9608b\GuzzleHttp\ClientInterface');
|
||||
$client->shouldReceive('send')->times(1)->andReturn($postResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
}
|
||||
/**
|
||||
* @expectedException League\OAuth2\Client\Provider\Exception\IdentityProviderException
|
||||
**/
|
||||
public function testExceptionThrownWhenOAuthErrorReceived()
|
||||
{
|
||||
$status = 200;
|
||||
$postResponse = m::mock('Pshowsso\Scope68f5e85e9608b\Psr\Http\Message\ResponseInterface');
|
||||
$postResponse->shouldReceive('getBody')->andReturn('{"error": "bad_verification_code","error_description": "The code passed is incorrect or expired.","error_uri": "https://developer.github.com/v3/oauth/#bad-verification-code"}');
|
||||
$postResponse->shouldReceive('getHeader')->andReturn(['content-type' => 'json']);
|
||||
$postResponse->shouldReceive('getStatusCode')->andReturn($status);
|
||||
$client = m::mock('Pshowsso\Scope68f5e85e9608b\GuzzleHttp\ClientInterface');
|
||||
$client->shouldReceive('send')->times(1)->andReturn($postResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user