mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-27 15:30:24 +05:30
Checkin
This commit is contained in:
parent
18b104d0ac
commit
82413513e8
@ -4,14 +4,12 @@
|
||||
"homepage": "http://oauth2.thephpleague.com/",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"symfony/http-foundation": "~2.4",
|
||||
"php": ">=5.5.9",
|
||||
"league/event": "~2.1",
|
||||
"league/container": "~1.0",
|
||||
"firebase/php-jwt": "~2.0"
|
||||
"zendframework/zend-diactoros": "~1.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.3.*",
|
||||
"phpunit/phpunit": "4.8.*",
|
||||
"mockery/mockery": "0.9.*",
|
||||
"codeception/codeception": "~2.0",
|
||||
"flow/jsonpath": "0.2.*"
|
||||
|
@ -2,7 +2,6 @@
|
||||
"name": "",
|
||||
"require": {
|
||||
"alexbilbie/proton": "~1.4",
|
||||
"illuminate/database": "~5.0",
|
||||
"ircmaxell/password-compat": "~1.0"
|
||||
},
|
||||
"autoload": {
|
||||
|
669
examples/composer.lock
generated
669
examples/composer.lock
generated
@ -1,10 +1,11 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "9ae3d11ba275cce8764cfa3002ec7c93",
|
||||
"hash": "ad90034834be06a42fc0b780af9a9425",
|
||||
"content-hash": "caf5b7d7e9c81d118a89ce3b7a38b6ad",
|
||||
"packages": [
|
||||
{
|
||||
"name": "alexbilbie/proton",
|
||||
@ -64,368 +65,6 @@
|
||||
],
|
||||
"time": "2015-03-26 17:35:31"
|
||||
},
|
||||
{
|
||||
"name": "danielstjules/stringy",
|
||||
"version": "1.9.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/danielstjules/Stringy.git",
|
||||
"reference": "3cf18e9e424a6dedc38b7eb7ef580edb0929461b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/danielstjules/Stringy/zipball/3cf18e9e424a6dedc38b7eb7ef580edb0929461b",
|
||||
"reference": "3cf18e9e424a6dedc38b7eb7ef580edb0929461b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Stringy\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/Create.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Daniel St. Jules",
|
||||
"email": "danielst.jules@gmail.com",
|
||||
"homepage": "http://www.danielstjules.com"
|
||||
}
|
||||
],
|
||||
"description": "A string manipulation library with multibyte support",
|
||||
"homepage": "https://github.com/danielstjules/Stringy",
|
||||
"keywords": [
|
||||
"UTF",
|
||||
"helpers",
|
||||
"manipulation",
|
||||
"methods",
|
||||
"multibyte",
|
||||
"string",
|
||||
"utf-8",
|
||||
"utility",
|
||||
"utils"
|
||||
],
|
||||
"time": "2015-02-10 06:19:18"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/inflector",
|
||||
"version": "v1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/inflector.git",
|
||||
"reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/inflector/zipball/0bcb2e79d8571787f18b7eb036ed3d004908e604",
|
||||
"reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Doctrine\\Common\\Inflector\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Benjamin Eberlei",
|
||||
"email": "kontakt@beberlei.de"
|
||||
},
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Wage",
|
||||
"email": "jonwage@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Common String Manipulations with regard to casing and singular/plural rules.",
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"inflection",
|
||||
"pluralize",
|
||||
"singularize",
|
||||
"string"
|
||||
],
|
||||
"time": "2014-12-20 21:24:13"
|
||||
},
|
||||
{
|
||||
"name": "firebase/php-jwt",
|
||||
"version": "2.0.0",
|
||||
"target-dir": "Firebase/PHP-JWT",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/firebase/php-jwt.git",
|
||||
"reference": "ffcfd888ce1e4f2d70cac2dc9b7301038332fe57"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/firebase/php-jwt/zipball/ffcfd888ce1e4f2d70cac2dc9b7301038332fe57",
|
||||
"reference": "ffcfd888ce1e4f2d70cac2dc9b7301038332fe57",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.2.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"Authentication/",
|
||||
"Exceptions/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Neuman Vong",
|
||||
"email": "neuman+pear@twilio.com",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Anant Narayanan",
|
||||
"email": "anant@php.net",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
|
||||
"homepage": "https://github.com/firebase/php-jwt",
|
||||
"time": "2015-04-01 18:46:38"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/container",
|
||||
"version": "v5.0.26",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/container.git",
|
||||
"reference": "a11c01c1d8b6941bd7ef2f104749ada5e34f146e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/container/zipball/a11c01c1d8b6941bd7ef2f104749ada5e34f146e",
|
||||
"reference": "a11c01c1d8b6941bd7ef2f104749ada5e34f146e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/contracts": "5.0.*",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Container\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "The Illuminate Container package.",
|
||||
"homepage": "http://laravel.com",
|
||||
"time": "2015-03-25 17:06:14"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/contracts",
|
||||
"version": "v5.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/contracts.git",
|
||||
"reference": "78f1dba092d5fcb6d3a19537662abe31c4d128fd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/contracts/zipball/78f1dba092d5fcb6d3a19537662abe31c4d128fd",
|
||||
"reference": "78f1dba092d5fcb6d3a19537662abe31c4d128fd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Contracts\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "The Illuminate Contracts package.",
|
||||
"time": "2015-01-30 16:27:08"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/database",
|
||||
"version": "v5.0.27",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/database.git",
|
||||
"reference": "8d41d6a2c20b4295f7f77b5ee1ac91d9060510f5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/database/zipball/8d41d6a2c20b4295f7f77b5ee1ac91d9060510f5",
|
||||
"reference": "8d41d6a2c20b4295f7f77b5ee1ac91d9060510f5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/container": "5.0.*",
|
||||
"illuminate/contracts": "5.0.*",
|
||||
"illuminate/support": "5.0.*",
|
||||
"nesbot/carbon": "~1.0",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.4).",
|
||||
"illuminate/console": "Required to use the database commands (5.0.*).",
|
||||
"illuminate/events": "Required to use the observers with Eloquent (5.0.*).",
|
||||
"illuminate/filesystem": "Required to use the migrations (5.0.*)."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Database\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "The Illuminate Database package.",
|
||||
"homepage": "http://laravel.com",
|
||||
"keywords": [
|
||||
"database",
|
||||
"laravel",
|
||||
"orm",
|
||||
"sql"
|
||||
],
|
||||
"time": "2015-04-04 01:34:34"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/support",
|
||||
"version": "v5.0.26",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/support.git",
|
||||
"reference": "29e8618a45d090572e092abf193a257bf28c48d9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/support/zipball/29e8618a45d090572e092abf193a257bf28c48d9",
|
||||
"reference": "29e8618a45d090572e092abf193a257bf28c48d9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"danielstjules/stringy": "~1.8",
|
||||
"doctrine/inflector": "~1.0",
|
||||
"ext-mbstring": "*",
|
||||
"illuminate/contracts": "5.0.*",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"jeremeamia/superclosure": "Required to be able to serialize closures (~2.0)."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Support\\": ""
|
||||
},
|
||||
"files": [
|
||||
"helpers.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "The Illuminate Support package.",
|
||||
"homepage": "http://laravel.com",
|
||||
"time": "2015-03-27 14:49:11"
|
||||
},
|
||||
{
|
||||
"name": "ircmaxell/password-compat",
|
||||
"version": "v1.0.4",
|
||||
@ -470,16 +109,16 @@
|
||||
},
|
||||
{
|
||||
"name": "league/container",
|
||||
"version": "1.3.1",
|
||||
"version": "1.3.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/container.git",
|
||||
"reference": "6cbb3d83bfb979eaf43cd3c279c22abf3fbcf9ff"
|
||||
"reference": "7e6c17fe48f76f3b97aeca70dc29c3f3c7c88d15"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/container/zipball/6cbb3d83bfb979eaf43cd3c279c22abf3fbcf9ff",
|
||||
"reference": "6cbb3d83bfb979eaf43cd3c279c22abf3fbcf9ff",
|
||||
"url": "https://api.github.com/repos/thephpleague/container/zipball/7e6c17fe48f76f3b97aeca70dc29c3f3c7c88d15",
|
||||
"reference": "7e6c17fe48f76f3b97aeca70dc29c3f3c7c88d15",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -494,7 +133,8 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.3-dev"
|
||||
"dev-master": "2.0-dev",
|
||||
"dev-1.x": "1.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@ -523,20 +163,20 @@
|
||||
"injection",
|
||||
"league"
|
||||
],
|
||||
"time": "2015-02-21 18:55:49"
|
||||
"time": "2015-04-05 17:14:48"
|
||||
},
|
||||
{
|
||||
"name": "league/event",
|
||||
"version": "2.1.1",
|
||||
"version": "2.1.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/event.git",
|
||||
"reference": "cecc6213023a8b18efb163853569082051e5f1ea"
|
||||
"reference": "e4bfc88dbcb60c8d8a2939a71f9813e141bbe4cd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/event/zipball/cecc6213023a8b18efb163853569082051e5f1ea",
|
||||
"reference": "cecc6213023a8b18efb163853569082051e5f1ea",
|
||||
"url": "https://api.github.com/repos/thephpleague/event/zipball/e4bfc88dbcb60c8d8a2939a71f9813e141bbe4cd",
|
||||
"reference": "e4bfc88dbcb60c8d8a2939a71f9813e141bbe4cd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -573,20 +213,20 @@
|
||||
"event",
|
||||
"listener"
|
||||
],
|
||||
"time": "2015-03-30 07:53:52"
|
||||
"time": "2015-05-21 12:24:47"
|
||||
},
|
||||
{
|
||||
"name": "league/route",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/route.git",
|
||||
"reference": "06b0b3cb203f329875ad534d0f8a049d23767005"
|
||||
"reference": "079e87a4653b43e2cba47b9e0563179c1c49fcf8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/route/zipball/06b0b3cb203f329875ad534d0f8a049d23767005",
|
||||
"reference": "06b0b3cb203f329875ad534d0f8a049d23767005",
|
||||
"url": "https://api.github.com/repos/thephpleague/route/zipball/079e87a4653b43e2cba47b9e0563179c1c49fcf8",
|
||||
"reference": "079e87a4653b43e2cba47b9e0563179c1c49fcf8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -631,20 +271,20 @@
|
||||
"league",
|
||||
"route"
|
||||
],
|
||||
"time": "2015-02-24 18:34:01"
|
||||
"time": "2015-09-11 07:40:31"
|
||||
},
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
"version": "1.13.1",
|
||||
"version": "1.17.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Seldaek/monolog.git",
|
||||
"reference": "c31a2c4e8db5da8b46c74cf275d7f109c0f249ac"
|
||||
"reference": "0524c87587ab85bc4c2d6f5b41253ccb930a5422"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/c31a2c4e8db5da8b46c74cf275d7f109c0f249ac",
|
||||
"reference": "c31a2c4e8db5da8b46c74cf275d7f109c0f249ac",
|
||||
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/0524c87587ab85bc4c2d6f5b41253ccb930a5422",
|
||||
"reference": "0524c87587ab85bc4c2d6f5b41253ccb930a5422",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -655,12 +295,14 @@
|
||||
"psr/log-implementation": "1.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"aws/aws-sdk-php": "~2.4, >2.4.8",
|
||||
"aws/aws-sdk-php": "^2.4.9",
|
||||
"doctrine/couchdb": "~1.0@dev",
|
||||
"graylog2/gelf-php": "~1.0",
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"raven/raven": "~0.5",
|
||||
"ruflin/elastica": "0.90.*",
|
||||
"php-console/php-console": "^3.1.3",
|
||||
"phpunit/phpunit": "~4.5",
|
||||
"phpunit/phpunit-mock-objects": "2.3.0",
|
||||
"raven/raven": "~0.11",
|
||||
"ruflin/elastica": ">=0.90 <3.0",
|
||||
"swiftmailer/swiftmailer": "~5.3",
|
||||
"videlalvaro/php-amqplib": "~2.4"
|
||||
},
|
||||
@ -670,6 +312,7 @@
|
||||
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
|
||||
"ext-mongo": "Allow sending log messages to a MongoDB server",
|
||||
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
|
||||
"php-console/php-console": "Allow sending log messages to Google Chrome",
|
||||
"raven/raven": "Allow sending log messages to a Sentry server",
|
||||
"rollbar/rollbar": "Allow sending log messages to Rollbar",
|
||||
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
|
||||
@ -678,7 +321,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.13.x-dev"
|
||||
"dev-master": "1.16.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@ -704,67 +347,20 @@
|
||||
"logging",
|
||||
"psr-3"
|
||||
],
|
||||
"time": "2015-03-09 09:58:04"
|
||||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
"version": "1.18.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/briannesbitt/Carbon.git",
|
||||
"reference": "99e2f69f7bdc2cc4334b2d00f1e0ba450623ea36"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/99e2f69f7bdc2cc4334b2d00f1e0ba450623ea36",
|
||||
"reference": "99e2f69f7bdc2cc4334b2d00f1e0ba450623ea36",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"symfony/translation": "2.6.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Carbon": "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"
|
||||
],
|
||||
"time": "2015-03-26 03:05:57"
|
||||
"time": "2015-08-31 09:17:37"
|
||||
},
|
||||
{
|
||||
"name": "nikic/fast-route",
|
||||
"version": "v0.4.0",
|
||||
"version": "v0.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nikic/FastRoute.git",
|
||||
"reference": "f26a8f7788f25c0e3e9b1579d38d7ccab2755320"
|
||||
"reference": "31fa86924556b80735f98b294a7ffdfb26789f22"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nikic/FastRoute/zipball/f26a8f7788f25c0e3e9b1579d38d7ccab2755320",
|
||||
"reference": "f26a8f7788f25c0e3e9b1579d38d7ccab2755320",
|
||||
"url": "https://api.github.com/repos/nikic/FastRoute/zipball/31fa86924556b80735f98b294a7ffdfb26789f22",
|
||||
"reference": "31fa86924556b80735f98b294a7ffdfb26789f22",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -794,7 +390,7 @@
|
||||
"router",
|
||||
"routing"
|
||||
],
|
||||
"time": "2015-02-26 15:33:07"
|
||||
"time": "2015-06-18 19:15:47"
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
@ -836,21 +432,20 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/debug",
|
||||
"version": "v2.6.6",
|
||||
"target-dir": "Symfony/Component/Debug",
|
||||
"version": "v2.7.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Debug.git",
|
||||
"reference": "d49a46a20a8f0544aedac54466750ad787d3d3e3"
|
||||
"url": "https://github.com/symfony/debug.git",
|
||||
"reference": "c79c361bca8e5ada6a47603875a3c964d03b67b1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Debug/zipball/d49a46a20a8f0544aedac54466750ad787d3d3e3",
|
||||
"reference": "d49a46a20a8f0544aedac54466750ad787d3d3e3",
|
||||
"url": "https://api.github.com/repos/symfony/debug/zipball/c79c361bca8e5ada6a47603875a3c964d03b67b1",
|
||||
"reference": "c79c361bca8e5ada6a47603875a3c964d03b67b1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"php": ">=5.3.9",
|
||||
"psr/log": "~1.0"
|
||||
},
|
||||
"conflict": {
|
||||
@ -858,22 +453,17 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/class-loader": "~2.2",
|
||||
"symfony/http-foundation": "~2.1",
|
||||
"symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2",
|
||||
"symfony/phpunit-bridge": "~2.7"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/http-foundation": "",
|
||||
"symfony/http-kernel": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.6-dev"
|
||||
"dev-master": "2.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Debug\\": ""
|
||||
}
|
||||
},
|
||||
@ -882,36 +472,35 @@
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Debug Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2015-03-22 16:55:57"
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-09-14 08:41:38"
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher",
|
||||
"version": "v2.6.6",
|
||||
"target-dir": "Symfony/Component/EventDispatcher",
|
||||
"version": "v2.7.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/EventDispatcher.git",
|
||||
"reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284"
|
||||
"url": "https://github.com/symfony/event-dispatcher.git",
|
||||
"reference": "ae4dcc2a8d3de98bd794167a3ccda1311597c5d9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/70f7c8478739ad21e3deef0d977b38c77f1fb284",
|
||||
"reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284",
|
||||
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ae4dcc2a8d3de98bd794167a3ccda1311597c5d9",
|
||||
"reference": "ae4dcc2a8d3de98bd794167a3ccda1311597c5d9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
"php": ">=5.3.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/log": "~1.0",
|
||||
@ -928,11 +517,11 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.6-dev"
|
||||
"dev-master": "2.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\EventDispatcher\\": ""
|
||||
}
|
||||
},
|
||||
@ -941,36 +530,35 @@
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony EventDispatcher Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2015-03-13 17:37:22"
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-09-22 13:49:29"
|
||||
},
|
||||
{
|
||||
"name": "symfony/http-foundation",
|
||||
"version": "v2.6.6",
|
||||
"target-dir": "Symfony/Component/HttpFoundation",
|
||||
"version": "v2.7.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/HttpFoundation.git",
|
||||
"reference": "8a6337233f08f7520de97f4ffd6f00e947d892f9"
|
||||
"url": "https://github.com/symfony/http-foundation.git",
|
||||
"reference": "e1509119f164a0d0a940d7d924d693a7a28a5470"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/8a6337233f08f7520de97f4ffd6f00e947d892f9",
|
||||
"reference": "8a6337233f08f7520de97f4ffd6f00e947d892f9",
|
||||
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/e1509119f164a0d0a940d7d924d693a7a28a5470",
|
||||
"reference": "e1509119f164a0d0a940d7d924d693a7a28a5470",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
"php": ">=5.3.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/expression-language": "~2.4",
|
||||
@ -979,15 +567,15 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.6-dev"
|
||||
"dev-master": "2.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\HttpFoundation\\": ""
|
||||
},
|
||||
"classmap": [
|
||||
"Symfony/Component/HttpFoundation/Resources/stubs"
|
||||
"Resources/stubs"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
@ -995,45 +583,47 @@
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony HttpFoundation Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2015-04-01 16:50:12"
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-09-22 13:49:29"
|
||||
},
|
||||
{
|
||||
"name": "symfony/http-kernel",
|
||||
"version": "v2.6.6",
|
||||
"target-dir": "Symfony/Component/HttpKernel",
|
||||
"version": "v2.7.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/HttpKernel.git",
|
||||
"reference": "3829cacfe21eaf3f73604a62d79183d1f6e792c4"
|
||||
"url": "https://github.com/symfony/http-kernel.git",
|
||||
"reference": "353aa457424262d7d4e4289ea483145921cffcb5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/3829cacfe21eaf3f73604a62d79183d1f6e792c4",
|
||||
"reference": "3829cacfe21eaf3f73604a62d79183d1f6e792c4",
|
||||
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/353aa457424262d7d4e4289ea483145921cffcb5",
|
||||
"reference": "353aa457424262d7d4e4289ea483145921cffcb5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"php": ">=5.3.9",
|
||||
"psr/log": "~1.0",
|
||||
"symfony/debug": "~2.6,>=2.6.2",
|
||||
"symfony/event-dispatcher": "~2.5.9|~2.6,>=2.6.2",
|
||||
"symfony/event-dispatcher": "~2.6,>=2.6.7",
|
||||
"symfony/http-foundation": "~2.5,>=2.5.4"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/config": "<2.7"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/browser-kit": "~2.3",
|
||||
"symfony/class-loader": "~2.1",
|
||||
"symfony/config": "~2.0,>=2.0.5",
|
||||
"symfony/config": "~2.7",
|
||||
"symfony/console": "~2.3",
|
||||
"symfony/css-selector": "~2.0,>=2.0.5",
|
||||
"symfony/dependency-injection": "~2.2",
|
||||
@ -1060,11 +650,11 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.6-dev"
|
||||
"dev-master": "2.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\HttpKernel\\": ""
|
||||
}
|
||||
},
|
||||
@ -1073,77 +663,18 @@
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony HttpKernel Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2015-04-01 16:55:26"
|
||||
},
|
||||
{
|
||||
"name": "symfony/translation",
|
||||
"version": "v2.6.6",
|
||||
"target-dir": "Symfony/Component/Translation",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Translation.git",
|
||||
"reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Translation/zipball/bd939f05cdaca128f4ddbae1b447d6f0203b60af",
|
||||
"reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/log": "~1.0",
|
||||
"symfony/config": "~2.3,>=2.3.12",
|
||||
"symfony/intl": "~2.3",
|
||||
"symfony/phpunit-bridge": "~2.7",
|
||||
"symfony/yaml": "~2.2"
|
||||
},
|
||||
"suggest": {
|
||||
"psr/log": "To use logging capability in translator",
|
||||
"symfony/config": "",
|
||||
"symfony/yaml": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.6-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Symfony\\Component\\Translation\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Translation Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2015-03-30 15:54:10"
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-09-25 11:16:52"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
|
@ -1,32 +1,20 @@
|
||||
<?php
|
||||
|
||||
use League\OAuth2\Server\Exception\OAuthException;
|
||||
use League\OAuth2\Server\Grant\ClientCredentialsGrant;
|
||||
use League\OAuth2\Server\Server;
|
||||
use OAuth2ServerExamples\Repositories\AccessTokenRepository;
|
||||
use OAuth2ServerExamples\Repositories\ClientRepository;
|
||||
use OAuth2ServerExamples\Repositories\ScopeRepository;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
include(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// Setup the authorization server
|
||||
$server = new Server();
|
||||
$server->addRepository(new ClientRepository());
|
||||
$server->addRepository(new ScopeRepository());
|
||||
$server->addRepository(new AccessTokenRepository());
|
||||
|
||||
// Enable the client credentials grant which will return access tokens that last for 24 hours
|
||||
$server->enableGrantType('ClientCredentialsGrant', null, new \DateInterval('PT24H'));
|
||||
// Init our repositories
|
||||
$clientRepository = new ClientRepository();
|
||||
$scopeRepository = new ScopeRepository();
|
||||
$accessTokenRepository = new AccessTokenRepository();
|
||||
|
||||
// Setup app + routing
|
||||
$application = new \Proton\Application();
|
||||
$application->post('/access_token', function (Request $request) use ($server) {
|
||||
try {
|
||||
return $server->getAccessTokenResponse($request);
|
||||
} catch (OAuthException $e) {
|
||||
return $e->generateHttpResponse();
|
||||
}
|
||||
});
|
||||
|
||||
// Run the app
|
||||
$application->run();
|
||||
// Enable the client credentials grant on the server
|
||||
$server->enableGrantType(new ClientCredentialsGrant($clientRepository, $scopeRepository, $accessTokenRepository));
|
||||
|
@ -30,7 +30,7 @@ class InvalidRequestException extends OAuthException
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
public function __construct($parameter, $redirectUri = null)
|
||||
public function __construct($parameter, $redirectUri = null, $description = null)
|
||||
{
|
||||
parent::__construct(
|
||||
sprintf(
|
||||
|
@ -11,9 +11,11 @@
|
||||
|
||||
namespace League\OAuth2\Server\Exception;
|
||||
|
||||
use League\OAuth2\Server\Util\RedirectUri;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use League\OAuth2\Server\Utils\RedirectUri;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Zend\Diactoros\Request;
|
||||
use Zend\Diactoros\Response;
|
||||
use Zend\Diactoros\ServerRequest;
|
||||
|
||||
/**
|
||||
* Exception class
|
||||
@ -37,14 +39,21 @@ class OAuthException extends \Exception
|
||||
*/
|
||||
public $errorType = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* Throw a new exception
|
||||
*
|
||||
* @param string $msg Exception Message
|
||||
* @param string $msg Exception Message
|
||||
* @param string|null $description Description of error
|
||||
*/
|
||||
public function __construct($msg = 'An error occured')
|
||||
public function __construct($msg = 'An error occurred', $description = null)
|
||||
{
|
||||
parent::__construct($msg);
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,7 +90,7 @@ class OAuthException extends \Exception
|
||||
public function getHttpHeaders()
|
||||
{
|
||||
$headers = [
|
||||
'Content-type' => 'application/json'
|
||||
'Content-type' => 'application/json'
|
||||
];
|
||||
switch ($this->httpStatusCode) {
|
||||
case 401:
|
||||
@ -110,11 +119,11 @@ class OAuthException extends \Exception
|
||||
// @codeCoverageIgnoreStart
|
||||
if ($this->errorType === 'invalid_client') {
|
||||
$authScheme = null;
|
||||
$request = new Request();
|
||||
if ($request->getUser() !== null) {
|
||||
$request = new ServerRequest();
|
||||
if ($request->getServerParams()['PHP_AUTH_USER'] !== null) {
|
||||
$authScheme = 'Basic';
|
||||
} else {
|
||||
$authHeader = $request->headers->get('Authorization');
|
||||
$authHeader = $request->getHeader('authorization');
|
||||
if ($authHeader !== null) {
|
||||
if (strpos($authHeader, 'Bearer') === 0) {
|
||||
$authScheme = 'Bearer';
|
||||
@ -124,7 +133,7 @@ class OAuthException extends \Exception
|
||||
}
|
||||
}
|
||||
if ($authScheme !== null) {
|
||||
$headers[] = 'WWW-Authenticate: ' . $authScheme . ' realm=""';
|
||||
$headers[] = 'WWW-Authenticate: ' . $authScheme . ' realm="OAuth"';
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
@ -133,17 +142,21 @@ class OAuthException extends \Exception
|
||||
|
||||
/**
|
||||
* Generate a HTTP response
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function generateHttpResponse()
|
||||
{
|
||||
$payload = [
|
||||
'error' => $this->errorType,
|
||||
'message' => $this->getMessage()
|
||||
];
|
||||
|
||||
if ($this->description !== null) {
|
||||
$payload['description'] = $this->description;
|
||||
}
|
||||
|
||||
return new Response(
|
||||
json_encode(
|
||||
[
|
||||
'error' => $this->errorType,
|
||||
'message' => $this->getMessage()
|
||||
]
|
||||
),
|
||||
json_encode($payload),
|
||||
$this->httpStatusCode,
|
||||
$this->getHttpHeaders()
|
||||
);
|
||||
|
@ -18,6 +18,7 @@ use League\OAuth2\Server\Exception;
|
||||
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
||||
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
|
||||
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
/**
|
||||
* Abstract grant class
|
||||
@ -39,7 +40,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
||||
protected $respondsWith = 'token';
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\HttpFoundation\Request
|
||||
* @var ServerRequestInterface
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
@ -64,18 +65,15 @@ abstract class AbstractGrant implements GrantTypeInterface
|
||||
protected $scopeRepository;
|
||||
|
||||
/**
|
||||
* @param \League\Event\Emitter $emitter
|
||||
* @param \League\OAuth2\Server\Repositories\ClientRepositoryInterface $clientRepository
|
||||
* @param \League\OAuth2\Server\Repositories\ScopeRepositoryInterface $scopeRepository
|
||||
* @param \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface $accessTokenRepository
|
||||
*/
|
||||
public function __construct(
|
||||
Emitter $emitter,
|
||||
ClientRepositoryInterface $clientRepository,
|
||||
ScopeRepositoryInterface $scopeRepository,
|
||||
AccessTokenRepositoryInterface $accessTokenRepository
|
||||
) {
|
||||
$this->emitter = $emitter;
|
||||
$this->clientRepository = $clientRepository;
|
||||
$this->scopeRepository = $scopeRepository;
|
||||
$this->accessTokenRepository = $accessTokenRepository;
|
||||
@ -98,8 +96,8 @@ abstract class AbstractGrant implements GrantTypeInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $scopeParamValue A string containing a delimited set of scope identifiers
|
||||
* @param string $scopeDelimiter The delimiter between the scopes in the value string
|
||||
* @param string $scopeParamValue A string containing a delimited set of scope identifiers
|
||||
* @param string $scopeDelimiterString The delimiter between the scopes in the value string
|
||||
* @param ClientEntityInterface $client
|
||||
* @param string $redirectUri
|
||||
*
|
||||
@ -108,18 +106,16 @@ abstract class AbstractGrant implements GrantTypeInterface
|
||||
*/
|
||||
public function validateScopes(
|
||||
$scopeParamValue,
|
||||
$scopeDelimiter,
|
||||
$scopeDelimiterString,
|
||||
ClientEntityInterface $client,
|
||||
$redirectUri = null
|
||||
) {
|
||||
$scopesList = explode($scopeDelimiter, trim($scopeParamValue));
|
||||
|
||||
for ($i = 0; $i < count($scopesList); $i++) {
|
||||
$scopesList[$i] = trim($scopesList[$i]);
|
||||
if ($scopesList[$i] === '') {
|
||||
unset($scopesList[$i]); // Remove any junk scopes
|
||||
$scopesList = array_filter(
|
||||
explode($scopeDelimiterString, trim($scopeParamValue)),
|
||||
function ($scope) {
|
||||
return !empty($scope);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$scopes = [];
|
||||
foreach ($scopesList as $scopeItem) {
|
||||
@ -138,4 +134,12 @@ abstract class AbstractGrant implements GrantTypeInterface
|
||||
|
||||
return $scopes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Emitter $emitter
|
||||
*/
|
||||
public function setEmitter(Emitter $emitter)
|
||||
{
|
||||
$this->emitter = $emitter;
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ class AuthCodeGrant extends AbstractGrant
|
||||
// Get the required params
|
||||
$clientId = $request->request->get('client_id', $request->getUser());
|
||||
if (is_null($clientId)) {
|
||||
throw new InvalidRequestException('client_id');
|
||||
throw new InvalidRequestException('client_id', '');
|
||||
}
|
||||
|
||||
$clientSecret = $request->request->get('client_secret',
|
||||
|
@ -18,7 +18,7 @@ use League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface;
|
||||
use League\OAuth2\Server\Exception;
|
||||
use League\OAuth2\Server\TokenTypes\TokenTypeInterface;
|
||||
use League\OAuth2\Server\Utils\SecureKey;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
/**
|
||||
* Client credentials grant class
|
||||
@ -35,7 +35,7 @@ class ClientCredentialsGrant extends AbstractGrant
|
||||
/**
|
||||
* Return an access token
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
||||
* @param \League\OAuth2\Server\TokenTypes\TokenTypeInterface $tokenType
|
||||
* @param \DateInterval $accessTokenTTL
|
||||
* @param string $scopeDelimiter
|
||||
@ -45,19 +45,29 @@ class ClientCredentialsGrant extends AbstractGrant
|
||||
* @throws \League\OAuth2\Server\Exception\InvalidRequestException
|
||||
* @throws \League\OAuth2\Server\Exception\InvalidScopeException
|
||||
*/
|
||||
public function getAccessTokenAsType(
|
||||
Request $request,
|
||||
public function respondToRequest(
|
||||
ServerRequestInterface $request,
|
||||
TokenTypeInterface $tokenType,
|
||||
DateInterval $accessTokenTTL,
|
||||
$scopeDelimiter = ' '
|
||||
) {
|
||||
// Get the required params
|
||||
$clientId = $request->request->get('client_id', $request->getUser());
|
||||
$clientId = isset($request->getParsedBody()['client_id'])
|
||||
? $request->getParsedBody()['client_id'] // $_POST['client_id']
|
||||
: isset($request->getServerParams()['PHP_AUTH_USER'])
|
||||
? $request->getServerParams()['PHP_AUTH_USER'] // $_SERVER['PHP_AUTH_USER']
|
||||
: null;
|
||||
|
||||
if (is_null($clientId)) {
|
||||
throw new Exception\InvalidRequestException('client_id');
|
||||
}
|
||||
|
||||
$clientSecret = $request->request->get('client_secret', $request->getPassword());
|
||||
$clientSecret = isset($request->getParsedBody()['client_secret'])
|
||||
? $request->getParsedBody()['client_secret'] // $_POST['client_id']
|
||||
: isset($request->getServerParams()['PHP_AUTH_PW'])
|
||||
? $request->getServerParams()['PHP_AUTH_PW'] // $_SERVER['PHP_AUTH_USER']
|
||||
: null;
|
||||
|
||||
if (is_null($clientSecret)) {
|
||||
throw new Exception\InvalidRequestException('client_secret');
|
||||
}
|
||||
@ -76,14 +86,15 @@ class ClientCredentialsGrant extends AbstractGrant
|
||||
}
|
||||
|
||||
// Validate any scopes that are in the request
|
||||
$scopeParam = $request->request->get('scope', '');
|
||||
$scopeParam = isset($request->getParsedBody()['scope'])
|
||||
? $request->getParsedBody()['scope'] // $_POST['scope']
|
||||
: '';
|
||||
$scopes = $this->validateScopes($scopeParam, $scopeDelimiter, $client);
|
||||
|
||||
// Generate an access token
|
||||
$accessToken = new AccessTokenEntity();
|
||||
$accessToken->setIdentifier(SecureKey::generate());
|
||||
$expirationDateTime = (new \DateTime())->add($accessTokenTTL);
|
||||
$accessToken->setExpiryDateTime($expirationDateTime);
|
||||
$accessToken->setExpiryDateTime((new \DateTime())->add($accessTokenTTL));
|
||||
$accessToken->setClient($client);
|
||||
$accessToken->setOwner('client', $client->getIdentifier());
|
||||
|
||||
@ -100,4 +111,28 @@ class ClientCredentialsGrant extends AbstractGrant
|
||||
|
||||
return $tokenType;
|
||||
}
|
||||
|
||||
/**
|
||||
* The grant type should return true if it is able to respond to this request.
|
||||
*
|
||||
* For example most grant types will check that the $_POST['grant_type'] property matches it's identifier property.
|
||||
*
|
||||
* Some grants, such as the authorization code grant can respond to multiple requests
|
||||
* - i.e. a client requesting an authorization code and requesting an access token
|
||||
*
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRespondToRequest(ServerRequestInterface $request)
|
||||
{
|
||||
if (
|
||||
isset($request->getParsedBody()['grant_type'])
|
||||
&& $request->getParsedBody()['grant_type'] === 'client_credentials'
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,9 @@
|
||||
namespace League\OAuth2\Server\Grant;
|
||||
|
||||
use DateInterval;
|
||||
use League\Event\Emitter;
|
||||
use League\OAuth2\Server\TokenTypes\TokenTypeInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
/**
|
||||
* Grant type interface
|
||||
@ -37,17 +38,38 @@ interface GrantTypeInterface
|
||||
/**
|
||||
* Return an access token
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
||||
* @param \League\OAuth2\Server\TokenTypes\TokenTypeInterface $tokenType
|
||||
* @param \DateInterval $accessTokenTTL
|
||||
* @param string $scopeDelimiter
|
||||
*
|
||||
* @return \League\OAuth2\Server\TokenTypes\TokenTypeInterface
|
||||
*/
|
||||
public function getAccessTokenAsType(
|
||||
Request $request,
|
||||
public function respondToRequest(
|
||||
ServerRequestInterface $request,
|
||||
TokenTypeInterface $tokenType,
|
||||
DateInterval $accessTokenTTL,
|
||||
$scopeDelimiter = ' '
|
||||
);
|
||||
|
||||
/**
|
||||
* The grant type should return true if it is able to respond to this request.
|
||||
*
|
||||
* For example most grant types will check that the $_POST['grant_type'] property matches it's identifier property.
|
||||
*
|
||||
* Some grants, such as the authorization code grant can respond to multiple requests
|
||||
* - i.e. a client requesting an authorization code and requesting an access token
|
||||
*
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRespondToRequest(ServerRequestInterface $request);
|
||||
|
||||
/**
|
||||
* Set the event emitter
|
||||
*
|
||||
* @param \League\Event\Emitter $emitter
|
||||
*/
|
||||
public function setEmitter(Emitter $emitter);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use League\OAuth2\Server\Exception;
|
||||
use League\OAuth2\Server\Util\SecureKey;
|
||||
|
||||
/**
|
||||
* Referesh token grant
|
||||
* Refresh token grant
|
||||
*/
|
||||
class RefreshTokenGrant extends AbstractGrant
|
||||
{
|
||||
|
@ -1,154 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* OAuth 2.0 Resource Server
|
||||
*
|
||||
* @package league/oauth2-server
|
||||
* @author Alex Bilbie <hello@alexbilbie.com>
|
||||
* @copyright Copyright (c) Alex Bilbie
|
||||
* @license http://mit-license.org/
|
||||
* @link https://github.com/thephpleague/oauth2-server
|
||||
*/
|
||||
|
||||
namespace League\OAuth2\Server;
|
||||
|
||||
use League\OAuth2\Server\Entity\AccessTokenEntity;
|
||||
use League\OAuth2\Server\Exception\AccessDeniedException;
|
||||
use League\OAuth2\Server\Exception\InvalidRequestException;
|
||||
use League\OAuth2\Server\Storage\AccessTokenInterface;
|
||||
use League\OAuth2\Server\Storage\ClientInterface;
|
||||
use League\OAuth2\Server\Storage\ScopeInterface;
|
||||
use League\OAuth2\Server\Storage\SessionInterface;
|
||||
use League\OAuth2\Server\TokenType\Bearer;
|
||||
|
||||
/**
|
||||
* OAuth 2.0 Resource Server
|
||||
*/
|
||||
class ResourceServer extends AbstractServer
|
||||
{
|
||||
/**
|
||||
* The access token
|
||||
*
|
||||
* @var \League\OAuth2\Server\Entity\AccessTokenEntity
|
||||
*/
|
||||
protected $accessToken;
|
||||
|
||||
/**
|
||||
* The query string key which is used by clients to present the access token (default: access_token)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $tokenKey = 'access_token';
|
||||
|
||||
/**
|
||||
* Initialise the resource server
|
||||
*
|
||||
* @param \League\OAuth2\Server\Storage\SessionInterface $sessionStorage
|
||||
* @param \League\OAuth2\Server\Storage\AccessTokenInterface $accessTokenStorage
|
||||
* @param \League\OAuth2\Server\Storage\ClientInterface $clientStorage
|
||||
* @param \League\OAuth2\Server\Storage\ScopeInterface $scopeStorage
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function __construct(
|
||||
SessionInterface $sessionStorage,
|
||||
AccessTokenInterface $accessTokenStorage,
|
||||
ClientInterface $clientStorage,
|
||||
ScopeInterface $scopeStorage
|
||||
) {
|
||||
$this->setSessionStorage($sessionStorage);
|
||||
$this->setAccessTokenStorage($accessTokenStorage);
|
||||
$this->setClientStorage($clientStorage);
|
||||
$this->setScopeStorage($scopeStorage);
|
||||
|
||||
// Set Bearer as the default token type
|
||||
$this->setTokenType(new Bearer());
|
||||
|
||||
parent::__construct();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the query string key for the access token.
|
||||
*
|
||||
* @param string $key The new query string key
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setIdKey($key)
|
||||
{
|
||||
$this->tokenKey = $key;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the access token
|
||||
*
|
||||
* @return \League\OAuth2\Server\Entity\AccessTokenEntity
|
||||
*/
|
||||
public function getAccessToken()
|
||||
{
|
||||
return $this->accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the access token is valid or not
|
||||
*
|
||||
* @param bool $headerOnly Limit Access Token to Authorization header
|
||||
* @param \League\OAuth2\Server\Entity\AccessTokenEntity|null $accessToken Access Token
|
||||
*
|
||||
* @throws \League\OAuth2\Server\Exception\AccessDeniedException
|
||||
* @throws \League\OAuth2\Server\Exception\InvalidRequestException
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidRequest($headerOnly = true, $accessToken = null)
|
||||
{
|
||||
$accessTokenString = ($accessToken !== null)
|
||||
? $accessToken
|
||||
: $this->determineAccessToken($headerOnly);
|
||||
|
||||
// Set the access token
|
||||
$this->accessToken = $this->getAccessTokenStorage()->get($accessTokenString);
|
||||
|
||||
// Ensure the access token exists
|
||||
if (!$this->accessToken instanceof AccessTokenEntity) {
|
||||
throw new AccessDeniedException();
|
||||
}
|
||||
|
||||
// Check the access token hasn't expired
|
||||
// Ensure the auth code hasn't expired
|
||||
if ($this->accessToken->isExpired() === true) {
|
||||
throw new AccessDeniedException();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads in the access token from the headers
|
||||
*
|
||||
* @param bool $headerOnly Limit Access Token to Authorization header
|
||||
*
|
||||
* @throws \League\OAuth2\Server\Exception\InvalidRequestException Thrown if there is no access token presented
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function determineAccessToken($headerOnly = false)
|
||||
{
|
||||
if ($this->getRequest()->headers->get('Authorization') !== null) {
|
||||
$accessToken = $this->getTokenType()->determineAccessTokenInHeader($this->getRequest());
|
||||
} elseif ($headerOnly === false) {
|
||||
$accessToken = ($this->getRequest()->server->get('REQUEST_METHOD') === 'GET')
|
||||
? $this->getRequest()->query->get($this->tokenKey)
|
||||
: $this->getRequest()->request->get($this->tokenKey);
|
||||
}
|
||||
|
||||
if (empty($accessToken)) {
|
||||
throw new InvalidRequestException('access token');
|
||||
}
|
||||
|
||||
return $accessToken;
|
||||
}
|
||||
}
|
127
src/Server.php
127
src/Server.php
@ -3,12 +3,24 @@
|
||||
namespace League\OAuth2\Server;
|
||||
|
||||
use DateInterval;
|
||||
use League\Event\EmitterAwareInterface;
|
||||
use League\Event\EmitterAwareTrait;
|
||||
use League\OAuth2\Server\Grant\GrantTypeInterface;
|
||||
//use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
||||
//use League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface;
|
||||
//use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
|
||||
use League\OAuth2\Server\Repositories\RepositoryInterface;
|
||||
//use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
|
||||
//use League\OAuth2\Server\Repositories\UserRepositoryInterface;
|
||||
use League\OAuth2\Server\TokenTypes\BearerTokenType;
|
||||
use League\OAuth2\Server\TokenTypes\TokenTypeInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Zend\Diactoros\ServerRequestFactory;
|
||||
|
||||
class Server extends AbstractServer
|
||||
class Server implements EmitterAwareInterface
|
||||
{
|
||||
use EmitterAwareTrait;
|
||||
|
||||
/**
|
||||
* @var \League\OAuth2\Server\Grant\GrantTypeInterface[]
|
||||
*/
|
||||
@ -37,16 +49,20 @@ class Server extends AbstractServer
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $scopeDelimiter = ' ';
|
||||
protected $scopeDelimiterString = ' ';
|
||||
|
||||
/**
|
||||
* @var RepositoryInterface[]
|
||||
*/
|
||||
// protected $repositories = [];
|
||||
|
||||
/**
|
||||
* New server instance
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->defaultTokenType = new BearerTokenType();
|
||||
$this->defaultAccessTokenTTL = new DateInterval('PT01H'); // default of 1 hour
|
||||
|
||||
parent::__construct();
|
||||
public function __construct()
|
||||
{
|
||||
$this->setDefaultTokenType(new BearerTokenType());
|
||||
$this->setDefaultAccessTokenTTL(new DateInterval('PT01H')); // default of 1 hour
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,13 +76,13 @@ class Server extends AbstractServer
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the delimiter used to separate scopes in a request
|
||||
* Set the delimiter string used to separate scopes in a request
|
||||
*
|
||||
* @param string $scopeDelimiter
|
||||
* @param string $scopeDelimiterString
|
||||
*/
|
||||
public function setScopeDelimiter($scopeDelimiter)
|
||||
public function setScopeDelimiterString($scopeDelimiterString)
|
||||
{
|
||||
$this->scopeDelimiter = $scopeDelimiter;
|
||||
$this->scopeDelimiterString = $scopeDelimiterString;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,68 +96,89 @@ class Server extends AbstractServer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $grantType
|
||||
* @param TokenTypeInterface $tokenType
|
||||
* @param DateInterval $accessTokenTTL
|
||||
* Enable a grant type on the server
|
||||
*
|
||||
* @throws \Exception
|
||||
* @param \League\OAuth2\Server\Grant\GrantTypeInterface $grantType
|
||||
* @param TokenTypeInterface $tokenType
|
||||
* @param DateInterval $accessTokenTTL
|
||||
*/
|
||||
public function enableGrantType(
|
||||
$grantType,
|
||||
GrantTypeInterface $grantType,
|
||||
TokenTypeInterface $tokenType = null,
|
||||
DateInterval $accessTokenTTL = null
|
||||
) {
|
||||
if ($this->getContainer()->isInServiceProvider($grantType)) {
|
||||
$grant = $this->getContainer()->get($grantType);
|
||||
$grantIdentifier = $grant->getIdentifier();
|
||||
$this->enabledGrantTypes[$grantIdentifier] = $grant;
|
||||
} else {
|
||||
throw new \Exception('Unregistered grant type'); // @TODO fix
|
||||
}
|
||||
$grantType->setEmitter($this->getEmitter());
|
||||
$this->enabledGrantTypes[$grantType->getIdentifier()] = $grantType;
|
||||
|
||||
// Set grant response type
|
||||
if ($tokenType instanceof TokenTypeInterface) {
|
||||
$this->grantTypeTokenTypes[$grantIdentifier] = $tokenType;
|
||||
$this->grantTypeTokenTypes[$grantType->getIdentifier()] = $tokenType;
|
||||
} else {
|
||||
$this->grantTypeTokenTypes[$grantIdentifier] = $this->defaultTokenType;
|
||||
$this->grantTypeTokenTypes[$grantType->getIdentifier()] = $this->defaultTokenType;
|
||||
}
|
||||
|
||||
// Set grant access token TTL
|
||||
if ($accessTokenTTL instanceof DateInterval) {
|
||||
$this->grantTypeAccessTokenTTL[$grantIdentifier] = $accessTokenTTL;
|
||||
$this->grantTypeAccessTokenTTL[$grantType->getIdentifier()] = $accessTokenTTL;
|
||||
} else {
|
||||
$this->grantTypeAccessTokenTTL[$grantIdentifier] = $this->defaultAccessTokenTTL;
|
||||
$this->grantTypeAccessTokenTTL[$grantType->getIdentifier()] = $this->defaultAccessTokenTTL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an access token response
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
||||
*
|
||||
* @return TokenTypeInterface
|
||||
* @throws \Exception
|
||||
* @return \League\OAuth2\Server\TokenTypes\TokenTypeInterface
|
||||
* @throws \League\OAuth2\Server\Exception\InvalidGrantException
|
||||
*/
|
||||
public function getAccessTokenResponse(Request $request = null)
|
||||
public function respondToRequest(ServerRequestInterface $request = null)
|
||||
{
|
||||
if ($request === null) {
|
||||
$request = Request::createFromGlobals();
|
||||
$request = ServerRequestFactory::fromGlobals();
|
||||
}
|
||||
|
||||
// Run the requested grant type
|
||||
$grantType = $request->request->get('grant_type', null);
|
||||
|
||||
if ($grantType === null || isset($this->enabledGrantTypes[$grantType]) === false) {
|
||||
throw new Exception\InvalidGrantException($grantType);
|
||||
$response = null;
|
||||
foreach ($this->enabledGrantTypes as $grantType) {
|
||||
if ($grantType->canRespondToRequest($request)) {
|
||||
$response = $grantType->respondToRequest(
|
||||
$request,
|
||||
$this->grantTypeTokenTypes[$grantType->getIdentifier()],
|
||||
$this->grantTypeAccessTokenTTL[$grantType->getIdentifier()],
|
||||
$this->scopeDelimiterString
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$tokenType = $this->enabledGrantTypes[$grantType]->getAccessTokenAsType(
|
||||
$request,
|
||||
$this->grantTypeTokenTypes[$grantType],
|
||||
$this->grantTypeAccessTokenTTL[$grantType],
|
||||
$this->scopeDelimiter
|
||||
);
|
||||
if ($response === null) {
|
||||
// do something here
|
||||
}
|
||||
|
||||
return $tokenType->generateHttpResponse();
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \League\OAuth2\Server\Repositories\RepositoryInterface $repository
|
||||
*/
|
||||
/*public function addRepository(RepositoryInterface $repository)
|
||||
{
|
||||
switch ($repository) {
|
||||
case ($repository instanceof AccessTokenRepositoryInterface):
|
||||
$this->repositories[AccessTokenRepositoryInterface::class] = $repository;
|
||||
break;
|
||||
case ($repository instanceof ClientRepositoryInterface):
|
||||
$this->repositories[ClientRepositoryInterface::class] = $repository;
|
||||
break;
|
||||
case ($repository instanceof ScopeRepositoryInterface):
|
||||
$this->repositories[ScopeRepositoryInterface::class] = $repository;
|
||||
break;
|
||||
case ($repository instanceof UserRepositoryInterface):
|
||||
$this->repositories[UserRepositoryInterface::class] = $repository;
|
||||
break;
|
||||
case ($repository instanceof AuthCodeRepositoryInterface):
|
||||
$this->repositories[AuthCodeRepositoryInterface::class] = $repository;
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@ -11,7 +11,8 @@
|
||||
|
||||
namespace League\OAuth2\Server\TokenTypes;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Zend\Diactoros\Response;
|
||||
|
||||
class BearerTokenType extends AbstractTokenType
|
||||
{
|
||||
@ -20,25 +21,36 @@ class BearerTokenType extends AbstractTokenType
|
||||
*/
|
||||
public function generateResponse()
|
||||
{
|
||||
$return = [
|
||||
$values = [
|
||||
'access_token' => $this->accessToken->getIdentifier(),
|
||||
'token_type' => 'Bearer',
|
||||
'expires_in' => $this->accessToken->getExpiryDateTime()->getTimestamp() - (new \DateTime())->getTimestamp()
|
||||
];
|
||||
|
||||
if (!is_null($this->getParam('refresh_token'))) {
|
||||
$return['refresh_token'] = $this->getParam('refresh_token');
|
||||
$values['refresh_token'] = $this->getParam('refresh_token');
|
||||
}
|
||||
|
||||
return $return;
|
||||
$response = new Response(
|
||||
'php://memory',
|
||||
200,
|
||||
[
|
||||
'pragma' => 'no-cache',
|
||||
'cache-control' => 'no-store',
|
||||
'content-type' => 'application/json;charset=UTF-8'
|
||||
]
|
||||
);
|
||||
$response->getBody()->write(json_encode($values));
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function determineAccessTokenInHeader(Request $request)
|
||||
public function determineAccessTokenInHeader(ServerRequestInterface $request)
|
||||
{
|
||||
$header = $request->headers->get('Authorization');
|
||||
$header = $request->getHeader('authorization');
|
||||
$accessToken = trim(preg_replace('/^(?:\s+)?Bearer\s/', '', $header));
|
||||
|
||||
// ^(?:\s+)?Bearer\s([a-zA-Z0-9-._~+/=]*)
|
||||
|
@ -12,14 +12,15 @@
|
||||
namespace League\OAuth2\Server\TokenTypes;
|
||||
|
||||
use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
interface TokenTypeInterface
|
||||
{
|
||||
/**
|
||||
* Generate a response
|
||||
*
|
||||
* @return array
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function generateResponse();
|
||||
|
||||
@ -48,14 +49,14 @@ interface TokenTypeInterface
|
||||
/**
|
||||
* Determine the access token in the authorization header
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function determineAccessTokenInHeader(Request $request);
|
||||
public function determineAccessTokenInHeader(ServerRequestInterface $request);
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function generateHttpResponse();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user