first initial commit
This commit is contained in:
parent
25d8b45b27
commit
457bf54810
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 vdomah
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
<?php namespace Vdomah\JWTAuth;
|
||||
|
||||
use Config;
|
||||
use RainLab\User\Models\User;
|
||||
use System\Classes\PluginBase;
|
||||
use App;
|
||||
use Illuminate\Foundation\AliasLoader;
|
||||
use Vdomah\JWTAuth\Models\Settings;
|
||||
|
||||
class Plugin extends PluginBase
|
||||
{
|
||||
/**
|
||||
* @var array Require the RainLab.User plugin
|
||||
*/
|
||||
public $require = ['RainLab.User'];
|
||||
|
||||
public function registerComponents()
|
||||
{
|
||||
}
|
||||
|
||||
public function registerSettings()
|
||||
{
|
||||
return [
|
||||
'settings' => [
|
||||
'label' => 'vdomah.jwtauth::lang.settings.page_name',
|
||||
'description' => 'vdomah.jwtauth::lang.settings.page_desc',
|
||||
'category' => 'vdomah.jwtauth::lang.plugin.name',
|
||||
'icon' => 'oc-icon-key',
|
||||
'class' => Settings::class,
|
||||
'order' => 500,
|
||||
'keywords' => 'jwt jwtauth',
|
||||
'permissions' => ['vdomah.jwtauth.settings']
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function boot()
|
||||
{
|
||||
if (empty(Config::get('auth'))) {
|
||||
Config::set('auth', Config::get('vdomah.jwtauth::auth'));
|
||||
}
|
||||
|
||||
$this->app->bind(\Illuminate\Auth\AuthManager::class, function($app){
|
||||
return new \Illuminate\Auth\AuthManager($app);
|
||||
});
|
||||
|
||||
App::register('\Vdomah\JWTAuth\Classes\JWTAuthServiceProvider');
|
||||
|
||||
$facade = AliasLoader::getInstance();
|
||||
$facade->alias('JWTAuth', '\Tymon\JWTAuth\Facades\JWTAuth');
|
||||
$facade->alias('JWTFactory', '\Tymon\JWTAuth\Facades\JWTFactory');
|
||||
|
||||
App::singleton('auth', function ($app) {
|
||||
return new \Illuminate\Auth\AuthManager($app);
|
||||
});
|
||||
|
||||
$this->app['router']->middleware('jwt.auth', '\Tymon\JWTAuth\Middleware\GetUserFromToken');
|
||||
$this->app['router']->middleware('jwt.refresh', '\Tymon\JWTAuth\Middleware\RefreshToken');
|
||||
|
||||
User::extend(function($model) {
|
||||
$model->addDynamicMethod('getAuthApiAttributes', function () {
|
||||
return [];
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
# JWT Auth API
|
||||
|
||||
JSON Web Token Authentication for your OctoberCMS API integrated with RainLab.User
|
||||
|
||||
This plugin provides token based authentication to your application. Is based on the awesome package [JSON Web Token Authentication for Laravel & Lumen](https://github.com/tymondesigns/jwt-auth) by Sean Tymon.
|
||||
|
||||
### Requirements
|
||||
|
||||
RainLab.User plugin
|
||||
|
||||
### Installation
|
||||
|
||||
1. [NOT REQUIRED ANY MORE] After plugin installation you need to copy /plugins/vdomah/jwtauth/config/auth.php to {root}/config/auth.php.
|
||||
If you want to change parameters values of auth.php you can use environment variables in .env (see "Environment options" section).
|
||||
{root}/config/auth.php is still supported and got priority highest then /plugins/vdomah/jwtauth/config/auth.php.
|
||||
|
||||
2. Generate JWT Authentication Secret. It will be used to sign your tokens. You got 2 options:
|
||||
- generate using command line:
|
||||
````$xslt
|
||||
php artisan jwt:generate
|
||||
````
|
||||
You need to assign the generated value to JWT_SECRET in your .env.
|
||||
- go to Backend > Settings > JWTauth settings and click Generate Secret Key and save.
|
||||
This value has the highest priority and will override JWT_SECRET value from .env.
|
||||
|
||||
## Endpoints
|
||||
|
||||
The plugin provides 4 endpoints:
|
||||
|
||||
- /api/login
|
||||
|
||||
Makes attempt to authenticate and returns token if succeeded. Also the basic user info is included in the response.
|
||||
By defult expects 2 parameters to receive: email and password.
|
||||
|
||||
- /api/signup
|
||||
|
||||
Tries to create a user and returns token if succeeded. The user info is included in the response.
|
||||
By default expects 3 parameters to receive: email, password and password_confirmation.
|
||||
|
||||
- /api/refresh
|
||||
|
||||
Tries to refresh the token and return the new token.
|
||||
By default expects 1 parameter: token.
|
||||
|
||||
- /api/invalidate
|
||||
|
||||
Tries to invalidate the given token - this can be used as an extra precaution to log the user out.
|
||||
By default expects 1 parameter: token.
|
||||
|
||||
## Environment options
|
||||
You're free to define any of this option in your project root .env.
|
||||
### JWT config
|
||||
| Variable | Default |
|
||||
| ------------- |:-------------:|
|
||||
| JWT_SECRET | |
|
||||
| JWT_TTL | 60 |
|
||||
| JWT_REFRESH_TTL | 20160 |
|
||||
| JWT_ALGO | HS256 |
|
||||
| JWT_USER_CLASS | RainLab\User\Models\User |
|
||||
| JWT_IDENTIFIER | id |
|
||||
| JWT_BLACKLIST_ENABLED | true |
|
||||
| JWT_PROVIDERS_USER | Tymon\JWTAuth\Providers\User\EloquentUserAdapter |
|
||||
| JWT_PROVIDERS_JWT | Tymon\JWTAuth\Providers\JWT\NamshiAdapter |
|
||||
| JWT_PROVIDERS_AUTH | Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter |
|
||||
| JWT_PROVIDERS_STORAGE | Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter |
|
||||
|
||||
### Laravel auth config
|
||||
| Variable | Default |
|
||||
| ------------- |:-------------:|
|
||||
| AUTH_DEFAULT_GUARD | web |
|
||||
| AUTH_DEFAULT_PASSWORDS | users |
|
||||
| AUTH_GUARDS_WEB_DRIVER | session |
|
||||
| AUTH_GUARDS_WEB_PROVIDER | users |
|
||||
| AUTH_GUARDS_API_DRIVER | token |
|
||||
| AUTH_GUARDS_API_PROVIDER | users |
|
||||
| AUTH_PROVIDERS_USERS_DRIVER | eloquent |
|
||||
| AUTH_PROVIDERS_USERS_MODEL | \RainLab\User\Models\User |
|
||||
| AUTH_PASSWORDS_USERS_PROVIDER | users |
|
||||
| AUTH_PASSWORDS_USERS_EMAIL | auth.emails.password |
|
||||
| AUTH_PASSWORDS_USERS_TABLE | password_resets |
|
||||
| AUTH_PASSWORDS_USERS_EXPIRE | 60 |
|
||||
|
||||
## Extending
|
||||
|
||||
### How to use this in another plugin?
|
||||
|
||||
Simply add `->middleware('\Tymon\JWTAuth\Middleware\GetUserFromToken')` to the end of the route in the plugin's routes.php
|
||||
|
||||
eg:
|
||||
```
|
||||
Route::post('test', function (\Request $request) {
|
||||
return response()->json(('The test was successful'));
|
||||
})->middleware('\Tymon\JWTAuth\Middleware\GetUserFromToken');
|
||||
```
|
||||
|
||||
Then when making the request set the header "Authorization" to "Bearer `{yourToken}`"
|
||||
|
||||
### How to define own set of user attributes in response?
|
||||
|
||||
For sign up and sign in add corresponding methods getAuthApiSignupAttributes or/and getAuthApiSigninAttributes to User model by extending it in your plugin's boot method:
|
||||
|
||||
```
|
||||
User::extend(function($model) {
|
||||
$model->addDynamicMethod('getAuthApiSignupAttributes', function () use ($model) {
|
||||
return [
|
||||
'my-attr' => $model->my_attr,
|
||||
];
|
||||
});
|
||||
});
|
||||
```
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php namespace Vdomah\JWTAuth\Classes;
|
||||
|
||||
use Config;
|
||||
use Vdomah\JWTAuth\Models\Settings;
|
||||
|
||||
class JWTAuthServiceProvider extends \Tymon\JWTAuth\Providers\JWTAuthServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Helper to get the config values.
|
||||
*
|
||||
* @param string $key
|
||||
* @return string
|
||||
*/
|
||||
protected function config($key, $default = null)
|
||||
{
|
||||
$val = Settings::get($key);
|
||||
|
||||
if (!$val)
|
||||
$val = Config::get('vdomah.jwtauth::' . $key);
|
||||
|
||||
return $val ?: config("jwt.$key", $default);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "vdomah/jwtauth-plugin",
|
||||
"type": "october-plugin",
|
||||
"description": "None",
|
||||
"require": {
|
||||
"composer/installers": "~1.0"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Defaults
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default authentication "guard" and password
|
||||
| reset options for your application. You may change these defaults
|
||||
| as required, but they're a perfect start for most applications.
|
||||
|
|
||||
*/
|
||||
'defaults' => [
|
||||
'guard' => env('AUTH_DEFAULT_GUARD', 'web'),
|
||||
'passwords' => env('AUTH_DEFAULT_PASSWORDS', 'users'),
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, you may define every authentication guard for your application.
|
||||
| Of course, a great default configuration has been defined for you
|
||||
| here which uses session storage and the Eloquent user provider.
|
||||
|
|
||||
| All authentication drivers have a user provider. This defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| mechanisms used by this application to persist your user's data.
|
||||
|
|
||||
| Supported: "session", "token"
|
||||
|
|
||||
*/
|
||||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => env('AUTH_GUARDS_WEB_DRIVER', 'session'),
|
||||
'provider' => env('AUTH_GUARDS_WEB_PROVIDER', 'users'),
|
||||
],
|
||||
'api' => [
|
||||
'driver' => env('AUTH_GUARDS_API_DRIVER', 'token'),
|
||||
'provider' => env('AUTH_GUARDS_API_PROVIDER', 'users'),
|
||||
],
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| All authentication drivers have a user provider. This defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| mechanisms used by this application to persist your user's data.
|
||||
|
|
||||
| If you have multiple user tables or models you may configure multiple
|
||||
| sources which represent each model / table. These sources may then
|
||||
| be assigned to any extra authentication guards you have defined.
|
||||
|
|
||||
| Supported: "database", "eloquent"
|
||||
|
|
||||
*/
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => env('AUTH_PROVIDERS_USERS_DRIVER', 'eloquent'),
|
||||
'model' => env('AUTH_PROVIDERS_USERS_MODEL', '\RainLab\User\Models\User'),
|
||||
],
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Resetting Passwords
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may set the options for resetting passwords including the view
|
||||
| that is your password reset e-mail. You may also set the name of the
|
||||
| table that maintains all of the reset tokens for your application.
|
||||
|
|
||||
| You may specify multiple password reset configurations if you have more
|
||||
| than one user table or model in the application and you want to have
|
||||
| separate password reset settings based on the specific user types.
|
||||
|
|
||||
| The expire time is the number of minutes that the reset token should be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
*/
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => env('AUTH_PASSWORDS_USERS_PROVIDER', 'users'),
|
||||
'email' => env('AUTH_PASSWORDS_USERS_EMAIL', 'auth.emails.password'),
|
||||
'table' => env('AUTH_PASSWORDS_USERS_TABLE', 'password_resets'),
|
||||
'expire' => env('AUTH_PASSWORDS_USERS_EXPIRE', 60),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| JWT Authentication Secret
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Don't forget to set this, as it will be used to sign your tokens.
|
||||
| A helper command is provided for this: `php artisan jwt:generate`
|
||||
|
|
||||
*/
|
||||
|
||||
'secret' => env('JWT_SECRET'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| JWT time to live
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the length of time (in minutes) that the token will be valid for.
|
||||
| Defaults to 1 hour
|
||||
|
|
||||
*/
|
||||
|
||||
'ttl' => env('JWT_TTL', 60),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Refresh time to live
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the length of time (in minutes) that the token can be refreshed
|
||||
| within. I.E. The user can refresh their token within a 2 week window of
|
||||
| the original token being created until they must re-authenticate.
|
||||
| Defaults to 2 weeks
|
||||
|
|
||||
*/
|
||||
|
||||
'refresh_ttl' => env('JWT_REFRESH_TTL', 20160),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| JWT hashing algorithm
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the hashing algorithm that will be used to sign the token.
|
||||
|
|
||||
| See here: https://github.com/namshi/jose/tree/2.2.0/src/Namshi/JOSE/Signer
|
||||
| for possible values
|
||||
|
|
||||
*/
|
||||
|
||||
'algo' => env('JWT_ALGO', 'HS256'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Model namespace
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the full namespace to your User model.
|
||||
| e.g. 'Acme\Entities\User'
|
||||
|
|
||||
*/
|
||||
|
||||
'user' => env('JWT_USER_CLASS', 'RainLab\User\Models\User'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User identifier
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify a unique property of the user that will be added as the 'sub'
|
||||
| claim of the token payload.
|
||||
|
|
||||
*/
|
||||
|
||||
'identifier' => env('JWT_IDENTIFIER', 'id'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Required Claims
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the required claims that must exist in any token.
|
||||
| A TokenInvalidException will be thrown if any of these claims are not
|
||||
| present in the payload.
|
||||
|
|
||||
*/
|
||||
|
||||
'required_claims' => ['iss', 'iat', 'exp', 'nbf', 'sub', 'jti'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Blacklist Enabled
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| In order to invalidate tokens, you must have the the blacklist enabled.
|
||||
| If you do not want or need this functionality, then set this to false.
|
||||
|
|
||||
*/
|
||||
|
||||
'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the various providers used throughout the package.
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Provider
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the provider that is used to find the user based
|
||||
| on the subject claim
|
||||
|
|
||||
*/
|
||||
|
||||
'user' => env('JWT_PROVIDERS_USER', 'Tymon\JWTAuth\Providers\User\EloquentUserAdapter'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| JWT Provider
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the provider that is used to create and decode the tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'jwt' => env('JWT_PROVIDERS_JWT', 'Tymon\JWTAuth\Providers\JWT\NamshiAdapter'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Provider
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the provider that is used to authenticate users.
|
||||
|
|
||||
*/
|
||||
|
||||
'auth' => env('JWT_PROVIDERS_AUTH', 'Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Storage Provider
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the provider that is used to store tokens in the blacklist
|
||||
|
|
||||
*/
|
||||
|
||||
'storage' => env('JWT_PROVIDERS_STORAGE', 'Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter'),
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php return [
|
||||
'plugin' => [
|
||||
'name' => 'JWTAuth',
|
||||
'description' => 'Provides token based authentication'
|
||||
],
|
||||
'fields' => [
|
||||
'secret' => 'Secret Key',
|
||||
'secret_comment' => 'Overrides JWT_SECRET from .env',
|
||||
'btn_generate' => 'Generate Secret Key',
|
||||
'signup_fields' => 'Signup Fields',
|
||||
'signup_fields_comment' => 'Defaults are email, password, password_confirmation',
|
||||
'login_fields' => 'Login Fields',
|
||||
'login_fields_comment' => 'Defaults are email, password',
|
||||
'section_routes_disable' => 'Disable routes',
|
||||
'is_login_disabled' => 'Login route disabled',
|
||||
'is_signup_disabled' => 'Signup route disabled',
|
||||
'is_refresh_disabled' => 'Refresh route disabled',
|
||||
'is_invalidate_disabled' => 'Invalidate route disabled',
|
||||
],
|
||||
'settings' => [
|
||||
'page_name' => 'JWTauth settings',
|
||||
'page_desc' => 'Configure jwt-auth',
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php namespace Vdomah\JWTAuth\Models;
|
||||
|
||||
use Model;
|
||||
|
||||
class Settings extends Model
|
||||
{
|
||||
public $implement = ['System.Behaviors.SettingsModel'];
|
||||
|
||||
public $settingsCode = 'vdomah_jwtauth_settings';
|
||||
|
||||
public $settingsFields = 'fields.yaml';
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php namespace Vdomah\JWTAuth\Models;
|
||||
|
||||
use RainLab\User\Models\User as UserBase;
|
||||
|
||||
class User extends UserBase
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
fields:
|
||||
secret:
|
||||
label: 'vdomah.jwtauth::lang.fields.secret'
|
||||
span: auto
|
||||
comment: 'vdomah.jwtauth::lang.fields.secret_comment'
|
||||
btn_generate:
|
||||
label: 'vdomah.jwtauth::lang.fields.btn_generate'
|
||||
span: auto
|
||||
type: partial
|
||||
path: $/vdomah/jwtauth/views/_btn_generate.htm
|
||||
|
||||
signup_fields:
|
||||
label: 'vdomah.jwtauth::lang.fields.signup_fields'
|
||||
span: auto
|
||||
type: taglist
|
||||
mode: array
|
||||
comment: 'vdomah.jwtauth::lang.fields.signup_fields_comment'
|
||||
login_fields:
|
||||
label: 'vdomah.jwtauth::lang.fields.login_fields'
|
||||
span: auto
|
||||
type: taglist
|
||||
mode: array
|
||||
comment: 'vdomah.jwtauth::lang.fields.login_fields_comment'
|
||||
|
||||
section_routes_disable:
|
||||
label: 'vdomah.jwtauth::lang.fields.section_routes_disable'
|
||||
span: full
|
||||
type: section
|
||||
is_login_disabled:
|
||||
label: 'vdomah.jwtauth::lang.fields.is_login_disabled'
|
||||
span: auto
|
||||
type: checkbox
|
||||
default: true
|
||||
is_signup_disabled:
|
||||
label: 'vdomah.jwtauth::lang.fields.is_signup_disabled'
|
||||
span: auto
|
||||
type: checkbox
|
||||
default: true
|
||||
is_refresh_disabled:
|
||||
label: 'vdomah.jwtauth::lang.fields.is_refresh_disabled'
|
||||
span: auto
|
||||
type: checkbox
|
||||
default: true
|
||||
is_invalidate_disabled:
|
||||
label: 'vdomah.jwtauth::lang.fields.is_invalidate_disabled'
|
||||
span: auto
|
||||
type: checkbox
|
||||
default: true
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
plugin:
|
||||
name: 'vdomah.jwtauth::lang.plugin.name'
|
||||
description: 'vdomah.jwtauth::lang.plugin.description'
|
||||
author: Vdomah
|
||||
icon: oc-icon-key
|
||||
homepage: 'https://github.com/vdomah/oc-jwtauth'
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
use RainLab\User\Models\User as UserModel;
|
||||
use Vdomah\JWTAuth\Models\Settings;
|
||||
|
||||
Route::group(['prefix' => 'api'], function() {
|
||||
|
||||
Route::post('login', function (Request $request) {
|
||||
if (Settings::get('is_login_disabled'))
|
||||
App::abort(404, 'Page not found');
|
||||
|
||||
$login_fields = Settings::get('login_fields', ['email', 'password']);
|
||||
|
||||
$credentials = Input::only($login_fields);
|
||||
|
||||
try {
|
||||
// verify the credentials and create a token for the user
|
||||
if (! $token = JWTAuth::attempt($credentials)) {
|
||||
return response()->json(['error' => 'invalid_credentials'], 401);
|
||||
}
|
||||
} catch (JWTException $e) {
|
||||
// something went wrong
|
||||
return response()->json(['error' => 'could_not_create_token'], 500);
|
||||
}
|
||||
|
||||
$userModel = JWTAuth::authenticate($token);
|
||||
|
||||
if ($userModel->methodExists('getAuthApiSigninAttributes')) {
|
||||
$user = $userModel->getAuthApiSigninAttributes();
|
||||
} else {
|
||||
$user = [
|
||||
'id' => $userModel->id,
|
||||
'name' => $userModel->name,
|
||||
'surname' => $userModel->surname,
|
||||
'username' => $userModel->username,
|
||||
'email' => $userModel->email,
|
||||
'is_activated' => $userModel->is_activated,
|
||||
];
|
||||
}
|
||||
// if no errors are encountered we can return a JWT
|
||||
return response()->json(compact('token', 'user'));
|
||||
});
|
||||
|
||||
Route::post('refresh', function (Request $request) {
|
||||
if (Settings::get('is_refresh_disabled'))
|
||||
App::abort(404, 'Page not found');
|
||||
|
||||
$token = Request::get('token');
|
||||
|
||||
try {
|
||||
// attempt to refresh the JWT
|
||||
if (!$token = JWTAuth::refresh($token)) {
|
||||
return response()->json(['error' => 'could_not_refresh_token'], 401);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// something went wrong
|
||||
return response()->json(['error' => 'could_not_refresh_token'], 500);
|
||||
}
|
||||
|
||||
// if no errors are encountered we can return a new JWT
|
||||
return response()->json(compact('token'));
|
||||
});
|
||||
|
||||
Route::post('invalidate', function (Request $request) {
|
||||
if (Settings::get('is_invalidate_disabled'))
|
||||
App::abort(404, 'Page not found');
|
||||
|
||||
$token = Request::get('token');
|
||||
|
||||
try {
|
||||
// invalidate the token
|
||||
JWTAuth::invalidate($token);
|
||||
} catch (Exception $e) {
|
||||
// something went wrong
|
||||
return response()->json(['error' => 'could_not_invalidate_token'], 500);
|
||||
}
|
||||
|
||||
// if no errors we can return a message to indicate that the token was invalidated
|
||||
return response()->json('token_invalidated');
|
||||
});
|
||||
|
||||
Route::post('signup', function (Request $request) {
|
||||
if (Settings::get('is_signup_disabled'))
|
||||
App::abort(404, 'Page not found');
|
||||
|
||||
$login_fields = Settings::get('signup_fields', ['email', 'password', 'password_confirmation']);
|
||||
$credentials = Input::only($login_fields);
|
||||
|
||||
try {
|
||||
$userModel = UserModel::create($credentials);
|
||||
|
||||
if ($userModel->methodExists('getAuthApiSignupAttributes')) {
|
||||
$user = $userModel->getAuthApiSignupAttributes();
|
||||
} else {
|
||||
$user = [
|
||||
'id' => $userModel->id,
|
||||
'name' => $userModel->name,
|
||||
'surname' => $userModel->surname,
|
||||
'username' => $userModel->username,
|
||||
'email' => $userModel->email,
|
||||
'is_activated' => $userModel->is_activated,
|
||||
];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return Response::json(['error' => $e->getMessage()], 401);
|
||||
}
|
||||
|
||||
$token = JWTAuth::fromUser($userModel);
|
||||
|
||||
return Response::json(compact('token', 'user'));
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
1.0.0:
|
||||
- Initialize plugin.
|
||||
1.0.1:
|
||||
- Custom service provider and config file added.
|
||||
1.0.2:
|
||||
- Compability with OctoberCMS builds > 419 (Laravel 5.5)
|
||||
1.0.3:
|
||||
- README.md updated
|
||||
1.0.4:
|
||||
- Ability to define own set of user attributes in response.
|
||||
1.0.5:
|
||||
- /refresh and /invalidate endpoints back.
|
||||
1.0.6:
|
||||
- Update README about creating route in another plugin.
|
||||
1.0.7:
|
||||
- Compability with OctoberCMS builds > 454 (Authenticatable trait removed)
|
||||
1.0.8:
|
||||
- JWT Authentication Secret default value removed from config file. README updated about how to generate the secret.
|
||||
1.0.9:
|
||||
- !!! Generate JWT Authentication Secret using php artisan jwt:generate and assign generated value to JWT_SECRET in .env
|
||||
1.0.10:
|
||||
- Backend settings to set secret key, signup/login configurable request params.
|
||||
1.0.11:
|
||||
- !!! auth.php copying to root/config/ is not required any more. .env options support added to override auth.php and config.php
|
||||
1.0.12:
|
||||
- Possibility to disable each endpoint in backend settings
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit3e1deaf74fcf6cb315868dd828db949e::getLoader();
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
$dir = __DIR__.'/..';
|
||||
|
||||
if (!file_exists($dir.'/autoload.php')) {
|
||||
$dir = __DIR__.'/../vendor';
|
||||
}
|
||||
|
||||
if (!file_exists($dir.'/autoload.php')) {
|
||||
$dir = __DIR__.'/../../..';
|
||||
}
|
||||
|
||||
if (!file_exists($dir.'/autoload.php')) {
|
||||
echo 'Autoload not found.';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$composerInstalled = false;
|
||||
|
||||
if (!file_exists($dir.'/composer/composer')) {
|
||||
$composerInstalled = true;
|
||||
shell_exec('composer require --dev composer/composer');
|
||||
}
|
||||
|
||||
include $dir.'/autoload.php';
|
||||
|
||||
Carbon\Upgrade::upgrade();
|
||||
|
||||
if ($composerInstalled) {
|
||||
shell_exec('composer remove --dev composer/composer');
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
|
@ -0,0 +1,445 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see http://www.php-fig.org/psr/psr-0/
|
||||
* @see http://www.php-fig.org/psr/psr-4/
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
// PSR-4
|
||||
private $prefixLengthsPsr4 = array();
|
||||
private $prefixDirsPsr4 = array();
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
private $prefixesPsr0 = array();
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
private $useIncludePath = false;
|
||||
private $classMap = array();
|
||||
private $classMapAuthoritative = false;
|
||||
private $missingClasses = array();
|
||||
private $apcuPrefix;
|
||||
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $classMap Class to filename map
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
if ($this->classMap) {
|
||||
$this->classMap = array_merge($this->classMap, $classMap);
|
||||
} else {
|
||||
$this->classMap = $classMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
// Register directories for a new namespace.
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 base directories
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr0 = (array) $paths;
|
||||
} else {
|
||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setPsr4($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr4 = (array) $paths;
|
||||
} else {
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns off searching the prefix and fallback directories for classes
|
||||
* that have not been registered with the class map.
|
||||
*
|
||||
* @param bool $classMapAuthoritative
|
||||
*/
|
||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||
{
|
||||
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should class lookup fail if not found in the current class map?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isClassMapAuthoritative()
|
||||
{
|
||||
return $this->classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||
*
|
||||
* @param string|null $apcuPrefix
|
||||
*/
|
||||
public function setApcuPrefix($apcuPrefix)
|
||||
{
|
||||
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The APCu prefix in use, or null if APCu caching is not enabled.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getApcuPrefix()
|
||||
{
|
||||
return $this->apcuPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return bool|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
includeFile($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|false The path if found, false otherwise
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
// class map lookup
|
||||
if (isset($this->classMap[$class])) {
|
||||
return $this->classMap[$class];
|
||||
}
|
||||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
||||
return false;
|
||||
}
|
||||
if (null !== $this->apcuPrefix) {
|
||||
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
||||
if ($hit) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
$file = $this->findFileWithExtension($class, '.php');
|
||||
|
||||
// Search for Hack files if we are running on HHVM
|
||||
if (false === $file && defined('HHVM_VERSION')) {
|
||||
$file = $this->findFileWithExtension($class, '.hh');
|
||||
}
|
||||
|
||||
if (null !== $this->apcuPrefix) {
|
||||
apcu_add($this->apcuPrefix.$class, $file);
|
||||
}
|
||||
|
||||
if (false === $file) {
|
||||
// Remember that this class does not exist.
|
||||
$this->missingClasses[$class] = true;
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||
$subPath = $class;
|
||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||
$subPath = substr($subPath, 0, $lastPos);
|
||||
$search = $subPath . '\\';
|
||||
if (isset($this->prefixDirsPsr4[$search])) {
|
||||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||
if (file_exists($file = $dir . $pathEnd)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-4 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 lookup
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||
}
|
||||
|
||||
if (isset($this->prefixesPsr0[$first])) {
|
||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 include paths.
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*/
|
||||
function includeFile($file)
|
||||
{
|
||||
include $file;
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||
|
||||
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.
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
// autoload_files.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
'bd9634f2d41831496de0d3dfe4c94881' => $vendorDir . '/symfony/polyfill-php56/bootstrap.php',
|
||||
);
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'UpdateHelper\\' => array($vendorDir . '/kylekatarnls/update-helper/src'),
|
||||
);
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Tymon\\JWTAuth\\' => array($vendorDir . '/tymon/jwt-auth/src'),
|
||||
'Symfony\\Polyfill\\Util\\' => array($vendorDir . '/symfony/polyfill-util'),
|
||||
'Symfony\\Polyfill\\Php56\\' => array($vendorDir . '/symfony/polyfill-php56'),
|
||||
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
|
||||
'Symfony\\Contracts\\Translation\\' => array($vendorDir . '/symfony/translation-contracts'),
|
||||
'Symfony\\Component\\Translation\\' => array($vendorDir . '/symfony/translation'),
|
||||
'Namshi\\JOSE\\' => array($vendorDir . '/namshi/jose/src/Namshi/JOSE'),
|
||||
'' => array($vendorDir . '/nesbot/carbon/src'),
|
||||
);
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit3e1deaf74fcf6cb315868dd828db949e
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit3e1deaf74fcf6cb315868dd828db949e', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit3e1deaf74fcf6cb315868dd828db949e', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require_once __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit3e1deaf74fcf6cb315868dd828db949e::getInitializer($loader));
|
||||
} else {
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
|
||||
$map = require __DIR__ . '/autoload_psr4.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->setPsr4($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
}
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit3e1deaf74fcf6cb315868dd828db949e::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire3e1deaf74fcf6cb315868dd828db949e($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire3e1deaf74fcf6cb315868dd828db949e($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
// autoload_static.php @generated by Composer
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit3e1deaf74fcf6cb315868dd828db949e
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
'bd9634f2d41831496de0d3dfe4c94881' => __DIR__ . '/..' . '/symfony/polyfill-php56/bootstrap.php',
|
||||
);
|
||||
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
'T' =>
|
||||
array (
|
||||
'Tymon\\JWTAuth\\' => 14,
|
||||
),
|
||||
'S' =>
|
||||
array (
|
||||
'Symfony\\Polyfill\\Util\\' => 22,
|
||||
'Symfony\\Polyfill\\Php56\\' => 23,
|
||||
'Symfony\\Polyfill\\Mbstring\\' => 26,
|
||||
'Symfony\\Contracts\\Translation\\' => 30,
|
||||
'Symfony\\Component\\Translation\\' => 30,
|
||||
),
|
||||
'N' =>
|
||||
array (
|
||||
'Namshi\\JOSE\\' => 12,
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixDirsPsr4 = array (
|
||||
'Tymon\\JWTAuth\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/tymon/jwt-auth/src',
|
||||
),
|
||||
'Symfony\\Polyfill\\Util\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/polyfill-util',
|
||||
),
|
||||
'Symfony\\Polyfill\\Php56\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/polyfill-php56',
|
||||
),
|
||||
'Symfony\\Polyfill\\Mbstring\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
|
||||
),
|
||||
'Symfony\\Contracts\\Translation\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/translation-contracts',
|
||||
),
|
||||
'Symfony\\Component\\Translation\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/translation',
|
||||
),
|
||||
'Namshi\\JOSE\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/namshi/jose/src/Namshi/JOSE',
|
||||
),
|
||||
);
|
||||
|
||||
public static $fallbackDirsPsr4 = array (
|
||||
0 => __DIR__ . '/..' . '/nesbot/carbon/src',
|
||||
);
|
||||
|
||||
public static $prefixesPsr0 = array (
|
||||
'U' =>
|
||||
array (
|
||||
'UpdateHelper\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/kylekatarnls/update-helper/src',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit3e1deaf74fcf6cb315868dd828db949e::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit3e1deaf74fcf6cb315868dd828db949e::$prefixDirsPsr4;
|
||||
$loader->fallbackDirsPsr4 = ComposerStaticInit3e1deaf74fcf6cb315868dd828db949e::$fallbackDirsPsr4;
|
||||
$loader->prefixesPsr0 = ComposerStaticInit3e1deaf74fcf6cb315868dd828db949e::$prefixesPsr0;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,552 @@
|
|||
[
|
||||
{
|
||||
"name": "kylekatarnls/update-helper",
|
||||
"version": "1.2.1",
|
||||
"version_normalized": "1.2.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/kylekatarnls/update-helper.git",
|
||||
"reference": "429be50660ed8a196e0798e5939760f168ec8ce9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/kylekatarnls/update-helper/zipball/429be50660ed8a196e0798e5939760f168ec8ce9",
|
||||
"reference": "429be50660ed8a196e0798e5939760f168ec8ce9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"composer-plugin-api": "^1.1.0 || ^2.0.0",
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"codeclimate/php-test-reporter": "dev-master",
|
||||
"composer/composer": "2.0.x-dev || ^2.0.0-dev",
|
||||
"phpunit/phpunit": ">=4.8.35 <6.0"
|
||||
},
|
||||
"time": "2020-04-07T20:44:10+00:00",
|
||||
"type": "composer-plugin",
|
||||
"extra": {
|
||||
"class": "UpdateHelper\\ComposerPlugin"
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"UpdateHelper\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kyle",
|
||||
"email": "kylekatarnls@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Update helper"
|
||||
},
|
||||
{
|
||||
"name": "namshi/jose",
|
||||
"version": "7.2.3",
|
||||
"version_normalized": "7.2.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/namshi/jose.git",
|
||||
"reference": "89a24d7eb3040e285dd5925fcad992378b82bcff"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/namshi/jose/zipball/89a24d7eb3040e285dd5925fcad992378b82bcff",
|
||||
"reference": "89a24d7eb3040e285dd5925fcad992378b82bcff",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-date": "*",
|
||||
"ext-hash": "*",
|
||||
"ext-json": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-spl": "*",
|
||||
"php": ">=5.5",
|
||||
"symfony/polyfill-php56": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpseclib/phpseclib": "^2.0",
|
||||
"phpunit/phpunit": "^4.5|^5.0",
|
||||
"satooshi/php-coveralls": "^1.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-openssl": "Allows to use OpenSSL as crypto engine.",
|
||||
"phpseclib/phpseclib": "Allows to use Phpseclib as crypto engine, use version ^2.0."
|
||||
},
|
||||
"time": "2016-12-05T07:27:31+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Namshi\\JOSE\\": "src/Namshi/JOSE/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alessandro Nadalin",
|
||||
"email": "alessandro.nadalin@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Alessandro Cinelli (cirpo)",
|
||||
"email": "alessandro.cinelli@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "JSON Object Signing and Encryption library for PHP.",
|
||||
"keywords": [
|
||||
"JSON Web Signature",
|
||||
"JSON Web Token",
|
||||
"JWS",
|
||||
"json",
|
||||
"jwt",
|
||||
"token"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
"version": "1.39.1",
|
||||
"version_normalized": "1.39.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/briannesbitt/Carbon.git",
|
||||
"reference": "4be0c005164249208ce1b5ca633cd57bdd42ff33"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/4be0c005164249208ce1b5ca633cd57bdd42ff33",
|
||||
"reference": "4be0c005164249208ce1b5ca633cd57bdd42ff33",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"kylekatarnls/update-helper": "^1.1",
|
||||
"php": ">=5.3.9",
|
||||
"symfony/translation": "~2.6 || ~3.0 || ~4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "^1.2",
|
||||
"friendsofphp/php-cs-fixer": "~2",
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7"
|
||||
},
|
||||
"time": "2019-10-14T05:51:36+00:00",
|
||||
"bin": [
|
||||
"bin/upgrade-carbon"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"update-helper": "Carbon\\Upgrade",
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Carbon\\Laravel\\ServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Brian Nesbitt",
|
||||
"email": "brian@nesbot.com",
|
||||
"homepage": "http://nesbot.com"
|
||||
}
|
||||
],
|
||||
"description": "A simple API extension for DateTime.",
|
||||
"homepage": "http://carbon.nesbot.com",
|
||||
"keywords": [
|
||||
"date",
|
||||
"datetime",
|
||||
"time"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-mbstring",
|
||||
"version": "dev-master",
|
||||
"version_normalized": "9999999-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||
"reference": "fa79b11539418b02fc5e1897267673ba2c19419c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fa79b11539418b02fc5e1897267673ba2c19419c",
|
||||
"reference": "fa79b11539418b02fc5e1897267673ba2c19419c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring": "For best performance"
|
||||
},
|
||||
"time": "2020-05-12T16:47:27+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.17-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "source",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Mbstring\\": ""
|
||||
},
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill for the Mbstring extension",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"mbstring",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php56",
|
||||
"version": "dev-master",
|
||||
"version_normalized": "9999999-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php56.git",
|
||||
"reference": "e3c8c138280cdfe4b81488441555583aa1984e23"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/e3c8c138280cdfe4b81488441555583aa1984e23",
|
||||
"reference": "e3c8c138280cdfe4b81488441555583aa1984e23",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"symfony/polyfill-util": "~1.0"
|
||||
},
|
||||
"time": "2020-05-12T16:47:27+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.17-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "source",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Php56\\": ""
|
||||
},
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-util",
|
||||
"version": "dev-master",
|
||||
"version_normalized": "9999999-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-util.git",
|
||||
"reference": "4afb4110fc037752cf0ce9869f9ab8162c4e20d7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-util/zipball/4afb4110fc037752cf0ce9869f9ab8162c4e20d7",
|
||||
"reference": "4afb4110fc037752cf0ce9869f9ab8162c4e20d7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"time": "2020-05-12T16:14:59+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.17-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "source",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Util\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony utilities for portability of PHP codes",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compat",
|
||||
"compatibility",
|
||||
"polyfill",
|
||||
"shim"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "symfony/translation",
|
||||
"version": "4.4.x-dev",
|
||||
"version_normalized": "4.4.9999999.9999999-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/translation.git",
|
||||
"reference": "46df2290b5dc8a53b4ded00f7e4b49e4ccd2a388"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/translation/zipball/46df2290b5dc8a53b4ded00f7e4b49e4ccd2a388",
|
||||
"reference": "46df2290b5dc8a53b4ded00f7e4b49e4ccd2a388",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"symfony/polyfill-mbstring": "~1.0",
|
||||
"symfony/translation-contracts": "^1.1.6|^2"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/config": "<3.4",
|
||||
"symfony/dependency-injection": "<3.4",
|
||||
"symfony/http-kernel": "<4.4",
|
||||
"symfony/yaml": "<3.4"
|
||||
},
|
||||
"provide": {
|
||||
"symfony/translation-implementation": "1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/log": "~1.0",
|
||||
"symfony/config": "^3.4|^4.0|^5.0",
|
||||
"symfony/console": "^3.4|^4.0|^5.0",
|
||||
"symfony/dependency-injection": "^3.4|^4.0|^5.0",
|
||||
"symfony/finder": "~2.8|~3.0|~4.0|^5.0",
|
||||
"symfony/http-kernel": "^4.4",
|
||||
"symfony/intl": "^3.4|^4.0|^5.0",
|
||||
"symfony/service-contracts": "^1.1.2|^2",
|
||||
"symfony/yaml": "^3.4|^4.0|^5.0"
|
||||
},
|
||||
"suggest": {
|
||||
"psr/log-implementation": "To use logging capability in translator",
|
||||
"symfony/config": "",
|
||||
"symfony/yaml": ""
|
||||
},
|
||||
"time": "2020-05-04T15:32:48+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.4-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "source",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Translation\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Translation Component",
|
||||
"homepage": "https://symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "symfony/translation-contracts",
|
||||
"version": "dev-master",
|
||||
"version_normalized": "9999999-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/translation-contracts.git",
|
||||
"reference": "cfa7f3f5bda0cffdb415d41dd86aa980a3837218"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/translation-contracts/zipball/cfa7f3f5bda0cffdb415d41dd86aa980a3837218",
|
||||
"reference": "cfa7f3f5bda0cffdb415d41dd86aa980a3837218",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/translation-implementation": ""
|
||||
},
|
||||
"time": "2020-05-08T21:41:03+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.1-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "source",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Contracts\\Translation\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Generic abstractions related to translation",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"abstractions",
|
||||
"contracts",
|
||||
"decoupling",
|
||||
"interfaces",
|
||||
"interoperability",
|
||||
"standards"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "tymon/jwt-auth",
|
||||
"version": "0.5.12",
|
||||
"version_normalized": "0.5.12.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tymondesigns/jwt-auth.git",
|
||||
"reference": "614ee3410a1cc18ef13c8d5ffd491b5608afabd8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/tymondesigns/jwt-auth/zipball/614ee3410a1cc18ef13c8d5ffd491b5608afabd8",
|
||||
"reference": "614ee3410a1cc18ef13c8d5ffd491b5608afabd8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/http": "~5.0",
|
||||
"illuminate/support": "~5.0",
|
||||
"namshi/jose": "^5.0 || ^7.0",
|
||||
"nesbot/carbon": "~1.0",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"illuminate/auth": "~5.0",
|
||||
"illuminate/console": "~5.0",
|
||||
"illuminate/database": "~5.0",
|
||||
"mockery/mockery": "0.9.*",
|
||||
"phpunit/phpunit": "4.*"
|
||||
},
|
||||
"time": "2017-06-07T21:32:02+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-develop": "0.5-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Tymon\\JWTAuth\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sean Tymon",
|
||||
"email": "tymon148@gmail.com",
|
||||
"homepage": "http://tymondesigns.com",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "JSON Web Token Authentication for Laravel 4 and 5",
|
||||
"homepage": "https://github.com/tymondesigns/jwt-auth",
|
||||
"keywords": [
|
||||
"Authentication",
|
||||
"JSON Web Token",
|
||||
"auth",
|
||||
"jwt",
|
||||
"laravel",
|
||||
"tymon"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 https://github.com/pug-php
|
||||
Copyright (c) 2017 https://github.com/kylekatarnls
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"name": "kylekatarnls/update-helper",
|
||||
"description": "Update helper",
|
||||
"type": "composer-plugin",
|
||||
"license": "MIT",
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kyle",
|
||||
"email": "kylekatarnls@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"composer-plugin-api": "^1.1.0 || ^2.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "2.0.x-dev || ^2.0.0-dev",
|
||||
"phpunit/phpunit": ">=4.8.35 <6.0",
|
||||
"codeclimate/php-test-reporter": "dev-master"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"UpdateHelper\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"UpdateHelper\\Tests\\": "tests/UpdateHelper/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-install-cmd": [
|
||||
"UpdateHelper\\UpdateHelper::check"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"UpdateHelper\\UpdateHelper::check"
|
||||
],
|
||||
"post-package-install": [
|
||||
"UpdateHelper\\UpdateHelper::check"
|
||||
],
|
||||
"post-package-update": [
|
||||
"UpdateHelper\\UpdateHelper::check"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"class": "UpdateHelper\\ComposerPlugin"
|
||||
}
|
||||
}
|
||||
47
plugins/vdomah/jwtauth/vendor/kylekatarnls/update-helper/src/UpdateHelper/ComposerPlugin.php
vendored
Normal file
47
plugins/vdomah/jwtauth/vendor/kylekatarnls/update-helper/src/UpdateHelper/ComposerPlugin.php
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace UpdateHelper;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\EventDispatcher\Event;
|
||||
use Composer\EventDispatcher\EventSubscriberInterface;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Plugin\PluginInterface;
|
||||
|
||||
class ComposerPlugin implements PluginInterface, EventSubscriberInterface
|
||||
{
|
||||
protected $io;
|
||||
|
||||
public function activate(Composer $composer, IOInterface $io)
|
||||
{
|
||||
$this->io = $io;
|
||||
}
|
||||
|
||||
public function deactivate(Composer $composer, IOInterface $io)
|
||||
{
|
||||
// Not needed
|
||||
}
|
||||
|
||||
public function uninstall(Composer $composer, IOInterface $io)
|
||||
{
|
||||
// Not needed
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
'post-autoload-dump' => array(
|
||||
array('onAutoloadDump', 0),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function onAutoloadDump(Event $event)
|
||||
{
|
||||
if (!class_exists('UpdateHelper\\UpdateHelper')) {
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateHelper::check($event);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace UpdateHelper;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
class NotUpdateInterfaceInstanceException extends InvalidArgumentException
|
||||
{
|
||||
}
|
||||
391
plugins/vdomah/jwtauth/vendor/kylekatarnls/update-helper/src/UpdateHelper/UpdateHelper.php
vendored
Normal file
391
plugins/vdomah/jwtauth/vendor/kylekatarnls/update-helper/src/UpdateHelper/UpdateHelper.php
vendored
Normal file
|
|
@ -0,0 +1,391 @@
|
|||
<?php
|
||||
|
||||
namespace UpdateHelper;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\EventDispatcher\Event;
|
||||
use Composer\Installer\PackageEvent;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Json\JsonFile;
|
||||
use Composer\Script\Event as ScriptEvent;
|
||||
use Composer\Semver\Semver;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
class UpdateHelper
|
||||
{
|
||||
/** @var Event */
|
||||
private $event;
|
||||
/** @var IOInterface|null */
|
||||
private $io;
|
||||
/** @var Composer */
|
||||
private $composer;
|
||||
/** @var array */
|
||||
private $dependencies = array();
|
||||
/** @var string */
|
||||
private $composerFilePath;
|
||||
/** @var JsonFile */
|
||||
private $file;
|
||||
|
||||
protected static function appendConfig(&$classes, $directory, $key = null)
|
||||
{
|
||||
$file = $directory.DIRECTORY_SEPARATOR.'composer.json';
|
||||
$json = new JsonFile($file);
|
||||
$key = $key ? $key : 'update-helper';
|
||||
|
||||
try {
|
||||
$dependencyConfig = $json->read();
|
||||
} catch (Exception $e) {
|
||||
$dependencyConfig = null;
|
||||
}
|
||||
|
||||
if (is_array($dependencyConfig) && isset($dependencyConfig['extra'], $dependencyConfig['extra'][$key])) {
|
||||
$classes[$file] = $dependencyConfig['extra'][$key];
|
||||
}
|
||||
}
|
||||
|
||||
protected static function getUpdateHelperConfig(Composer $composer, $key = null)
|
||||
{
|
||||
$vendorDir = $composer->getConfig()->get('vendor-dir');
|
||||
|
||||
$npm = array();
|
||||
|
||||
foreach (scandir($vendorDir) as $namespace) {
|
||||
if ($namespace === '.' || $namespace === '..' || !is_dir($directory = $vendorDir.DIRECTORY_SEPARATOR.$namespace)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (scandir($directory) as $dependency) {
|
||||
if ($dependency === '.' || $dependency === '..' || !is_dir($subDirectory = $directory.DIRECTORY_SEPARATOR.$dependency)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
static::appendConfig($npm, $subDirectory, $key);
|
||||
}
|
||||
}
|
||||
|
||||
static::appendConfig($npm, dirname($vendorDir), $key);
|
||||
|
||||
return $npm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Event $event
|
||||
* @param IOInterface $io
|
||||
* @param Composer $composer
|
||||
* @param string[] $subClasses
|
||||
*/
|
||||
protected static function checkHelper($event, IOInterface $io, $composer, $class)
|
||||
{
|
||||
if (!is_string($class) || !class_exists($class)) {
|
||||
throw new NotUpdateInterfaceInstanceException();
|
||||
}
|
||||
|
||||
try {
|
||||
$helper = new $class();
|
||||
} catch (Exception $e) {
|
||||
throw new InvalidArgumentException($e->getMessage(), 1000, $e);
|
||||
} catch (Throwable $e) {
|
||||
throw new InvalidArgumentException($e->getMessage(), 1000, $e);
|
||||
}
|
||||
|
||||
if (!($helper instanceof UpdateHelperInterface)) {
|
||||
throw new NotUpdateInterfaceInstanceException();
|
||||
}
|
||||
|
||||
$helper->check(new static($event, $io, $composer));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param Event $event
|
||||
* @param IOInterface $io
|
||||
* @param Composer $composer
|
||||
* @param string[] $subClasses
|
||||
*/
|
||||
protected static function checkFileHelpers($file, $event, IOInterface $io, $composer, array $subClasses)
|
||||
{
|
||||
foreach ($subClasses as $class) {
|
||||
try {
|
||||
static::checkHelper($event, $io, $composer, $class);
|
||||
} catch (InvalidArgumentException $exception) {
|
||||
$io->writeError(static::getErrorMessage($exception, $file, $class));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static function getErrorMessage(InvalidArgumentException $exception, $file, $class)
|
||||
{
|
||||
if ($exception instanceof NotUpdateInterfaceInstanceException) {
|
||||
return 'UpdateHelper error in '.$file.":\n".JsonFile::encode($class).' is not an instance of UpdateHelperInterface.';
|
||||
}
|
||||
|
||||
return 'UpdateHelper error: '.$exception->getPrevious()->getMessage().
|
||||
"\nFile: ".$exception->getPrevious()->getFile().
|
||||
"\nLine:".$exception->getPrevious()->getLine().
|
||||
"\n\n".$exception->getPrevious()->getTraceAsString();
|
||||
}
|
||||
|
||||
public static function check(Event $event)
|
||||
{
|
||||
if (!($event instanceof ScriptEvent) && !($event instanceof PackageEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$io = $event->getIO();
|
||||
$composer = $event->getComposer();
|
||||
$autoload = $composer->getConfig()->get('vendor-dir').'/autoload.php';
|
||||
|
||||
if (file_exists($autoload)) {
|
||||
include_once $autoload;
|
||||
}
|
||||
|
||||
$classes = static::getUpdateHelperConfig($composer);
|
||||
|
||||
foreach ($classes as $file => $subClasses) {
|
||||
static::checkFileHelpers($file, $event, $io, $composer, (array) $subClasses);
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct(Event $event, IOInterface $io = null, Composer $composer = null)
|
||||
{
|
||||
$this->event = $event;
|
||||
$this->io = $io ?: (method_exists($event, 'getIO') ? $event->getIO() : null);
|
||||
$this->composer = $composer ?: (method_exists($event, 'getComposer') ? $event->getComposer() : null);
|
||||
|
||||
if ($this->composer &&
|
||||
($directory = $this->composer->getConfig()->get('archive-dir')) &&
|
||||
file_exists($file = $directory.'/composer.json')
|
||||
) {
|
||||
$this->composerFilePath = $file;
|
||||
$this->file = new JsonFile($this->composerFilePath);
|
||||
$this->dependencies = $this->file->read();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return JsonFile
|
||||
*/
|
||||
public function getFile()
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getComposerFilePath()
|
||||
{
|
||||
return $this->composerFilePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Composer
|
||||
*/
|
||||
public function getComposer()
|
||||
{
|
||||
return $this->composer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Event
|
||||
*/
|
||||
public function getEvent()
|
||||
{
|
||||
return $this->event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IOInterface|null
|
||||
*/
|
||||
public function getIo()
|
||||
{
|
||||
return $this->io;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDependencies()
|
||||
{
|
||||
return $this->dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDevDependencies()
|
||||
{
|
||||
return isset($this->dependencies['require-dev']) ? $this->dependencies['require-dev'] : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getProdDependencies()
|
||||
{
|
||||
return isset($this->dependencies['require']) ? $this->dependencies['require'] : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFlattenDependencies()
|
||||
{
|
||||
return array_merge($this->getDevDependencies(), $this->getProdDependencies());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dependency
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAsDevDependency($dependency)
|
||||
{
|
||||
return isset($this->dependencies['require-dev'][$dependency]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dependency
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAsProdDependency($dependency)
|
||||
{
|
||||
return isset($this->dependencies['require'][$dependency]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dependency
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAsDependency($dependency)
|
||||
{
|
||||
return $this->hasAsDevDependency($dependency) || $this->hasAsProdDependency($dependency);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dependency
|
||||
* @param string $version
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDependencyAtLeast($dependency, $version)
|
||||
{
|
||||
if ($this->hasAsProdDependency($dependency)) {
|
||||
return Semver::satisfies($version, $this->dependencies['require'][$dependency]);
|
||||
}
|
||||
|
||||
if ($this->hasAsDevDependency($dependency)) {
|
||||
return Semver::satisfies($version, $this->dependencies['require-dev'][$dependency]);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dependency
|
||||
* @param string $version
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDependencyLesserThan($dependency, $version)
|
||||
{
|
||||
return !$this->isDependencyAtLeast($dependency, $version);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dependency
|
||||
* @param string $version
|
||||
* @param array $environments
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDependencyVersion($dependency, $version, $environments = array('require', 'require-dev'))
|
||||
{
|
||||
return $this->setDependencyVersions(array($dependency => $version), $environments);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $dependencies
|
||||
* @param array $environments
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDependencyVersions($dependencies, $environments = array('require', 'require-dev'))
|
||||
{
|
||||
if (!$this->composerFilePath) {
|
||||
throw new RuntimeException('No composer instance detected.');
|
||||
}
|
||||
|
||||
$touched = false;
|
||||
|
||||
foreach ($environments as $environment) {
|
||||
foreach ($dependencies as $dependency => $version) {
|
||||
if (isset($this->dependencies[$environment], $this->dependencies[$environment][$dependency])) {
|
||||
$this->dependencies[$environment][$dependency] = $version;
|
||||
$touched = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($touched) {
|
||||
if (!$this->composerFilePath) {
|
||||
throw new RuntimeException('composer.json not found (custom vendor-dir are not yet supported).');
|
||||
}
|
||||
|
||||
$file = new JsonFile($this->composerFilePath);
|
||||
$file->write($this->dependencies);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$output = shell_exec('composer update --no-scripts');
|
||||
|
||||
if (!empty($output)) {
|
||||
$this->write($output);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $text
|
||||
*/
|
||||
public function write($text)
|
||||
{
|
||||
if ($this->io) {
|
||||
$this->io->write($text);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_array($text)) {
|
||||
$text = implode("\n", $text);
|
||||
}
|
||||
|
||||
echo $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isInteractive()
|
||||
{
|
||||
return $this->io && $this->io->isInteractive();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace UpdateHelper;
|
||||
|
||||
interface UpdateHelperInterface
|
||||
{
|
||||
public function check(UpdateHelper $helper);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
### 6.1.0
|
||||
|
||||
- Dropped support for PHP 5.4
|
||||
- phpseclib ~2.0.x
|
||||
|
||||
### 6.0.4
|
||||
|
||||
- Added styleci config, add styleci-php-cs bridge to check formatting
|
||||
- Removed composer.lock
|
||||
- Fix #34: strlen() and substr() can misbehave with mbstring.func_overload
|
||||
- Fix: Don't cast to boolean the result of openssl_verify()
|
||||
- Enhancement: support phpseclib 1.x.x
|
||||
|
||||
### 6.x.x - Not Backwards Compatible
|
||||
|
||||
- Dropped support for PHP 5.3
|
||||
- Don't escape slashes when generating signin input.
|
||||
This may render tokens generated with earlier versions of Jose incompatible.
|
||||
- **DON'T** install version 6.0.2! It's using phpseclib version 2 instead of version 1 and some classes are broken
|
||||
|
||||
### 3.x.x to 4.x.x - Not Backwards Compatible
|
||||
|
||||
Added the ability to set custom properties in the header. Moved automatic inclusion of certain claims into an SimpleJWS class from the base JWS class.
|
||||
|
||||
### 2.x.x to 3.x.x
|
||||
|
||||
Introduced the ability to specify an encryption engine. Added support of PHPSecLib to the existing OpenSSL implementation.
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License
|
||||
|
||||
Copyright (c) 2014 Alessandro Nadalin
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
# NAMSHI | JOSE
|
||||
|
||||
[](https://travis-ci.org/namshi/jose)
|
||||
[](https://packagist.org/packages/namshi/jose)
|
||||
[](https://packagist.org/packages/namshi/jose)
|
||||
[](https://packagist.org/packages/namshi/jose)
|
||||
|
||||
This library provides a lightweight
|
||||
implementation of the JWS
|
||||
([JSON Web Signature](http://tools.ietf.org/html/draft-jones-json-web-signature-04)) specification.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
This library needs PHP 5.5+ and the library OpenSSL.
|
||||
|
||||
It has been tested using `PHP5.5` to `PHP7.0` and `HHVM`.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
You can install the library directly from
|
||||
composer / [packagist](https://packagist.org/packages/namshi/jose):
|
||||
|
||||
```
|
||||
"namshi/jose": "7.0.*"
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Using it is pretty straightforward:
|
||||
imagine that you want to offer a service
|
||||
the ability to authenticate a user via
|
||||
a cookie, and the service is built with
|
||||
javascript; what you would need to do is
|
||||
to generate a JWS (after verifying the
|
||||
credentials once), store it as a cookie
|
||||
and then pass it from your JavaScript app
|
||||
everytime you want to authenticate that
|
||||
user.
|
||||
|
||||
First, generate the JWS:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
|
||||
use Namshi\JOSE\SimpleJWS;
|
||||
|
||||
if ($username == 'correctUsername' && $pass == 'ok') {
|
||||
$user = Db::loadUserByUsername($username);
|
||||
|
||||
$jws = new SimpleJWS(array(
|
||||
'alg' => 'RS256'
|
||||
));
|
||||
$jws->setPayload(array(
|
||||
'uid' => $user->getid(),
|
||||
));
|
||||
|
||||
$privateKey = openssl_pkey_get_private("file://path/to/private.key", self::SSL_KEY_PASSPHRASE);
|
||||
$jws->sign($privateKey);
|
||||
setcookie('identity', $jws->getTokenString());
|
||||
}
|
||||
```
|
||||
|
||||
Then your JS app can use the available cookie to execute
|
||||
authenticated calls, without sending passwords or credentials.
|
||||
|
||||
Once a request is submitted, you only have to verify that it
|
||||
is a valid call:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
|
||||
use Namshi\JOSE\SimpleJWS;
|
||||
|
||||
$jws = SimpleJWS::load($_COOKIE['identity']);
|
||||
$public_key = openssl_pkey_get_public("/path/to/public.key");
|
||||
|
||||
// verify that the token is valid and had the same values
|
||||
// you emitted before while setting it as a cookie
|
||||
if ($jws->isValid($public_key, 'RS256')) {
|
||||
$payload = $jws->getPayload();
|
||||
|
||||
echo sprintf("Hey, my JS app just did an action authenticated as user #%s", $payload['uid']);
|
||||
}
|
||||
```
|
||||
|
||||
> PROTIP: you can omit the second argument of the isValid() method, so jose will try to validate the token with the algorithm specified in the token's header, though this might expose you to some security issues.
|
||||
>
|
||||
> For now we recommend to always explicitely set the algorithm you want to use to validate tokens.
|
||||
|
||||
### PHPSECLIB For RSA Verification
|
||||
|
||||
You may find that you need to use this library in an environment where
|
||||
[PHP's wrappers for OpenSSL](http://php.net/manual/en/ref.openssl.php)
|
||||
do not work, or OpenSSL simply is not installed. This library uses
|
||||
OpenSSL to encrypt by default, but you can specify that you want to use [PHPSecLib](http://phpseclib.sourceforge.net/) for a pure PHP
|
||||
implementation of RSA encryption.
|
||||
|
||||
In these cases, simply add the optional `'SecLib'` parameter when
|
||||
constructing a JWS:
|
||||
|
||||
```php
|
||||
$jws = new JWS(array('alg' => 'RS256'), 'SecLib');
|
||||
```
|
||||
|
||||
You can now use the PHPSecLib implementation of RSA signing. If you use
|
||||
a password protected private key, you can still submit the private key
|
||||
to use for signing as a string, as long as you pass the password as the
|
||||
second parameter into the `sign` method:
|
||||
|
||||
```php
|
||||
$jws->sign(file_get_contents(SSL_KEYS_PATH . "private.key"), 'tests');
|
||||
```
|
||||
|
||||
You may also load a JWS using the PHPSecLib implementation of RSA verification:
|
||||
|
||||
```php
|
||||
$jws = JWS::load($tokenString, false, $encoder, 'SecLib');
|
||||
```
|
||||
|
||||
## Under the hood
|
||||
|
||||
In order to [validate the JWS](https://github.com/namshi/jose/blob/master/src/Namshi/JOSE/SimpleJWS.php#L43),
|
||||
the signature is first [verified](https://github.com/namshi/jose/blob/master/src/Namshi/JOSE/JWS.php#L113)
|
||||
with a public key and then we will check whether the [token is expired](https://github.com/namshi/jose/blob/master/src/Namshi/JOSE/SimpleJWS.php#L55).
|
||||
|
||||
To give a JWS a TTL, just use the standard `exp` value in the payload:
|
||||
|
||||
``` php
|
||||
$date = new DateTime('tomorrow');
|
||||
$this->jws = new SimpleJWS(array('alg' => 'RS256'));
|
||||
$this->jws->setPayload(array(
|
||||
'exp' => $date->format('U'),
|
||||
));
|
||||
```
|
||||
|
||||
### Unsecure JWSes
|
||||
|
||||
You can allow [unsecure JWSes](https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40#page-12)
|
||||
by setting the `$allowUnsecure` flag while loading JWSes:
|
||||
|
||||
``` php
|
||||
JWS::load($this->jws->getTokenString(), true);
|
||||
```
|
||||
|
||||
This allows tokens signed with the 'none' algorithms to go through, which is something
|
||||
you probably don't want to do. Proceed with caution :)
|
||||
|
||||
**Unsecure JWSes are disabled by default since version 2.2.2. You should **not**
|
||||
use previous versions other than 2.2.2 as they have a security
|
||||
vulnerability. More info [here](http://tech.namshi.com/blog/2015/02/19/update-your-namshi-slash-jose-installations-as-a-security-vulnerability-was-found/).**
|
||||
|
||||
## Using a custom encoder
|
||||
|
||||
If, for some reason, you need to encode the token in a different way, you can
|
||||
inject any implementation of `Namshi\JOSE\Base64\Encoder` in a `JWS` instance.
|
||||
Likewise, `JWS::load()` accepts such an implementation as a second argument.
|
||||
|
||||
## Implementation Specifics
|
||||
|
||||
The library provides a base JWT Class that implements what is needed just for JSON Web Tokens. The JWS Class then extends
|
||||
the JWT class and adds the implementation for signing and verifying using JSON Web Signatures. The SimpleJWS class extends
|
||||
the base JWS class and adds validation of a TTL and inclusion of automatic claims.
|
||||
|
||||
## Major Versions
|
||||
|
||||
### 2.x.x to 3.x.x
|
||||
|
||||
Introduced the ability to specify an encryption engine. Added support of PHPSecLib to the existing OpenSSL implementation.
|
||||
|
||||
### 3.x.x to 4.x.x - Not Backwards Compatible
|
||||
|
||||
Added the ability to set custom properties in the header. Moved automatic inclusion of certain claims into an SimpleJWS class from the base JWS class.
|
||||
|
||||
### 6.x.x - Not Backwards Compatible
|
||||
|
||||
#### 6.1.x
|
||||
- Dropped support for PHP 5.4
|
||||
- phpseclib 2.0
|
||||
|
||||
#### 6.0.x
|
||||
- Dropped support for PHP 5.3
|
||||
- Don't escape slashes when generating signin input.
|
||||
This may render tokens generated with earlier versions of Jose incompatible.
|
||||
|
||||
### 7.x.x
|
||||
|
||||
#### 7.0.x
|
||||
|
||||
Moved phpseclib and the openssl extension as suggested dependencies.
|
||||
|
||||
## Tests
|
||||
|
||||
Tests are written using PHPUnit for this library. After doing composer install you can execute the following command to run tests:
|
||||
|
||||
```
|
||||
./vendor/bin/phpunit
|
||||
```
|
||||
|
||||
## Credits
|
||||
|
||||
This library has been inspired by the
|
||||
[initial work done by @ritou](https://github.com/ritou/php-Akita_JOSE).
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"name": "namshi/jose",
|
||||
"description": "JSON Object Signing and Encryption library for PHP.",
|
||||
"license": "MIT",
|
||||
"keywords": ["jws", "jwt", "json", "json web token", "json web signature", "token"],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alessandro Nadalin",
|
||||
"email": "alessandro.nadalin@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Alessandro Cinelli (cirpo)",
|
||||
"email": "alessandro.cinelli@gmail.com"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Namshi\\JOSE\\": "src/Namshi/JOSE/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Namshi\\JOSE\\Test\\": "test/Namshi/JOSE/Test/"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"ext-date": "*",
|
||||
"ext-hash": "*",
|
||||
"ext-json": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-spl": "*",
|
||||
"php": ">=5.5",
|
||||
"symfony/polyfill-php56": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.5|^5.0",
|
||||
"satooshi/php-coveralls": "^1.0",
|
||||
"phpseclib/phpseclib": "^2.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-openssl": "Allows to use OpenSSL as crypto engine.",
|
||||
"phpseclib/phpseclib": "Allows to use Phpseclib as crypto engine, use version ^2.0."
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
beStrictAboutTestsThatDoNotTestAnything="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnError="false"
|
||||
stopOnFailure="false"
|
||||
verbose="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="JOSE Test Suite">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">./src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
26
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Base64/Base64Encoder.php
vendored
Normal file
26
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Base64/Base64Encoder.php
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Base64;
|
||||
|
||||
class Base64Encoder implements Encoder
|
||||
{
|
||||
/**
|
||||
* @param string $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function encode($data)
|
||||
{
|
||||
return base64_encode($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decode($data)
|
||||
{
|
||||
return base64_decode($data);
|
||||
}
|
||||
}
|
||||
16
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Base64/Base64UrlSafeEncoder.php
vendored
Normal file
16
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Base64/Base64UrlSafeEncoder.php
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Base64;
|
||||
|
||||
class Base64UrlSafeEncoder implements Encoder
|
||||
{
|
||||
public function encode($data)
|
||||
{
|
||||
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
|
||||
}
|
||||
|
||||
public function decode($data)
|
||||
{
|
||||
return base64_decode(strtr($data, '-_', '+/'));
|
||||
}
|
||||
}
|
||||
20
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Base64/Encoder.php
vendored
Normal file
20
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Base64/Encoder.php
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Base64;
|
||||
|
||||
interface Encoder
|
||||
{
|
||||
/**
|
||||
* @param string $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function encode($data);
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decode($data);
|
||||
}
|
||||
|
|
@ -0,0 +1,240 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Namshi\JOSE\Base64\Base64Encoder;
|
||||
use Namshi\JOSE\Base64\Base64UrlSafeEncoder;
|
||||
use Namshi\JOSE\Base64\Encoder;
|
||||
use Namshi\JOSE\Signer\SignerInterface;
|
||||
|
||||
/**
|
||||
* Class representing a JSON Web Signature.
|
||||
*/
|
||||
class JWS extends JWT
|
||||
{
|
||||
protected $signature;
|
||||
protected $isSigned = false;
|
||||
protected $originalToken;
|
||||
protected $encodedSignature;
|
||||
protected $encryptionEngine;
|
||||
protected $supportedEncryptionEngines = array('OpenSSL', 'SecLib');
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $header An associative array of headers. The value can be any type accepted by json_encode or a JSON serializable object
|
||||
*
|
||||
* @see http://php.net/manual/en/function.json-encode.php
|
||||
* @see http://php.net/manual/en/jsonserializable.jsonserialize.php
|
||||
* @see https://tools.ietf.org/html/draft-ietf-jose-json-web-signature-41#section-4
|
||||
*
|
||||
* @param string $encryptionEngine
|
||||
* }
|
||||
*/
|
||||
public function __construct($header = array(), $encryptionEngine = 'OpenSSL')
|
||||
{
|
||||
if (!in_array($encryptionEngine, $this->supportedEncryptionEngines)) {
|
||||
throw new InvalidArgumentException(sprintf('Encryption engine %s is not supported', $encryptionEngine));
|
||||
}
|
||||
|
||||
if ('SecLib' === $encryptionEngine && version_compare(PHP_VERSION, '7.0.0-dev') >= 0) {
|
||||
throw new InvalidArgumentException("phpseclib 1.0.0(LTS), even the latest 2.0.0, doesn't support PHP7 yet");
|
||||
}
|
||||
|
||||
$this->encryptionEngine = $encryptionEngine;
|
||||
|
||||
parent::__construct(array(), $header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs the JWS signininput.
|
||||
*
|
||||
* @param resource|string $key
|
||||
* @param optional string $password
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function sign($key, $password = null)
|
||||
{
|
||||
$this->signature = $this->getSigner()->sign($this->generateSigninInput(), $key, $password);
|
||||
$this->isSigned = true;
|
||||
|
||||
return $this->signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the signature representation of the JWS.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSignature()
|
||||
{
|
||||
if ($this->isSigned()) {
|
||||
return $this->signature;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the JSW has already been signed.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSigned()
|
||||
{
|
||||
return (bool) $this->isSigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representing the JWT.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenString()
|
||||
{
|
||||
$signinInput = $this->generateSigninInput();
|
||||
|
||||
return sprintf('%s.%s', $signinInput, $this->encoder->encode($this->getSignature()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of a JWS from a JWT.
|
||||
*
|
||||
* @param string $jwsTokenString
|
||||
* @param bool $allowUnsecure
|
||||
* @param Encoder $encoder
|
||||
* @param string $encryptionEngine
|
||||
*
|
||||
* @return JWS
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function load($jwsTokenString, $allowUnsecure = false, Encoder $encoder = null, $encryptionEngine = 'OpenSSL')
|
||||
{
|
||||
if ($encoder === null) {
|
||||
$encoder = strpbrk($jwsTokenString, '+/=') ? new Base64Encoder() : new Base64UrlSafeEncoder();
|
||||
}
|
||||
|
||||
$parts = explode('.', $jwsTokenString);
|
||||
|
||||
if (count($parts) === 3) {
|
||||
$header = json_decode($encoder->decode($parts[0]), true);
|
||||
$payload = json_decode($encoder->decode($parts[1]), true);
|
||||
|
||||
if (is_array($header) && is_array($payload)) {
|
||||
if (strtolower($header['alg']) === 'none' && !$allowUnsecure) {
|
||||
throw new InvalidArgumentException(sprintf('The token "%s" cannot be validated in a secure context, as it uses the unallowed "none" algorithm', $jwsTokenString));
|
||||
}
|
||||
|
||||
$jws = new static($header, $encryptionEngine);
|
||||
|
||||
$jws->setEncoder($encoder)
|
||||
->setHeader($header)
|
||||
->setPayload($payload)
|
||||
->setOriginalToken($jwsTokenString)
|
||||
->setEncodedSignature($parts[2]);
|
||||
|
||||
return $jws;
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(sprintf('The token "%s" is an invalid JWS', $jwsTokenString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the internal signin input corresponds to the encoded
|
||||
* signature previously stored (@see JWS::load).
|
||||
*
|
||||
* @param resource|string $key
|
||||
* @param string $algo The algorithms this JWS should be signed with. Use it if you want to restrict which algorithms you want to allow to be validated.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function verify($key, $algo = null)
|
||||
{
|
||||
if (empty($key) || ($algo && $this->header['alg'] !== $algo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$decodedSignature = $this->encoder->decode($this->getEncodedSignature());
|
||||
$signinInput = $this->getSigninInput();
|
||||
|
||||
return $this->getSigner()->verify($key, $decodedSignature, $signinInput);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the original token signin input if it exists, otherwise generate the
|
||||
* signin input for the current JWS
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getSigninInput()
|
||||
{
|
||||
$parts = explode('.', $this->originalToken);
|
||||
|
||||
if (count($parts) >= 2) {
|
||||
return sprintf('%s.%s', $parts[0], $parts[1]);
|
||||
}
|
||||
|
||||
return $this->generateSigninInput();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the original base64 encoded token.
|
||||
*
|
||||
* @param string $originalToken
|
||||
*
|
||||
* @return JWS
|
||||
*/
|
||||
private function setOriginalToken($originalToken)
|
||||
{
|
||||
$this->originalToken = $originalToken;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base64 encoded signature.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEncodedSignature()
|
||||
{
|
||||
return $this->encodedSignature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base64 encoded signature.
|
||||
*
|
||||
* @param string $encodedSignature
|
||||
*
|
||||
* @return JWS
|
||||
*/
|
||||
public function setEncodedSignature($encodedSignature)
|
||||
{
|
||||
$this->encodedSignature = $encodedSignature;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the signer responsible to encrypting / decrypting this JWS.
|
||||
*
|
||||
* @return SignerInterface
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function getSigner()
|
||||
{
|
||||
$signerClass = sprintf('Namshi\\JOSE\\Signer\\%s\\%s', $this->encryptionEngine, $this->header['alg']);
|
||||
|
||||
if (class_exists($signerClass)) {
|
||||
return new $signerClass();
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(
|
||||
sprintf("The algorithm '%s' is not supported for %s", $this->header['alg'], $this->encryptionEngine));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE;
|
||||
|
||||
use Namshi\JOSE\Base64\Base64UrlSafeEncoder;
|
||||
use Namshi\JOSE\Base64\Encoder;
|
||||
|
||||
/**
|
||||
* Class representing a JSON Web Token.
|
||||
*/
|
||||
class JWT
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $payload;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $header;
|
||||
|
||||
/**
|
||||
* @var Encoder
|
||||
*/
|
||||
protected $encoder;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $payload
|
||||
* @param array $header
|
||||
*/
|
||||
public function __construct(array $payload, array $header)
|
||||
{
|
||||
$this->setPayload($payload);
|
||||
$this->setHeader($header);
|
||||
$this->setEncoder(new Base64UrlSafeEncoder());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Encoder $encoder
|
||||
*/
|
||||
public function setEncoder(Encoder $encoder)
|
||||
{
|
||||
$this->encoder = $encoder;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the signininput for the current JWT.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateSigninInput()
|
||||
{
|
||||
$base64payload = $this->encoder->encode(json_encode($this->getPayload(), JSON_UNESCAPED_SLASHES));
|
||||
$base64header = $this->encoder->encode(json_encode($this->getHeader(), JSON_UNESCAPED_SLASHES));
|
||||
|
||||
return sprintf('%s.%s', $base64header, $base64payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the payload of the JWT.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPayload()
|
||||
{
|
||||
return $this->payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the payload of the current JWT.
|
||||
*
|
||||
* @param array $payload
|
||||
*/
|
||||
public function setPayload(array $payload)
|
||||
{
|
||||
$this->payload = $payload;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the header of the JWT.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getHeader()
|
||||
{
|
||||
return $this->header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the header of this JWT.
|
||||
*
|
||||
* @param array $header
|
||||
*/
|
||||
public function setHeader(array $header)
|
||||
{
|
||||
$this->header = $header;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
108
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/ECDSA.php
vendored
Normal file
108
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/ECDSA.php
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\OpenSSL;
|
||||
|
||||
use phpseclib\File\ASN1;
|
||||
|
||||
/**
|
||||
* Class responsible to sign inputs with the a ECDSA algorithm, after hashing it.
|
||||
*/
|
||||
abstract class ECDSA extends PublicKey
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '7.0.0-dev') >= 0) {
|
||||
throw new \InvalidArgumentException("phpseclib 1.0.0(LTS), even the latest 2.0.0, doesn't support PHP7 yet");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function supportsKey($key)
|
||||
{
|
||||
if (false === parent::supportsKey($key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// openssl_sign with EC keys was introduced in this PHP release
|
||||
$minVersions = array(
|
||||
'5.4' => '5.4.26',
|
||||
'5.5' => '5.5.10',
|
||||
'5.6' => '5.6.0',
|
||||
);
|
||||
|
||||
if (isset($minVersions[PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION]) &&
|
||||
version_compare(PHP_VERSION, $minVersions[PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION], '<')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$keyDetails = openssl_pkey_get_details($key);
|
||||
|
||||
if (0 === preg_match('/-----BEGIN PUBLIC KEY-----([^-]+)-----END PUBLIC KEY-----/', $keyDetails['key'], $matches)) {
|
||||
return false;
|
||||
}
|
||||
$publicKey = trim($matches[1]);
|
||||
$asn1 = new ASN1();
|
||||
|
||||
/*
|
||||
* http://tools.ietf.org/html/rfc3279#section-2.2.3
|
||||
* AlgorithmIdentifier ::= SEQUENCE {
|
||||
* algorithm OBJECT IDENTIFIER,
|
||||
* parameters ANY DEFINED BY algorithm OPTIONAL
|
||||
* }
|
||||
* For ECDSA Signature Algorithm:
|
||||
* algorithm: ansi-X9-62 => 1.2.840.10045.2.1
|
||||
* parameters: id-ecSigType => 1.2.840.10045.x.y.z
|
||||
*
|
||||
*/
|
||||
$asnAlgorithmIdentifier = array(
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'children' => array(
|
||||
'ansi-X9-62' => array(
|
||||
'type' => ASN1::TYPE_OBJECT_IDENTIFIER,
|
||||
),
|
||||
'id-ecSigType' => array(
|
||||
'type' => ASN1::TYPE_OBJECT_IDENTIFIER,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/*
|
||||
* http://tools.ietf.org/html/rfc5280#section-4.1
|
||||
* SubjectPublicKeyInfo ::= SEQUENCE {
|
||||
* algorithm AlgorithmIdentifier,
|
||||
* subjectPublicKey BIT STRING
|
||||
* }
|
||||
*/
|
||||
$asnSubjectPublicKeyInfo = array(
|
||||
'type' => ASN1::TYPE_SEQUENCE,
|
||||
'children' => array(
|
||||
'algorithm' => $asnAlgorithmIdentifier,
|
||||
'subjectPublicKey' => array(
|
||||
'type' => ASN1::TYPE_BIT_STRING,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$decoded = $asn1->decodeBER(base64_decode($publicKey));
|
||||
$mappedDetails = $asn1->asn1map($decoded[0], $asnSubjectPublicKeyInfo);
|
||||
|
||||
return isset($mappedDetails['algorithm']['id-ecSigType']) ? $this->getSupportedECDSACurve() === $mappedDetails['algorithm']['id-ecSigType'] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getSupportedPrivateKeyType()
|
||||
{
|
||||
return defined('OPENSSL_KEYTYPE_EC') ? OPENSSL_KEYTYPE_EC : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ECDSA curve supported in this signer.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getSupportedECDSACurve();
|
||||
}
|
||||
19
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/ES256.php
vendored
Normal file
19
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/ES256.php
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\OpenSSL;
|
||||
|
||||
/**
|
||||
* Class responsible to sign inputs with the ECDSA algorithm, after hashing it.
|
||||
*/
|
||||
class ES256 extends ECDSA
|
||||
{
|
||||
public function getHashingAlgorithm()
|
||||
{
|
||||
return version_compare(phpversion(), '5.4.8', '<') ? 'SHA256' : OPENSSL_ALGO_SHA256;
|
||||
}
|
||||
|
||||
protected function getSupportedECDSACurve()
|
||||
{
|
||||
return '1.2.840.10045.3.1.7';
|
||||
}
|
||||
}
|
||||
19
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/ES384.php
vendored
Normal file
19
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/ES384.php
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\OpenSSL;
|
||||
|
||||
/**
|
||||
* Class responsible to sign inputs with the ECDSA algorithm, after hashing it.
|
||||
*/
|
||||
class ES384 extends ECDSA
|
||||
{
|
||||
public function getHashingAlgorithm()
|
||||
{
|
||||
return version_compare(phpversion(), '5.4.8', '<') ? 'SHA384' : OPENSSL_ALGO_SHA384;
|
||||
}
|
||||
|
||||
protected function getSupportedECDSACurve()
|
||||
{
|
||||
return '1.3.132.0.34';
|
||||
}
|
||||
}
|
||||
19
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/ES512.php
vendored
Normal file
19
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/ES512.php
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\OpenSSL;
|
||||
|
||||
/**
|
||||
* Class responsible to sign inputs with the ECDSA algorithm, after hashing it.
|
||||
*/
|
||||
class ES512 extends ECDSA
|
||||
{
|
||||
public function getHashingAlgorithm()
|
||||
{
|
||||
return version_compare(phpversion(), '5.4.8', '<') ? 'SHA512' : OPENSSL_ALGO_SHA512;
|
||||
}
|
||||
|
||||
protected function getSupportedECDSACurve()
|
||||
{
|
||||
return '1.3.132.0.35';
|
||||
}
|
||||
}
|
||||
56
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/HMAC.php
vendored
Normal file
56
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/HMAC.php
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\OpenSSL;
|
||||
|
||||
use Namshi\JOSE\Signer\SignerInterface;
|
||||
|
||||
/**
|
||||
* This class is the base of all HMAC Signers.
|
||||
*/
|
||||
abstract class HMAC implements SignerInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function sign($input, $key)
|
||||
{
|
||||
return hash_hmac($this->getHashingAlgorithm(), $input, (string) $key, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* To prevent timing attacks we are using PHP 5.6 native function hash_equals,
|
||||
* in case of PHP < 5.6 a timing safe equals comparison function.
|
||||
*
|
||||
* more info here:
|
||||
* http://blog.ircmaxell.com/2014/11/its-all-about-time.html
|
||||
*
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function verify($key, $signature, $input)
|
||||
{
|
||||
$signedInput = $this->sign($input, $key);
|
||||
|
||||
return $this->timingSafeEquals($signedInput, $signature);
|
||||
}
|
||||
|
||||
/**
|
||||
* A timing safe equals comparison.
|
||||
*
|
||||
* @param string $signature the internal signature to be checked
|
||||
* @param string $signedInput The signed input submitted value
|
||||
*
|
||||
* @return bool true if the two strings are identical.
|
||||
*/
|
||||
public function timingSafeEquals($known, $input)
|
||||
{
|
||||
return hash_equals($known, $input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hashing algorithm used in this signer.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getHashingAlgorithm();
|
||||
}
|
||||
14
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/HS256.php
vendored
Normal file
14
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/HS256.php
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\OpenSSL;
|
||||
|
||||
/**
|
||||
* HMAC Signer using SHA-256.
|
||||
*/
|
||||
class HS256 extends HMAC
|
||||
{
|
||||
public function getHashingAlgorithm()
|
||||
{
|
||||
return 'sha256';
|
||||
}
|
||||
}
|
||||
14
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/HS384.php
vendored
Normal file
14
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/HS384.php
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\OpenSSL;
|
||||
|
||||
/**
|
||||
* HMAC Signer using SHA-384.
|
||||
*/
|
||||
class HS384 extends HMAC
|
||||
{
|
||||
public function getHashingAlgorithm()
|
||||
{
|
||||
return 'sha384';
|
||||
}
|
||||
}
|
||||
14
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/HS512.php
vendored
Normal file
14
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/HS512.php
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\OpenSSL;
|
||||
|
||||
/**
|
||||
* HMAC Signer using SHA-512.
|
||||
*/
|
||||
class HS512 extends HMAC
|
||||
{
|
||||
public function getHashingAlgorithm()
|
||||
{
|
||||
return 'sha512';
|
||||
}
|
||||
}
|
||||
27
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/None.php
vendored
Normal file
27
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/None.php
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\OpenSSL;
|
||||
|
||||
use Namshi\JOSE\Signer\SignerInterface;
|
||||
|
||||
/**
|
||||
* None Signer.
|
||||
*/
|
||||
class None implements SignerInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function sign($input, $key)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function verify($key, $signature, $input)
|
||||
{
|
||||
return $signature === '';
|
||||
}
|
||||
}
|
||||
98
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/PublicKey.php
vendored
Normal file
98
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/PublicKey.php
vendored
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\OpenSSL;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Namshi\JOSE\Signer\SignerInterface;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Class responsible to sign inputs with the a public key algorithm, after hashing it.
|
||||
*/
|
||||
abstract class PublicKey implements SignerInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function sign($input, $key, $password = null)
|
||||
{
|
||||
$keyResource = $this->getKeyResource($key, $password);
|
||||
if (!$this->supportsKey($keyResource)) {
|
||||
throw new InvalidArgumentException('Invalid key supplied.');
|
||||
}
|
||||
|
||||
$signature = null;
|
||||
openssl_sign($input, $signature, $keyResource, $this->getHashingAlgorithm());
|
||||
|
||||
return $signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function verify($key, $signature, $input)
|
||||
{
|
||||
$keyResource = $this->getKeyResource($key);
|
||||
if (!$this->supportsKey($keyResource)) {
|
||||
throw new InvalidArgumentException('Invalid key supplied.');
|
||||
}
|
||||
|
||||
$result = openssl_verify($input, $signature, $keyResource, $this->getHashingAlgorithm());
|
||||
|
||||
if ($result === -1) {
|
||||
throw new RuntimeException('Unknown error during verification.');
|
||||
}
|
||||
|
||||
return (bool) $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string representation of a key into an OpenSSL resource.
|
||||
*
|
||||
* @param string|resource $key
|
||||
* @param string $password
|
||||
*
|
||||
* @return resource OpenSSL key resource
|
||||
*/
|
||||
protected function getKeyResource($key, $password = null)
|
||||
{
|
||||
if (is_resource($key)) {
|
||||
return $key;
|
||||
}
|
||||
|
||||
$resource = openssl_pkey_get_public($key) ?: openssl_pkey_get_private($key, $password);
|
||||
if ($resource === false) {
|
||||
throw new RuntimeException('Could not read key resource: ' . openssl_error_string());
|
||||
}
|
||||
return $resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the key is supported by this signer.
|
||||
*
|
||||
* @param resource $key Public or private key
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function supportsKey($key)
|
||||
{
|
||||
// OpenSSL 0.9.8+
|
||||
$keyDetails = openssl_pkey_get_details($key);
|
||||
|
||||
return isset($keyDetails['type']) ? $this->getSupportedPrivateKeyType() === $keyDetails['type'] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hashing algorithm used in this signer.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getHashingAlgorithm();
|
||||
|
||||
/**
|
||||
* Returns the private key type supported in this signer.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getSupportedPrivateKeyType();
|
||||
}
|
||||
14
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/RS256.php
vendored
Normal file
14
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/RS256.php
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\OpenSSL;
|
||||
|
||||
/**
|
||||
* Class responsible to sign inputs with the RSA algorithm, after hashing it.
|
||||
*/
|
||||
class RS256 extends RSA
|
||||
{
|
||||
public function getHashingAlgorithm()
|
||||
{
|
||||
return version_compare(phpversion(), '5.4.8', '<') ? 'SHA256' : OPENSSL_ALGO_SHA256;
|
||||
}
|
||||
}
|
||||
14
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/RS384.php
vendored
Normal file
14
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/RS384.php
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\OpenSSL;
|
||||
|
||||
/**
|
||||
* Class responsible to sign inputs with the RSA algorithm, after hashing it.
|
||||
*/
|
||||
class RS384 extends RSA
|
||||
{
|
||||
public function getHashingAlgorithm()
|
||||
{
|
||||
return version_compare(phpversion(), '5.4.8', '<') ? 'SHA384' : OPENSSL_ALGO_SHA384;
|
||||
}
|
||||
}
|
||||
14
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/RS512.php
vendored
Normal file
14
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/RS512.php
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\OpenSSL;
|
||||
|
||||
/**
|
||||
* Class responsible to sign inputs with the RSA algorithm, after hashing it.
|
||||
*/
|
||||
class RS512 extends RSA
|
||||
{
|
||||
public function getHashingAlgorithm()
|
||||
{
|
||||
return version_compare(phpversion(), '5.4.8', '<') ? 'SHA512' : OPENSSL_ALGO_SHA512;
|
||||
}
|
||||
}
|
||||
17
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/RSA.php
vendored
Normal file
17
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/OpenSSL/RSA.php
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\OpenSSL;
|
||||
|
||||
/**
|
||||
* Class responsible to sign inputs with the a RSA algorithm, after hashing it.
|
||||
*/
|
||||
abstract class RSA extends PublicKey
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getSupportedPrivateKeyType()
|
||||
{
|
||||
return defined('OPENSSL_KEYTYPE_RSA') ? OPENSSL_KEYTYPE_RSA : false;
|
||||
}
|
||||
}
|
||||
39
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/SecLib/PublicKey.php
vendored
Normal file
39
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/SecLib/PublicKey.php
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\SecLib;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Namshi\JOSE\Signer\SignerInterface;
|
||||
|
||||
abstract class PublicKey implements SignerInterface
|
||||
{
|
||||
protected $encryptionAlgorithm;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function sign($input, $key, $password = null)
|
||||
{
|
||||
if ($password) {
|
||||
$this->encryptionAlgorithm->setPassword($password);
|
||||
}
|
||||
|
||||
if (!$this->encryptionAlgorithm->loadKey($key)) {
|
||||
throw new InvalidArgumentException('Invalid key supplied.');
|
||||
}
|
||||
|
||||
return $this->encryptionAlgorithm->sign($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function verify($key, $signature, $input)
|
||||
{
|
||||
if (!$this->encryptionAlgorithm->loadKey($key)) {
|
||||
throw new InvalidArgumentException('Invalid key supplied.');
|
||||
}
|
||||
|
||||
return $this->encryptionAlgorithm->verify($input, $signature);
|
||||
}
|
||||
}
|
||||
13
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/SecLib/RS256.php
vendored
Normal file
13
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/SecLib/RS256.php
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\SecLib;
|
||||
|
||||
class RS256 extends RSA
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->encryptionAlgorithm->setHash('sha256');
|
||||
$this->encryptionAlgorithm->setMGFHash('sha256');
|
||||
}
|
||||
}
|
||||
13
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/SecLib/RS384.php
vendored
Normal file
13
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/SecLib/RS384.php
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\SecLib;
|
||||
|
||||
class RS384 extends RSA
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->encryptionAlgorithm->setHash('sha384');
|
||||
$this->encryptionAlgorithm->setMGFHash('sha384');
|
||||
}
|
||||
}
|
||||
13
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/SecLib/RS512.php
vendored
Normal file
13
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/SecLib/RS512.php
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\SecLib;
|
||||
|
||||
class RS512 extends RSA
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->encryptionAlgorithm->setHash('sha512');
|
||||
$this->encryptionAlgorithm->setMGFHash('sha512');
|
||||
}
|
||||
}
|
||||
13
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/SecLib/RSA.php
vendored
Normal file
13
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/SecLib/RSA.php
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer\SecLib;
|
||||
|
||||
use phpseclib\Crypt\RSA as CryptRSA;
|
||||
|
||||
class RSA extends PublicKey
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->encryptionAlgorithm = new CryptRSA();
|
||||
}
|
||||
}
|
||||
28
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/SignerInterface.php
vendored
Normal file
28
plugins/vdomah/jwtauth/vendor/namshi/jose/src/Namshi/JOSE/Signer/SignerInterface.php
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Signer;
|
||||
|
||||
interface SignerInterface
|
||||
{
|
||||
/**
|
||||
* Signs the $input with the $key, after hashing it.
|
||||
*
|
||||
* @param string $input
|
||||
* @param resource|string $key
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function sign($input, $key);
|
||||
|
||||
/**
|
||||
* Verifies that the input correspond to the $signature decrypted with the
|
||||
* given public $key.
|
||||
*
|
||||
* @param resource|string $key
|
||||
* @param string $signature
|
||||
* @param string $input
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function verify($key, $signature, $input);
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE;
|
||||
|
||||
/**
|
||||
* Class providing an easy to use JWS implementation.
|
||||
*/
|
||||
class SimpleJWS extends JWS
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $header An associative array of headers. The value can be any type accepted by json_encode or a JSON serializable object
|
||||
*
|
||||
* @see http://php.net/manual/en/function.json-encode.php
|
||||
* @see http://php.net/manual/en/jsonserializable.jsonserialize.php
|
||||
* @see https://tools.ietf.org/html/draft-ietf-jose-json-web-signature-41#section-4
|
||||
* }
|
||||
*/
|
||||
public function __construct($header = array(), $encryptionEngine = 'OpenSSL')
|
||||
{
|
||||
if (!isset($header['typ'])) {
|
||||
$header['typ'] = 'JWS';
|
||||
}
|
||||
parent::__construct($header, $encryptionEngine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the payload of the current JWS with an issued at value in the 'iat' property.
|
||||
*
|
||||
* @param array $payload
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPayload(array $payload)
|
||||
{
|
||||
if (!isset($payload['iat'])) {
|
||||
$payload['iat'] = time();
|
||||
}
|
||||
|
||||
return parent::setPayload($payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the JWS has been signed with a valid private key by verifying it with a public $key
|
||||
* and the token is not expired.
|
||||
*
|
||||
* @param resource|string $key
|
||||
* @param string $algo The algorithms this JWS should be signed with. Use it if you want to restrict which algorithms you want to allow to be validated.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid($key, $algo = null)
|
||||
{
|
||||
return $this->verify($key, $algo) && !$this->isExpired();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the token is expired based on the 'exp' value.
|
||||
*it.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isExpired()
|
||||
{
|
||||
$payload = $this->getPayload();
|
||||
|
||||
if (isset($payload['exp'])) {
|
||||
$now = new \DateTime('now');
|
||||
|
||||
if (is_int($payload['exp'])) {
|
||||
return ($now->getTimestamp() - $payload['exp']) > 0;
|
||||
}
|
||||
|
||||
if (is_numeric($payload['exp'])) {
|
||||
return ($now->format('U') - $payload['exp']) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
37
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/BCJWSTest.php
vendored
Normal file
37
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/BCJWSTest.php
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test;
|
||||
|
||||
use Namshi\JOSE\Base64\Base64Encoder;
|
||||
use Namshi\JOSE\JWS;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
|
||||
/**
|
||||
* BC test for base64 url-safe fix
|
||||
* Test that tokens generated the old way (non url-safe) will work with url-safe base64 decoding.
|
||||
*/
|
||||
class BCJWSTest extends TestCase
|
||||
{
|
||||
const SSL_KEY_PASSPHRASE = 'tests';
|
||||
|
||||
public function testTestBC()
|
||||
{
|
||||
$data = array(
|
||||
array('order_nr' => 'ae123123'),
|
||||
array('username' => 'asdasdasd'),
|
||||
array('anything' => '!@#$%^&*()_+'),
|
||||
);
|
||||
|
||||
foreach ($data as $payload) {
|
||||
$jwsOld = new JWS(array('alg' => 'RS256'));
|
||||
$jwsOld->setEncoder(new Base64Encoder());
|
||||
$jwsOld->setPayload($payload);
|
||||
$jwsOld->sign(openssl_pkey_get_private(SSL_KEYS_PATH.'private.key', self::SSL_KEY_PASSPHRASE));
|
||||
|
||||
$t = $jwsOld->getTokenString();
|
||||
|
||||
$jwsNew = JWS::load($t);
|
||||
$this->assertTrue($jwsNew->verify(openssl_pkey_get_public(SSL_KEYS_PATH.'public.key')));
|
||||
}
|
||||
}
|
||||
}
|
||||
294
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/JWSTest.php
vendored
Normal file
294
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/JWSTest.php
vendored
Normal file
|
|
@ -0,0 +1,294 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test;
|
||||
|
||||
use DateTime;
|
||||
use Namshi\JOSE\JWS;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Namshi\JOSE\Signer\OpenSSL\HS256;
|
||||
use Namshi\JOSE\Base64\Base64UrlSafeEncoder;
|
||||
|
||||
class JWSTest extends TestCase
|
||||
{
|
||||
const SSL_KEY_PASSPHRASE = 'tests';
|
||||
|
||||
public function setup()
|
||||
{
|
||||
$date = new DateTime('tomorrow');
|
||||
$data = array(
|
||||
'a' => 'b',
|
||||
);
|
||||
$this->jws = new JWS(array('alg' => 'RS256'));
|
||||
$this->jws->setPayload($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testLoadingUnsecureJwsWithNoneAlgo()
|
||||
{
|
||||
$date = new DateTime('tomorrow');
|
||||
$data = array(
|
||||
'a' => 'b',
|
||||
'exp' => $date->format('U'),
|
||||
);
|
||||
$this->jws = new JWS(array('alg' => 'None'));
|
||||
$this->jws->setPayload($data);
|
||||
$this->jws->sign('111');
|
||||
|
||||
$jws = JWS::load($this->jws->getTokenString());
|
||||
$this->assertFalse($jws->verify('111'));
|
||||
|
||||
$payload = $jws->getPayload();
|
||||
$this->assertEquals('b', $payload['a']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testLoadingUnsecureJwsWithLowercaseNone()
|
||||
{
|
||||
$date = new DateTime('tomorrow');
|
||||
$data = array(
|
||||
'a' => 'b',
|
||||
'exp' => $date->format('U'),
|
||||
);
|
||||
$this->jws = new JWS(array('alg' => 'none'));
|
||||
$this->jws->setPayload($data);
|
||||
$this->jws->sign('111');
|
||||
|
||||
$jws = JWS::load($this->jws->getTokenString());
|
||||
$this->assertFalse($jws->verify('111'));
|
||||
|
||||
$payload = $jws->getPayload();
|
||||
$this->assertEquals('b', $payload['a']);
|
||||
}
|
||||
|
||||
public function testAllowingUnsecureJws()
|
||||
{
|
||||
$date = new DateTime('tomorrow');
|
||||
$data = array(
|
||||
'a' => 'b',
|
||||
'exp' => $date->format('U'),
|
||||
);
|
||||
$this->jws = new JWS(array('alg' => 'None'));
|
||||
$this->jws->setPayload($data);
|
||||
$this->jws->sign('111');
|
||||
|
||||
$jws = JWS::load($this->jws->getTokenString(), true);
|
||||
$this->assertTrue($jws->verify('111'));
|
||||
|
||||
$payload = $jws->getPayload();
|
||||
$this->assertEquals('b', $payload['a']);
|
||||
}
|
||||
|
||||
public function testRestrictingTheAlgorithmsKo()
|
||||
{
|
||||
$this->jws = new JWS(array('alg' => 'HS256'));
|
||||
$this->jws->sign('12345');
|
||||
|
||||
$jws = JWS::load($this->jws->getTokenString());
|
||||
$this->assertFalse($jws->verify('12345', 'RS256'));
|
||||
}
|
||||
|
||||
public function testRestrictingTheAlgorithmsOk()
|
||||
{
|
||||
$date = new DateTime('tomorrow');
|
||||
$data = array(
|
||||
'a' => 'b',
|
||||
'exp' => $date->format('U'),
|
||||
);
|
||||
$this->jws = new JWS(array('alg' => 'HS256'));
|
||||
$this->jws->setPayload($data);
|
||||
$this->jws->sign('123');
|
||||
|
||||
$jws = JWS::load($this->jws->getTokenString());
|
||||
$this->assertTrue($jws->verify('123', 'HS256'));
|
||||
}
|
||||
|
||||
public function testVerificationRS256()
|
||||
{
|
||||
$privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.key', self::SSL_KEY_PASSPHRASE);
|
||||
$this->jws->sign($privateKey);
|
||||
|
||||
$jws = JWS::load($this->jws->getTokenString());
|
||||
$public_key = openssl_pkey_get_public(SSL_KEYS_PATH.'public.key');
|
||||
$this->assertTrue($jws->verify($public_key));
|
||||
|
||||
$payload = $jws->getPayload();
|
||||
$this->assertEquals('b', $payload['a']);
|
||||
}
|
||||
|
||||
public function testVerificationRS256KeyAsString()
|
||||
{
|
||||
$privateKey = file_get_contents(TEST_DIR.'/private.key');
|
||||
$this->jws->sign($privateKey, self::SSL_KEY_PASSPHRASE);
|
||||
|
||||
$jws = JWS::load($this->jws->getTokenString());
|
||||
$public_key = openssl_pkey_get_public(SSL_KEYS_PATH.'public.key');
|
||||
$this->assertTrue($jws->verify($public_key));
|
||||
|
||||
$payload = $jws->getPayload();
|
||||
$this->assertEquals('b', $payload['a']);
|
||||
}
|
||||
|
||||
public function testUseOfCustomEncoder()
|
||||
{
|
||||
$encoder = $this->prophesize('Namshi\JOSE\Base64\Encoder');
|
||||
$encoder
|
||||
->decode(Argument::any())
|
||||
->willReturn('{"whatever": "the payload should be"}')
|
||||
->shouldBeCalled();
|
||||
$encoder
|
||||
->decode(Argument::any())
|
||||
->willReturn('{"alg": "test"}')
|
||||
->shouldBeCalled();
|
||||
JWS::load($this->jws->getTokenString(), false, $encoder->reveal());
|
||||
}
|
||||
|
||||
public function testVerificationThatTheJWSIsSigned()
|
||||
{
|
||||
$privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.key', self::SSL_KEY_PASSPHRASE);
|
||||
$this->jws->sign($privateKey);
|
||||
$this->assertTrue($this->jws->isSigned());
|
||||
}
|
||||
|
||||
public function testVerificationThatTheJWSIsNotSigned()
|
||||
{
|
||||
$this->assertFalse($this->jws->isSigned());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testWrongVerificationRS256()
|
||||
{
|
||||
$privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.key', self::SSL_KEY_PASSPHRASE);
|
||||
$this->jws->sign($privateKey);
|
||||
|
||||
$jws = JWS::load('eyJhbGciOiJ0ZXN0In0=.eyJhbGciOiJ0ZXN0In0=.eyJhbGciOiJ0ZXN0In0=');
|
||||
$public_key = openssl_pkey_get_public(SSL_KEYS_PATH.'public.key');
|
||||
$this->assertFalse($jws->verify($public_key));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testLoadingAMalformedTokenString()
|
||||
{
|
||||
JWS::load('test.Test.TEST');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testLoadingAMalformedTokenString2()
|
||||
{
|
||||
JWS::load('test');
|
||||
}
|
||||
|
||||
public function testSignAndVerifyWithFalsePublicKey()
|
||||
{
|
||||
$public_key = false;
|
||||
$jwsHMAC = new JWS(array('alg' => 'HS256'));
|
||||
|
||||
$jwsHMAC->sign(false);
|
||||
$jws = JWS::load($jwsHMAC->getTokenString());
|
||||
|
||||
$this->assertFalse($jws->verify($public_key));
|
||||
}
|
||||
|
||||
public function testSignAndVerifyWithEmptyStringPublicKey()
|
||||
{
|
||||
$public_key = false;
|
||||
$jwsHMAC = new JWS(array('alg' => 'HS256'));
|
||||
|
||||
$jwsHMAC->sign('');
|
||||
$jws = JWS::load($jwsHMAC->getTokenString());
|
||||
|
||||
$this->assertFalse($jws->verify($public_key));
|
||||
}
|
||||
|
||||
public function testLoadingWithAnyOrderOfHeaders()
|
||||
{
|
||||
$privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.key', self::SSL_KEY_PASSPHRASE);
|
||||
$public_key = openssl_pkey_get_public(SSL_KEYS_PATH.'public.key');
|
||||
|
||||
$this->jws = new JWS(array('alg' => 'RS256', 'custom' => '1'));
|
||||
|
||||
$header = $this->jws->getHeader();
|
||||
$reversedHeader = array_reverse($header);
|
||||
$this->assertFalse($header === $reversedHeader);
|
||||
|
||||
$this->jws->setHeader($reversedHeader);
|
||||
$this->jws->sign($privateKey);
|
||||
|
||||
$tokenString = $this->jws->getTokenString();
|
||||
$jws = JWS::load($tokenString);
|
||||
$this->assertTrue($reversedHeader === $jws->getHeader());
|
||||
}
|
||||
|
||||
public function testSignAndVerifyWithSecLib()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '7.0.0-dev') >= 0) {
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
}
|
||||
|
||||
$jwsRSA = new JWS(array('alg' => 'RS256'), 'SecLib');
|
||||
$data = array('a' => 'b');
|
||||
$jwsRSA->setPayload($data);
|
||||
|
||||
$jwsRSA->sign(file_get_contents(SSL_KEYS_PATH.'private.key'), 'tests');
|
||||
$jws = JWS::load($jwsRSA->getTokenString(), false, null, 'SecLib');
|
||||
|
||||
$this->assertTrue($jws->verify(file_get_contents(SSL_KEYS_PATH.'public.key', 'RS256')));
|
||||
}
|
||||
|
||||
public function testConstructionFromHeader()
|
||||
{
|
||||
$header = array('alg' => 'RS256', 'test' => true);
|
||||
$jws = new JWS($header);
|
||||
|
||||
$this->assertTrue($header == $jws->getHeader());
|
||||
}
|
||||
|
||||
public function testVerificationCustomizedHeader()
|
||||
{
|
||||
$header = $this->jws->getHeader();
|
||||
$header['test'] = true;
|
||||
$this->jws->setHeader($header);
|
||||
|
||||
$privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.key', self::SSL_KEY_PASSPHRASE);
|
||||
$this->jws->sign($privateKey);
|
||||
|
||||
$jws = JWS::load($this->jws->getTokenString());
|
||||
$public_key = openssl_pkey_get_public(SSL_KEYS_PATH.'public.key');
|
||||
$headerFromSig = $jws->getHeader();
|
||||
|
||||
$this->assertSame($headerFromSig['test'], true);
|
||||
$this->assertTrue($jws->verify($public_key));
|
||||
}
|
||||
|
||||
public function testVerificationWithJsonThatContainsWhitespace()
|
||||
{
|
||||
$header = '{
|
||||
"alg": "HS256"
|
||||
}';
|
||||
|
||||
$payload = '{
|
||||
"a": "b"
|
||||
}';
|
||||
|
||||
$encoder = new Base64UrlSafeEncoder();
|
||||
$signer = new HS256();
|
||||
|
||||
$token = sprintf('%s.%s', $encoder->encode($header), $encoder->encode($payload));
|
||||
$signature = $encoder->encode($signer->sign($token, '123'));
|
||||
$jwsToken = sprintf('%s.%s', $token, $signature);
|
||||
|
||||
$jws = JWS::load($jwsToken);
|
||||
|
||||
$this->assertTrue($jws->verify('123'));
|
||||
}
|
||||
}
|
||||
45
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/JWTTest.php
vendored
Normal file
45
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/JWTTest.php
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test;
|
||||
|
||||
use Namshi\JOSE\Base64\Base64UrlSafeEncoder;
|
||||
use Namshi\JOSE\JWT;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
|
||||
class JWTTest extends TestCase
|
||||
{
|
||||
public function testGenerationOfTheSigninInput()
|
||||
{
|
||||
$payload = array('b' => 'a', 'iat' => 1421161177);
|
||||
$header = array('a' => 'b');
|
||||
$jwt = new JWT($payload, $header);
|
||||
$encoder = new Base64UrlSafeEncoder();
|
||||
|
||||
$this->assertEquals(sprintf('%s.%s', $encoder->encode(json_encode($header)), $encoder->encode(json_encode($payload))), $jwt->generateSigninInput());
|
||||
}
|
||||
|
||||
public function testGenerationOfTheSigninInputCanHandleSlashes()
|
||||
{
|
||||
$encoder = new Base64UrlSafeEncoder();
|
||||
$json_string = '{"a":"/b/"}';
|
||||
$encoded_json_string = $encoder->encode($json_string);
|
||||
$jwt = new JWT(json_decode($json_string, true), json_decode($json_string, true));
|
||||
|
||||
$this->assertEquals(sprintf('%s.%s', $encoded_json_string, $encoded_json_string), $jwt->generateSigninInput());
|
||||
}
|
||||
|
||||
public function testPayload()
|
||||
{
|
||||
$jwt = new JWT(array('a' => 'b'), array());
|
||||
$payload = $jwt->getPayload();
|
||||
|
||||
$this->assertSame(array('a' => 'b'), $payload);
|
||||
|
||||
$jwt = new JWT(array('a' => 'b'), array());
|
||||
$jwt->setPayload(array('b' => 'a'));
|
||||
$payload = $jwt->getPayload();
|
||||
|
||||
$this->assertSame($payload['b'], 'a');
|
||||
$this->assertSame(array('b' => 'a'), $payload);
|
||||
}
|
||||
}
|
||||
43
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/ES256Test.php
vendored
Normal file
43
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/ES256Test.php
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test\OpenSSL\Signer;
|
||||
|
||||
use Namshi\JOSE\Signer\OpenSSL\ES256;
|
||||
use Namshi\JOSE\Test\Signer\SecLib\SecLibTestCase;
|
||||
|
||||
class ES256Test extends SecLibTestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
parent::setup();
|
||||
// https://github.com/sebastianbergmann/phpunit/issues/1356
|
||||
if (defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
$this->privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.es256.key');
|
||||
$this->public = openssl_pkey_get_public(SSL_KEYS_PATH.'public.es256.key');
|
||||
$this->signer = new ES256();
|
||||
}
|
||||
|
||||
public function testVerificationWorksProperly()
|
||||
{
|
||||
$encrypted = $this->signer->sign('aaa', $this->privateKey);
|
||||
$this->assertInternalType('bool', $this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
$this->assertTrue($this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Invalid key supplied.
|
||||
*/
|
||||
public function testWrongKeyCurve()
|
||||
{
|
||||
$privateKey512 = openssl_pkey_get_private(SSL_KEYS_PATH.'private.es512.key');
|
||||
$this->signer->sign('aaa', $privateKey512);
|
||||
}
|
||||
|
||||
public function testSigningWorksProperly()
|
||||
{
|
||||
$this->assertInternalType('string', $this->signer->sign('aaa', $this->privateKey));
|
||||
}
|
||||
}
|
||||
33
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/ES384Test.php
vendored
Normal file
33
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/ES384Test.php
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test\OpenSSL\Signer;
|
||||
|
||||
use Namshi\JOSE\Signer\OpenSSL\ES384;
|
||||
use Namshi\JOSE\Test\Signer\SecLib\SecLibTestCase;
|
||||
|
||||
class ES384Test extends SecLibTestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
parent::setup();
|
||||
// https://github.com/sebastianbergmann/phpunit/issues/1356
|
||||
if (defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
$this->privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.es384.key', 'tests');
|
||||
$this->public = openssl_pkey_get_public(SSL_KEYS_PATH.'public.es384.key');
|
||||
$this->signer = new ES384();
|
||||
}
|
||||
|
||||
public function testVerificationWorksProperly()
|
||||
{
|
||||
$encrypted = $this->signer->sign('aaa', $this->privateKey);
|
||||
$this->assertInternalType('bool', $this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
$this->assertTrue($this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
}
|
||||
|
||||
public function testSigningWorksProperly()
|
||||
{
|
||||
$this->assertInternalType('string', $this->signer->sign('aaa', $this->privateKey));
|
||||
}
|
||||
}
|
||||
33
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/ES512Test.php
vendored
Normal file
33
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/ES512Test.php
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test\OpenSSL\Signer;
|
||||
|
||||
use Namshi\JOSE\Signer\OpenSSL\ES512;
|
||||
use Namshi\JOSE\Test\Signer\SecLib\SecLibTestCase;
|
||||
|
||||
class ES512Test extends SecLibTestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
parent::setup();
|
||||
// https://github.com/sebastianbergmann/phpunit/issues/1356
|
||||
if (defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
$this->privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.es512.key');
|
||||
$this->public = openssl_pkey_get_public(SSL_KEYS_PATH.'public.es512.key');
|
||||
$this->signer = new ES512();
|
||||
}
|
||||
|
||||
public function testVerificationWorksProperly()
|
||||
{
|
||||
$encrypted = $this->signer->sign('aaa', $this->privateKey);
|
||||
$this->assertInternalType('bool', $this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
$this->assertTrue($this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
}
|
||||
|
||||
public function testSigningWorksProperly()
|
||||
{
|
||||
$this->assertInternalType('string', $this->signer->sign('aaa', $this->privateKey));
|
||||
}
|
||||
}
|
||||
19
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/HS256Test.php
vendored
Normal file
19
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/HS256Test.php
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test\OpenSSL\Signer;
|
||||
|
||||
use Namshi\JOSE\Signer\OpenSSL\HS256;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
|
||||
class HS256Test extends TestCase
|
||||
{
|
||||
public function testSigningAndVerificationWorkProperly()
|
||||
{
|
||||
$signer = new HS256();
|
||||
$signature = $signer->sign('aaa', 'foo');
|
||||
$this->assertEquals($signature, base64_decode('P2Pb8e2Ja4P4YnTZ3EF002RKpUpOnfjIy0uLNT0R1J0='));
|
||||
|
||||
$this->assertTrue($signer->verify('foo', $signature, 'aaa'));
|
||||
$this->assertFalse($signer->verify('bar', $signature, 'aaa'));
|
||||
}
|
||||
}
|
||||
20
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/HS384Test.php
vendored
Normal file
20
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/HS384Test.php
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test\OpenSSL\Signer;
|
||||
|
||||
use Namshi\JOSE\Signer\OpenSSL\HS384;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
|
||||
class HS384Test extends TestCase
|
||||
{
|
||||
public function testSigningAndVerificationWorkProperly()
|
||||
{
|
||||
$signer = new HS384();
|
||||
$signature = $signer->sign('aaa', 'foo');
|
||||
|
||||
$this->assertEquals($signature, base64_decode('W6Cd7qZknNYIXOxTrpEWFFwfuX0e2j59hTH4kVFh5o+9rcnfNtphLg4V8YXfkXGF'));
|
||||
|
||||
$this->assertTrue($signer->verify('foo', $signature, 'aaa'));
|
||||
$this->assertFalse($signer->verify('bar', $signature, 'aaa'));
|
||||
}
|
||||
}
|
||||
20
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/HS512Test.php
vendored
Normal file
20
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/HS512Test.php
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test\OpenSSL\Signer;
|
||||
|
||||
use Namshi\JOSE\Signer\OpenSSL\HS512;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
|
||||
class HS512Test extends TestCase
|
||||
{
|
||||
public function testSigningAndVerificationWorkProperly()
|
||||
{
|
||||
$signer = new HS512();
|
||||
$signature = $signer->sign('aaa', 'foo');
|
||||
|
||||
$this->assertEquals($signature, base64_decode('GysqRX8GoD6BCTrI5sJy1ptn9A7vbDlvFOnaAxO/t+BD8KVrVAUVcHMxgM68ZNxnUNkb7kNSq3YxkCV4pBvTjg=='));
|
||||
|
||||
$this->assertTrue($signer->verify('foo', $signature, 'aaa'));
|
||||
$this->assertFalse($signer->verify('bar', $signature, 'aaa'));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test\OpenSSL\Signer;
|
||||
|
||||
use Namshi\JOSE\Signer\OpenSSL\RS256;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
|
||||
class KeyFormatTest extends TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
$this->privateKeyResource = openssl_pkey_get_private(SSL_KEYS_PATH.'private.key', 'tests');
|
||||
$this->privateKeyString = "-----BEGIN PRIVATE KEY-----\nMIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAN91kQxBuaze3WjI\nCNjeR/HD8E3kDzp89+Lhtn3tMish4yQxhNl6BEkabuS3pUj3WDP6+AFjBVqA1j3f\nu8Wqu7hRJDPHOs2kCII+LhIqvqQTLx/nvNOUhW2DimKn0HuHnlwJODq0MHFJEq5R\nrJH+mFGsP9yMGz4MxA04E2RVbUJRAgMBAAECgYEAjrDrO3Fo2GvD5Jn/lER0mnxt\nIb/kvYt5WyaYutbRN1u/SKhaVeklfWzkrSZb5DkV2LOE1JXfoEgvBnms1O9OSJXw\nqDrFF7NDebw95g6JzI+SbkIHw0Cb+/E9K92FjvW3Bi8j9PKIa8c/dpwIAIirc/q8\nuhSTf4WoIOHSFbSaQPECQQD1Wi9vynJLI5lShOs0wPomZOwNrXa73Lj8ciZC4oPS\nt6tWjbLnLsP+vTSLUyEYeQGsjdbY+y5siJmAqnV/ShB9AkEA6Sgna9gQw4dXN0jB\nSjOZSjl4S2/H3wHatclrvlYfbJVU6GlIlqWGaUkdFvCuEr9iXJAY4zpEQ4P370EZ\ntsyVZQJBAOZu/X6RNSc9GBNYo0+4rzjAMLPn50wp0dPHogfPlt+hgVqZWx2l3o6y\nRVdVjA/gFqJp1Q+VWdS1tvYRIqmadkECQCVdqQuwgedEHmcewtNod42crjmwvWBx\nBKMTl6/WT4zwVb41eUujVWo0LHRLuCoK//GDqmloIh6L3MU8MqnIGb0CQFWcpD4/\nroCkMblk0hPoQPpyapJexc438x7XuEGFEhyxxauqC5R4YFKCf+KBS2gZgr4GSwBU\nQww+qZ3eRYM7faM=\n-----END PRIVATE KEY-----";
|
||||
$this->privateKeyFilePath = SSL_KEYS_PATH.'private-ne.key';
|
||||
$this->publicKeyResource = openssl_pkey_get_public(SSL_KEYS_PATH.'public.key');
|
||||
$this->publicKeyString = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDfdZEMQbms3t1oyAjY3kfxw/BN\n5A86fPfi4bZ97TIrIeMkMYTZegRJGm7kt6VI91gz+vgBYwVagNY937vFqru4USQz\nxzrNpAiCPi4SKr6kEy8f57zTlIVtg4pip9B7h55cCTg6tDBxSRKuUayR/phRrD/c\njBs+DMQNOBNkVW1CUQIDAQAB\n-----END PUBLIC KEY-----";
|
||||
$this->publicKeyFilePath = SSL_KEYS_PATH.'public-ne.key';
|
||||
$this->badPrivateKeyString = "-----BEGIN PRIVATE KEY-----\nfoo\nbar\n-----END PRIVATE KEY-----";
|
||||
$this->badPrivateKeyFilePath = SSL_KEYS_PATH.'nonexistant.key';
|
||||
$this->signer = new RS256();
|
||||
}
|
||||
|
||||
public function testStringKeyWorksProperly()
|
||||
{
|
||||
$encrypted = $this->signer->sign('aaa', $this->privateKeyString);
|
||||
$this->assertInternalType('bool', $this->signer->verify($this->publicKeyString, $encrypted, 'aaa'));
|
||||
$this->assertTrue($this->signer->verify($this->publicKeyString, $encrypted, 'aaa'));
|
||||
}
|
||||
|
||||
public function testFilePathKeyWorksProperly()
|
||||
{
|
||||
$encrypted = $this->signer->sign('aaa', $this->privateKeyFilePath);
|
||||
$this->assertInternalType('bool', $this->signer->verify($this->publicKeyFilePath, $encrypted, 'aaa'));
|
||||
$this->assertTrue($this->signer->verify($this->publicKeyFilePath, $encrypted, 'aaa'));
|
||||
}
|
||||
|
||||
public function testResourceKeyWorksProperly()
|
||||
{
|
||||
$encrypted = $this->signer->sign('aaa', $this->privateKeyResource);
|
||||
$this->assertInternalType('bool', $this->signer->verify($this->publicKeyResource, $encrypted, 'aaa'));
|
||||
$this->assertTrue($this->signer->verify($this->publicKeyResource, $encrypted, 'aaa'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHPUnit 5.4
|
||||
*/
|
||||
public function testBadStringKeyThrowsException()
|
||||
{
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->signer->sign('aaa', $this->badPrivateKeyString);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHPUnit 5.4
|
||||
*/
|
||||
public function testFilePathKeyThrowsException()
|
||||
{
|
||||
if(defined('HHVM_VERSION')) {
|
||||
// in HHVM, openssl_pkey_get_(public|private) throws an error when
|
||||
// passed a file path that cannot be found
|
||||
$this->expectException('PHPUnit_Framework_Error');
|
||||
} else {
|
||||
$this->expectException(\RuntimeException::class);
|
||||
}
|
||||
$this->signer->sign('aaa', $this->badPrivateKeyFilePath);
|
||||
}
|
||||
}
|
||||
24
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/NoneTest.php
vendored
Normal file
24
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/NoneTest.php
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test\OpenSSL\Signer;
|
||||
|
||||
use Namshi\JOSE\Signer\OpenSSL\None;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
|
||||
class NoneTest extends TestCase
|
||||
{
|
||||
public function testVerificationWorksProperly()
|
||||
{
|
||||
$signer = new none();
|
||||
|
||||
$this->assertTrue($signer->verify('bar', '', 'aaa'));
|
||||
}
|
||||
|
||||
public function testSigningWorksProperly()
|
||||
{
|
||||
$signer = new none();
|
||||
$signature = $signer->sign('aaa', 'foo');
|
||||
|
||||
$this->assertTrue($signature === '');
|
||||
}
|
||||
}
|
||||
28
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/RS256Test.php
vendored
Normal file
28
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/RS256Test.php
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test\OpenSSL\Signer;
|
||||
|
||||
use Namshi\JOSE\Signer\OpenSSL\RS256;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
|
||||
class RS256Test extends TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
$this->privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.key', 'tests');
|
||||
$this->public = openssl_pkey_get_public(SSL_KEYS_PATH.'public.key');
|
||||
$this->signer = new RS256();
|
||||
}
|
||||
|
||||
public function testVerificationWorksProperly()
|
||||
{
|
||||
$encrypted = $this->signer->sign('aaa', $this->privateKey);
|
||||
$this->assertInternalType('bool', $this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
$this->assertTrue($this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
}
|
||||
|
||||
public function testSigningWorksProperly()
|
||||
{
|
||||
$this->assertInternalType('string', $this->signer->sign('aaa', $this->privateKey));
|
||||
}
|
||||
}
|
||||
28
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/RS384Test.php
vendored
Normal file
28
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/RS384Test.php
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test\OpenSSL\Signer;
|
||||
|
||||
use Namshi\JOSE\Signer\OpenSSL\RS384;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
|
||||
class RS384Test extends TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
$this->privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.key', 'tests');
|
||||
$this->public = openssl_pkey_get_public(SSL_KEYS_PATH.'public.key');
|
||||
$this->signer = new RS384();
|
||||
}
|
||||
|
||||
public function testVerificationWorksProperly()
|
||||
{
|
||||
$encrypted = $this->signer->sign('aaa', $this->privateKey);
|
||||
$this->assertInternalType('bool', $this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
$this->assertTrue($this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
}
|
||||
|
||||
public function testSigningWorksProperly()
|
||||
{
|
||||
$this->assertInternalType('string', $this->signer->sign('aaa', $this->privateKey));
|
||||
}
|
||||
}
|
||||
28
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/RS512Test.php
vendored
Normal file
28
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/OpenSSL/RS512Test.php
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test\OpenSSL\Signer;
|
||||
|
||||
use Namshi\JOSE\Signer\OpenSSL\RS512;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
|
||||
class RS512Test extends TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
$this->privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.key', 'tests');
|
||||
$this->public = openssl_pkey_get_public(SSL_KEYS_PATH.'public.key');
|
||||
$this->signer = new RS512();
|
||||
}
|
||||
|
||||
public function testVerificationWorksProperly()
|
||||
{
|
||||
$encrypted = $this->signer->sign('aaa', $this->privateKey);
|
||||
$this->assertInternalType('bool', $this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
$this->assertTrue($this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
}
|
||||
|
||||
public function testSigningWorksProperly()
|
||||
{
|
||||
$this->assertInternalType('string', $this->signer->sign('aaa', $this->privateKey));
|
||||
}
|
||||
}
|
||||
30
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/SecLib/RS256TEST.php
vendored
Normal file
30
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/SecLib/RS256TEST.php
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test\Signer\SecLib;
|
||||
|
||||
use Namshi\JOSE\Signer\SecLib\RS256;
|
||||
|
||||
class RS256TEST extends SecLibTestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
parent::setup();
|
||||
|
||||
$this->privateKey = file_get_contents(SSL_KEYS_PATH.'private.key');
|
||||
$this->public = file_get_contents(SSL_KEYS_PATH.'public.key');
|
||||
$this->password = 'tests';
|
||||
$this->signer = new RS256();
|
||||
}
|
||||
|
||||
public function testVerificationWorksProperly()
|
||||
{
|
||||
$encrypted = $this->signer->sign('aaa', $this->privateKey, $this->password);
|
||||
$this->assertInternalType('bool', $this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
$this->assertTrue($this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
}
|
||||
|
||||
public function testSigningWorksProperly()
|
||||
{
|
||||
$this->assertInternalType('string', $this->signer->sign('aaa', $this->privateKey, $this->password));
|
||||
}
|
||||
}
|
||||
30
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/SecLib/RS384Test.php
vendored
Normal file
30
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/SecLib/RS384Test.php
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test\Signer\SecLib;
|
||||
|
||||
use Namshi\JOSE\Signer\SecLib\RS384;
|
||||
|
||||
class RS384Test extends SecLibTestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
parent::setup();
|
||||
|
||||
$this->privateKey = file_get_contents(SSL_KEYS_PATH.'private.key');
|
||||
$this->public = file_get_contents(SSL_KEYS_PATH.'public.key');
|
||||
$this->password = 'tests';
|
||||
$this->signer = new RS384();
|
||||
}
|
||||
|
||||
public function testVerificationWorksProperly()
|
||||
{
|
||||
$encrypted = $this->signer->sign('aaa', $this->privateKey, $this->password);
|
||||
$this->assertInternalType('bool', $this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
$this->assertTrue($this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
}
|
||||
|
||||
public function testSigningWorksProperly()
|
||||
{
|
||||
$this->assertInternalType('string', $this->signer->sign('aaa', $this->privateKey, $this->password));
|
||||
}
|
||||
}
|
||||
30
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/SecLib/RS512Test.php
vendored
Normal file
30
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/Signer/SecLib/RS512Test.php
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test\Signer\SecLib;
|
||||
|
||||
use Namshi\JOSE\Signer\SecLib\RS512;
|
||||
|
||||
class RS512Test extends SecLibTestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
parent::setup();
|
||||
|
||||
$this->privateKey = file_get_contents(SSL_KEYS_PATH.'private.key');
|
||||
$this->public = file_get_contents(SSL_KEYS_PATH.'public.key');
|
||||
$this->password = 'tests';
|
||||
$this->signer = new RS512();
|
||||
}
|
||||
|
||||
public function testVerificationWorksProperly()
|
||||
{
|
||||
$encrypted = $this->signer->sign('aaa', $this->privateKey, $this->password);
|
||||
$this->assertInternalType('bool', $this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
$this->assertTrue($this->signer->verify($this->public, $encrypted, 'aaa'));
|
||||
}
|
||||
|
||||
public function testSigningWorksProperly()
|
||||
{
|
||||
$this->assertInternalType('string', $this->signer->sign('aaa', $this->privateKey, $this->password));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test\Signer\SecLib;
|
||||
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
|
||||
class SecLibTestCase extends TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '7.0.0-dev') >= 0) {
|
||||
$this->markTestSkipped("phpseclib 1.0.0(LTS), even the latest 2.0.0, doesn't support PHP7 yet");
|
||||
}
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
}
|
||||
107
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/SimpleJWSTest.php
vendored
Normal file
107
plugins/vdomah/jwtauth/vendor/namshi/jose/tests/Namshi/JOSE/Test/SimpleJWSTest.php
vendored
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
namespace Namshi\JOSE\Test;
|
||||
|
||||
use DateTime;
|
||||
use Namshi\JOSE\SimpleJWS;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
|
||||
class SimpleJWSTest extends TestCase
|
||||
{
|
||||
const SSL_KEY_PASSPHRASE = 'tests';
|
||||
|
||||
public function setup()
|
||||
{
|
||||
$date = new DateTime('tomorrow');
|
||||
$data = array(
|
||||
'a' => 'b',
|
||||
'exp' => $date->format('U'),
|
||||
);
|
||||
$this->jws = new SimpleJWS(array('alg' => 'RS256'));
|
||||
$this->jws->setPayload($data);
|
||||
}
|
||||
|
||||
public function testConstruction()
|
||||
{
|
||||
$this->assertSame($this->jws->getHeader(), array('alg' => 'RS256', 'typ' => 'JWS'));
|
||||
$this->assertTrue(is_int($this->jws->getPayload()['iat']), 'iat property should be integer value (from construction)');
|
||||
}
|
||||
|
||||
public function testValidationOfAValidSimpleJWS()
|
||||
{
|
||||
$privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.key', self::SSL_KEY_PASSPHRASE);
|
||||
$this->jws->sign($privateKey);
|
||||
|
||||
$jws = SimpleJWS::load($this->jws->getTokenString());
|
||||
$public_key = openssl_pkey_get_public(SSL_KEYS_PATH.'public.key');
|
||||
$this->assertTrue($jws->isValid($public_key, 'RS256'));
|
||||
}
|
||||
|
||||
public function testValidationOfInvalidSimpleJWS()
|
||||
{
|
||||
$date = new DateTime('yesterday');
|
||||
$this->jws->setPayload(array(
|
||||
'exp' => $date->format('U'),
|
||||
));
|
||||
$privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.key', self::SSL_KEY_PASSPHRASE);
|
||||
$this->jws->sign($privateKey);
|
||||
|
||||
$jws = SimpleJWS::load($this->jws->getTokenString());
|
||||
$public_key = openssl_pkey_get_public(SSL_KEYS_PATH.'public.key');
|
||||
$this->assertFalse($jws->isValid($public_key, 'RS256'));
|
||||
}
|
||||
|
||||
public function testValidationOfValidSimpleJWSWithStringIat()
|
||||
{
|
||||
$date = new DateTime('tomorrow');
|
||||
$data = array(
|
||||
'a' => 'b',
|
||||
'exp' => $date->format('U'),
|
||||
'iat' => time()
|
||||
);
|
||||
$this->jws->setPayload($data);
|
||||
|
||||
$privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.key', self::SSL_KEY_PASSPHRASE);
|
||||
$this->jws->sign($privateKey);
|
||||
|
||||
$jws = SimpleJWS::load($this->jws->getTokenString());
|
||||
$public_key = openssl_pkey_get_public(SSL_KEYS_PATH.'public.key');
|
||||
$this->assertTrue($jws->isValid($public_key, 'RS256'));
|
||||
}
|
||||
|
||||
public function testValidationOfValidSimpleJWSWithExpAsInt()
|
||||
{
|
||||
$date = new DateTime('tomorrow');
|
||||
$data = array(
|
||||
'a' => 'b',
|
||||
'exp' => $date->getTimestamp(),
|
||||
'iat' => time()
|
||||
);
|
||||
$this->jws->setPayload($data);
|
||||
|
||||
$privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.key', self::SSL_KEY_PASSPHRASE);
|
||||
$this->jws->sign($privateKey);
|
||||
|
||||
$jws = SimpleJWS::load($this->jws->getTokenString());
|
||||
$public_key = openssl_pkey_get_public(SSL_KEYS_PATH.'public.key');
|
||||
$this->assertTrue($jws->isValid($public_key, 'RS256'));
|
||||
}
|
||||
|
||||
public function testValidationOfInvalidSimpleJWSWithExpAsInt()
|
||||
{
|
||||
$date = new DateTime('yesterday');
|
||||
$data = array(
|
||||
'a' => 'b',
|
||||
'exp' => $date->getTimestamp(),
|
||||
'iat' => time()
|
||||
);
|
||||
$this->jws->setPayload($data);
|
||||
|
||||
$privateKey = openssl_pkey_get_private(SSL_KEYS_PATH.'private.key', self::SSL_KEY_PASSPHRASE);
|
||||
$this->jws->sign($privateKey);
|
||||
|
||||
$jws = SimpleJWS::load($this->jws->getTokenString());
|
||||
$public_key = openssl_pkey_get_public(SSL_KEYS_PATH.'public.key');
|
||||
$this->assertFalse($jws->isValid($public_key, 'RS256'));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
$loader = require __DIR__.'/../vendor/autoload.php';
|
||||
$loader->add('Namshi\\JOSE\\Test', __DIR__);
|
||||
|
||||
define('TEST_DIR', __DIR__);
|
||||
define('SSL_KEYS_PATH', 'file://'.TEST_DIR.DIRECTORY_SEPARATOR);
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
-----BEGIN PRIVATE KEY-----
|
||||
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAN91kQxBuaze3WjI
|
||||
CNjeR/HD8E3kDzp89+Lhtn3tMish4yQxhNl6BEkabuS3pUj3WDP6+AFjBVqA1j3f
|
||||
u8Wqu7hRJDPHOs2kCII+LhIqvqQTLx/nvNOUhW2DimKn0HuHnlwJODq0MHFJEq5R
|
||||
rJH+mFGsP9yMGz4MxA04E2RVbUJRAgMBAAECgYEAjrDrO3Fo2GvD5Jn/lER0mnxt
|
||||
Ib/kvYt5WyaYutbRN1u/SKhaVeklfWzkrSZb5DkV2LOE1JXfoEgvBnms1O9OSJXw
|
||||
qDrFF7NDebw95g6JzI+SbkIHw0Cb+/E9K92FjvW3Bi8j9PKIa8c/dpwIAIirc/q8
|
||||
uhSTf4WoIOHSFbSaQPECQQD1Wi9vynJLI5lShOs0wPomZOwNrXa73Lj8ciZC4oPS
|
||||
t6tWjbLnLsP+vTSLUyEYeQGsjdbY+y5siJmAqnV/ShB9AkEA6Sgna9gQw4dXN0jB
|
||||
SjOZSjl4S2/H3wHatclrvlYfbJVU6GlIlqWGaUkdFvCuEr9iXJAY4zpEQ4P370EZ
|
||||
tsyVZQJBAOZu/X6RNSc9GBNYo0+4rzjAMLPn50wp0dPHogfPlt+hgVqZWx2l3o6y
|
||||
RVdVjA/gFqJp1Q+VWdS1tvYRIqmadkECQCVdqQuwgedEHmcewtNod42crjmwvWBx
|
||||
BKMTl6/WT4zwVb41eUujVWo0LHRLuCoK//GDqmloIh6L3MU8MqnIGb0CQFWcpD4/
|
||||
roCkMblk0hPoQPpyapJexc438x7XuEGFEhyxxauqC5R4YFKCf+KBS2gZgr4GSwBU
|
||||
Qww+qZ3eRYM7faM=
|
||||
-----END PRIVATE KEY-----
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
-----BEGIN EC PRIVATE KEY-----
|
||||
MHcCAQEEIKv1ZMzZ8Uxt/YxwdKpMAP0nlV7ne8gh0+5G+5Gb/tMUoAoGCCqGSM49
|
||||
AwEHoUQDQgAEvuYsP+QnrqAbM7Iyhzjt08hFSuzapyojCB/gFsBt65Wir4TYr5fS
|
||||
Q96oa4qeGVeTFzl+fGiZFILootvLsiPwAQ==
|
||||
-----END EC PRIVATE KEY-----
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
-----BEGIN EC PRIVATE KEY-----
|
||||
MIGkAgEBBDClxJJett5kQ5oEizsjCpxT0z844zzVeFm44egaCZL/Y90QLBx1BxfO
|
||||
/tbz6VgvRyugBwYFK4EEACKhZANiAATp/5dmyDZO+fQSgRqlD7KUxg22ybwI9/Rx
|
||||
vwcjYSR9j0Gqm3dAzPCUzuZWwVGZoxlvyc6dHCamYSe8DZTzJ1L51uc+/tvBiX6r
|
||||
Wo16HxamOivdU75FO3hx7Q+fbmgYZZQ=
|
||||
-----END EC PRIVATE KEY-----
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
-----BEGIN EC PRIVATE KEY-----
|
||||
MIHbAgEBBEEWnooUpGIch1H/s8/ZUrHPo6RL+mHKhCrDO/Yjz37zM/tBJyvHmvwY
|
||||
Utw3mYII0m3es3dIiAjheghBs14+UCPq8aAHBgUrgQQAI6GBiQOBhgAEAVpvo7TG
|
||||
pQk5P7ZLo0qkBpaT+fFDv6HQrWElBKMxcrJd/mRNapweATsVv83YON4lTIIRXzgG
|
||||
kmWeqbDr6RQO+1cSAIs+MoRmLaiPyG2xmPwQCHX2CGX/uCZiT3iOxTAJEZuUbeSA
|
||||
828K4WfAA4ODdGiB87YVShhPOkiQswV3LpbpPGhC
|
||||
-----END EC PRIVATE KEY-----
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
-----BEGIN RSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: AES-256-CBC,510C9E7AAF17A8397C4B79D906DAE432
|
||||
|
||||
W0qO1iOiS10gdomVUBbR3LdJOHRmfOmsXAjg4ezG3+Dg/0rfVkj+H3RWIpNnLq2l
|
||||
ciayAqjFzLzlKYPW4/XakyhfmCrZE+mL+kFVEUjhISZ+xXLwHGltL0UeYsei/AUp
|
||||
usjbxO8K0hZ1ZG2bQCEj5ff2YGmC9g1K3C7tE8XR0+QCZ/xaYkdUxDUIfYZ4MebG
|
||||
+C5P+mckds6lmcdZkIZj9H+36LPH2RPlMJAdLmLGytKF37h93gcL/pgePMEY+sVj
|
||||
h0YfScQ2GlE3v3S1CC1X2yjU5CtfxPHuA+2XuFIZ9twlrNFSqUWtvaCMNgSaWPLH
|
||||
KdR9RC8vImz0PEu6eR4t9ytTnykYG+mujCjumeohJoWjrXJymC4ocHIa8p/EA7Hc
|
||||
AWXxVlS897feG1BQ+rAiuvzIDvU8glKO8ZDjs9FUeC4O6ySCI9b4Of/57Uqo7nmQ
|
||||
0nLTJntvKFeusJ9WnergOEEHg1x93n8ajM49a+eS2uEj+UlIWiT01WTVS2i5wWp7
|
||||
+wcniYwlEk36HHBWSYBmhK+Uda4isE3SBBiRBa4ETh7Goor3FcxTA5TEqKwsHG0o
|
||||
1infKNmPHUy2hQTrGttoJrCpAvKq2RuQJUG5Tu5mURibihcRqCCcbyz/uKY/IIJg
|
||||
9WV3gzsDXrmr2UWovD9Rfudm6mdkhz1Sn+XS69z3irMJHuW/j2sO/bO5JseurPq7
|
||||
0V9Ms2TCIlyT7ncjsV3Lf0PSmitf/W4KzRKgxKkgORHNWX4W9yLA+yMeP3CfwaBn
|
||||
QiTk/dnN/uwVFQ5YlRkUsWOFxS7/gk/kBv15dTZV/1paqm0iPcExmtXqFvPlxnUr
|
||||
J3NeVl6j6kOUGLPsijk4zIijVMquYug4WfjCHLmzsqEGOYoK+nA6BQwxeMSOxFWT
|
||||
R8QWvvz8B6fm5BigBsUs7kQa3HcksE6YMz8dXr3r0cvINurGUpd3hDYLMdUJ0ttG
|
||||
cjdHXG3+fBOhUD8zkQSpf21V1/B4df2PiFlTKar5Jx1IiplvkTDPv6Nea8zuiVzy
|
||||
8Wp/PawNbPRs+KQAsr+pvged+VftvsVVGyG+0lXd7kPAJqxo4xEpD+NelHJKDgVy
|
||||
uuQPMoxt1TIvCAP9jD+ENCmnGU2HhpJvngsVQs+7DviCOgbbdIfff91fyrLkSNkb
|
||||
tck4q3RFpKDcKiU9yxjeAaYP6bXSq2ypwHV4YhivftyJN52TxAjGRqkuZCr5cG9P
|
||||
+l3hgwTusJSjiNFkjSv7Tq3sq+s6p3+vdqBs7pS6wH/yfnJtSnPgdOkO9NqvYG67
|
||||
ALco0hSuBmKWFjr4rk9e/fVPqOFCKZNdJ44ZFViFkF1Ry/YO7XvnxCQCOk17g/aM
|
||||
daMSNDJdZliGsu6lHxzF0/gq7ukTqAYJEh0Jvb7+l8/YMJZRFzxB0SENCTn9rPIY
|
||||
VTrajK8z33GMHUFzbGEyoZoGxNe0F4DarHqFteBjnRLFev0N88go0hlLP0NR2hBB
|
||||
RsNRTJGbzYTVZJwZTDrA11KoU3PaWFrZglsD/ExVb+OYgYv+SlbUdu9znpZBlayj
|
||||
3wJv6RqhDntrbc2yPzK/27KzToNLlqdBnUO0kl64JaZukkhpDfmKJahWO4nePxvu
|
||||
-----END RSA PRIVATE KEY-----
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
-----BEGIN PUBLIC KEY-----
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDfdZEMQbms3t1oyAjY3kfxw/BN
|
||||
5A86fPfi4bZ97TIrIeMkMYTZegRJGm7kt6VI91gz+vgBYwVagNY937vFqru4USQz
|
||||
xzrNpAiCPi4SKr6kEy8f57zTlIVtg4pip9B7h55cCTg6tDBxSRKuUayR/phRrD/c
|
||||
jBs+DMQNOBNkVW1CUQIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
-----BEGIN PUBLIC KEY-----
|
||||
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEvuYsP+QnrqAbM7Iyhzjt08hFSuza
|
||||
pyojCB/gFsBt65Wir4TYr5fSQ96oa4qeGVeTFzl+fGiZFILootvLsiPwAQ==
|
||||
-----END PUBLIC KEY-----
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
-----BEGIN PUBLIC KEY-----
|
||||
MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE6f+XZsg2Tvn0EoEapQ+ylMYNtsm8CPf0
|
||||
cb8HI2EkfY9Bqpt3QMzwlM7mVsFRmaMZb8nOnRwmpmEnvA2U8ydS+dbnPv7bwYl+
|
||||
q1qNeh8Wpjor3VO+RTt4ce0Pn25oGGWU
|
||||
-----END PUBLIC KEY-----
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
-----BEGIN PUBLIC KEY-----
|
||||
MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBWm+jtMalCTk/tkujSqQGlpP58UO/
|
||||
odCtYSUEozFysl3+ZE1qnB4BOxW/zdg43iVMghFfOAaSZZ6psOvpFA77VxIAiz4y
|
||||
hGYtqI/IbbGY/BAIdfYIZf+4JmJPeI7FMAkRm5Rt5IDzbwrhZ8ADg4N0aIHzthVK
|
||||
GE86SJCzBXculuk8aEI=
|
||||
-----END PUBLIC KEY-----
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtpS1ZmfVKVP5KofIhMBP
|
||||
0tSWc4qlh6fm2lrZSkuKxUjEaWjzZSzs72gEIGxraWusMdoRuV54xsWRyf5KeZT0
|
||||
S+I5Prle3Idi3gICiO4NwvMk6JwSBcJWwmSLFEKyUSnB2CtfiGc0/5rQCpcEt/Dn
|
||||
5iM+BNn7fqpoLIbks8rXKUIj8+qMVqkTXsEKeKinE23t1ykMldsNaaOH+hvGti5J
|
||||
t2DMnH1JjoXdDXfxvSP/0gjUYb0ektudYFXoA6wekmQyJeImvgx4Myz1I4iHtkY/
|
||||
Cp7J4Mn1ejZ6HNmyvoTE/4OuY1uCeYv4UyXFc1s1uUyYtj4z57qsHGsS4dQ3A2MJ
|
||||
swIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
Copyright (C) Brian Nesbitt
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
$dir = __DIR__.'/..';
|
||||
|
||||
if (!file_exists($dir.'/autoload.php')) {
|
||||
$dir = __DIR__.'/../vendor';
|
||||
}
|
||||
|
||||
if (!file_exists($dir.'/autoload.php')) {
|
||||
$dir = __DIR__.'/../../..';
|
||||
}
|
||||
|
||||
if (!file_exists($dir.'/autoload.php')) {
|
||||
echo 'Autoload not found.';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$composerInstalled = false;
|
||||
|
||||
if (!file_exists($dir.'/composer/composer')) {
|
||||
$composerInstalled = true;
|
||||
shell_exec('composer require --dev composer/composer');
|
||||
}
|
||||
|
||||
include $dir.'/autoload.php';
|
||||
|
||||
Carbon\Upgrade::upgrade();
|
||||
|
||||
if ($composerInstalled) {
|
||||
shell_exec('composer remove --dev composer/composer');
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
@ECHO OFF
|
||||
setlocal DISABLEDELAYEDEXPANSION
|
||||
SET BIN_TARGET=%~dp0/upgrade-carbon
|
||||
php "%BIN_TARGET%" %*
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"name": "nesbot/carbon",
|
||||
"type": "library",
|
||||
"description": "A simple API extension for DateTime.",
|
||||
"keywords": [
|
||||
"date",
|
||||
"time",
|
||||
"DateTime"
|
||||
],
|
||||
"homepage": "http://carbon.nesbot.com",
|
||||
"support": {
|
||||
"issues": "https://github.com/briannesbitt/Carbon/issues",
|
||||
"source": "https://github.com/briannesbitt/Carbon"
|
||||
},
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Brian Nesbitt",
|
||||
"email": "brian@nesbot.com",
|
||||
"homepage": "http://nesbot.com"
|
||||
}
|
||||
],
|
||||
"bin": ["bin/upgrade-carbon"],
|
||||
"require": {
|
||||
"php": ">=5.3.9",
|
||||
"kylekatarnls/update-helper": "^1.1",
|
||||
"symfony/translation": "~2.6 || ~3.0 || ~4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "^1.2",
|
||||
"friendsofphp/php-cs-fixer": "~2",
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"scripts": {
|
||||
"test": [
|
||||
"@phpunit",
|
||||
"@phpcs"
|
||||
],
|
||||
"phpunit": "phpunit --verbose --coverage-clover=coverage.xml",
|
||||
"phpcs": "php-cs-fixer fix -v --diff --dry-run",
|
||||
"phpstan": "phpstan analyse --configuration phpstan.neon --level 3 src tests",
|
||||
"post-autoload-dump": [
|
||||
"UpdateHelper\\UpdateHelper::check"
|
||||
],
|
||||
"upgrade-carbon": [
|
||||
"Carbon\\Upgrade::upgrade"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"update-helper": "Carbon\\Upgrade",
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Carbon\\Laravel\\ServiceProvider"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
# Carbon
|
||||
|
||||
[](https://packagist.org/packages/nesbot/carbon)
|
||||
[](https://packagist.org/packages/nesbot/carbon)
|
||||
[](https://travis-ci.org/briannesbitt/Carbon)
|
||||
[](https://styleci.io/repos/5724990)
|
||||
[](https://codecov.io/github/briannesbitt/Carbon?branch=master)
|
||||
[](https://php-eye.com/package/nesbot/carbon)
|
||||
[](https://github.com/phpstan/phpstan)
|
||||
|
||||
A simple PHP API extension for DateTime. [http://carbon.nesbot.com](http://carbon.nesbot.com)
|
||||
|
||||
```php
|
||||
use Carbon\Carbon;
|
||||
|
||||
printf("Right now is %s", Carbon::now()->toDateTimeString());
|
||||
printf("Right now in Vancouver is %s", Carbon::now('America/Vancouver')); //implicit __toString()
|
||||
$tomorrow = Carbon::now()->addDay();
|
||||
$lastWeek = Carbon::now()->subWeek();
|
||||
$nextSummerOlympics = Carbon::createFromDate(2016)->addYears(4);
|
||||
|
||||
$officialDate = Carbon::now()->toRfc2822String();
|
||||
|
||||
$howOldAmI = Carbon::createFromDate(1975, 5, 21)->age;
|
||||
|
||||
$noonTodayLondonTime = Carbon::createFromTime(12, 0, 0, 'Europe/London');
|
||||
|
||||
$internetWillBlowUpOn = Carbon::create(2038, 01, 19, 3, 14, 7, 'GMT');
|
||||
|
||||
// Don't really want this to happen so mock now
|
||||
Carbon::setTestNow(Carbon::createFromDate(2000, 1, 1));
|
||||
|
||||
// comparisons are always done in UTC
|
||||
if (Carbon::now()->gte($internetWillBlowUpOn)) {
|
||||
die();
|
||||
}
|
||||
|
||||
// Phew! Return to normal behaviour
|
||||
Carbon::setTestNow();
|
||||
|
||||
if (Carbon::now()->isWeekend()) {
|
||||
echo 'Party!';
|
||||
}
|
||||
echo Carbon::now()->subMinutes(2)->diffForHumans(); // '2 minutes ago'
|
||||
|
||||
// ... but also does 'from now', 'after' and 'before'
|
||||
// rolling up to seconds, minutes, hours, days, months, years
|
||||
|
||||
$daysSinceEpoch = Carbon::createFromTimestamp(0)->diffInDays();
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
### With Composer
|
||||
|
||||
```
|
||||
$ composer require nesbot/carbon
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"nesbot/carbon": "~1.21"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```php
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
printf("Now: %s", Carbon::now());
|
||||
```
|
||||
|
||||
<a name="install-nocomposer"/>
|
||||
|
||||
### Without Composer
|
||||
|
||||
Why are you not using [composer](http://getcomposer.org/)? Download [Carbon.php](https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/Carbon.php) from the repo and save the file into your project path somewhere.
|
||||
|
||||
```php
|
||||
<?php
|
||||
require 'path/to/Carbon.php';
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
printf("Now: %s", Carbon::now());
|
||||
```
|
||||
|
||||
## Docs
|
||||
|
||||
[http://carbon.nesbot.com/docs](http://carbon.nesbot.com/docs)
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue