Skip to content

Commit b6b63dc

Browse files
committed
BearerAuthorization based on TokenAuthorization
0 parents  commit b6b63dc

17 files changed

+2503
-0
lines changed

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 4
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
10+
[*.json]
11+
indent_size = 2
12+
13+
[Makefile]
14+
indent_style = tab

.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Ignoring files for distribution archieves
2+
examples/ export-ignore
3+
tests/ export-ignore
4+
.travis.yml export-ignore
5+
.gitignore export-ignore
6+
.gitattributes export-ignore
7+
.scrutinizer.yml export-ignore
8+
phpunit.xml.dist export-ignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor/

.scrutinizer.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
filter:
2+
paths: [src/*]
3+
excluded_paths: [examples/*, tests/*]
4+
tools:
5+
external_code_coverage: true
6+
php_analyzer: true
7+
php_hhvm: true
8+
php_sim: true
9+
php_pdepend: true
10+
sensiolabs_security_checker: true
11+
php_changetracking: true
12+
php_code_sniffer:
13+
enabled: true
14+
config:
15+
tab_width: 0
16+
encoding: utf8
17+
ruleset: ~
18+
standard: "PSR2"
19+
php_cs_fixer:
20+
enabled: true
21+
config:
22+
level: psr2
23+
php_mess_detector:
24+
enabled: true
25+
config:
26+
ruleset: ~
27+
code_size_rules:
28+
cyclomatic_complexity: true
29+
npath_complexity: true
30+
excessive_method_length: true
31+
excessive_class_length: true
32+
excessive_parameter_list: true
33+
excessive_public_count: true
34+
too_many_fields: true
35+
too_many_methods: true
36+
excessive_class_complexity: true
37+
design_rules:
38+
exit_expression: true
39+
eval_expression: true
40+
goto_statement: true
41+
number_of_class_children: true
42+
depth_of_inheritance: true
43+
coupling_between_objects: true
44+
unused_code_rules:
45+
unused_private_field: true
46+
unused_local_variable: true
47+
unused_private_method: true
48+
unused_formal_parameter: true
49+
naming_rules:
50+
short_variable:
51+
minimum: 3
52+
long_variable:
53+
maximum: 20
54+
short_method:
55+
minimum: 3
56+
constructor_conflict: true
57+
constant_naming: true
58+
boolean_method_name: true
59+
controversial_rules:
60+
superglobals: true
61+
camel_case_class_name: true
62+
camel_case_property_name: true
63+
camel_case_method_name: true
64+
camel_case_parameter_name: true
65+
camel_case_variable_name: true
66+
checks:
67+
php:
68+
code_rating: true

.stickler.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
linters:
2+
phpcs:
3+
standard: 'PSR2'
4+
extensions: '.php'
5+
tab_width: 4

.travis.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
language: php
2+
sudo: false
3+
4+
## Cache composer bits
5+
cache:
6+
directories:
7+
- $HOME/.composer/cache
8+
9+
## PHP versions we test against
10+
php:
11+
- 7.0
12+
- 7.1
13+
- nightly
14+
15+
## Environment variables
16+
env:
17+
- coverage=true
18+
19+
## Build matrix for lowest and highest possible targets
20+
matrix:
21+
include:
22+
- php: 7.0
23+
env:
24+
- dependencies=lowest
25+
- coverage=false
26+
- php: 7.1
27+
env:
28+
- dependencies=lowest
29+
- coverage=false
30+
- php: nightly
31+
env:
32+
- dependencies=lowest
33+
- coverage=false
34+
- php: 7.0
35+
env:
36+
- dependencies=highest
37+
- coverage=false
38+
- php: 7.1
39+
env:
40+
- dependencies=highest
41+
- coverage=false
42+
- php: nightly
43+
env:
44+
- dependencies=highest
45+
- coverage=false
46+
47+
## Install or update dependencies
48+
install:
49+
- composer validate
50+
- if [ "$coverage" = "false" ]; then phpenv config-rm xdebug.ini || :; fi;
51+
- if [ -z "$dependencies" ]; then composer install --prefer-dist; fi;
52+
- if [ "$dependencies" = "lowest" ]; then composer update --prefer-lowest --prefer-dist -n; fi;
53+
- if [ "$dependencies" = "highest" ]; then composer update --prefer-dist -n; fi;
54+
- composer show
55+
56+
## Run the actual test
57+
script:
58+
- if [ "$coverage" = "false" ]; then make ci; fi;
59+
- if [ "$coverage" = "true" ]; then make ci-with-coverage; fi;
60+
61+
## Gather coverage and set it to coverage servers
62+
after_script: make ci-coverage

CONTRIBUTING.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Contributing
2+
3+
Pull requests are highly appreciated. Here's a quick guide.
4+
5+
Fork, then clone the repo:
6+
7+
git clone [email protected]:your-username/middleware-bearer-authorization.git
8+
9+
Set up your machine:
10+
11+
composer install
12+
13+
Make sure the tests pass:
14+
15+
make unit
16+
17+
Make sure the tests pass on all supported PHP versions (requires docker):
18+
19+
make dunit
20+
21+
Make your change. Add tests for your change. Make the tests pass:
22+
23+
make dunit && make unit
24+
25+
Before committing and submitting your pull request make sure it passes PSR2 coding style, unit tests pass and pass on all supported PHP versions:
26+
27+
make contrib
28+
29+
Push to your fork and [submit a pull request][pr].
30+
31+
[pr]: https://help.github.com/articles/creating-a-pull-request/
32+
33+
At this point you're waiting on me. I like to at least comment on pull requests
34+
within a day or two. I may suggest some changes or improvements or alternatives.
35+
36+
Some things that will increase the chance that your pull request is accepted:
37+
38+
* Write tests.
39+
* Follow PSR2 (travis will also check for this).
40+
* Write a [good commit message][commit].
41+
42+
[commit]: http://chris.beams.io/posts/git-commit/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Cees-Jan Kiewiet
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
all:
2+
composer run-script qa-all --timeout=0
3+
4+
all-coverage:
5+
composer run-script qa-all-coverage --timeout=0
6+
7+
ci:
8+
composer run-script qa-ci --timeout=0
9+
10+
ci-with-coverage:
11+
composer run-script qa-ci-coverage --timeout=0
12+
13+
contrib:
14+
composer run-script qa-contrib --timeout=0
15+
16+
init:
17+
composer ensure-installed
18+
19+
cs:
20+
composer cs
21+
22+
unit:
23+
composer run-script unit --timeout=0
24+
25+
unit-coverage:
26+
composer run-script unit-coverage --timeout=0
27+
28+
ci-coverage: init
29+
composer ci-coverage

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Bearer authorization middleware
2+
3+
[![Build Status](https://travis-ci.org/php-api-clients/middleware-bearer-authorization.svg?branch=master)](https://travis-ci.org/php-api-clients/middleware-bearer-authorization)
4+
[![Latest Stable Version](https://poser.pugx.org/api-clients/middleware-bearer-authorization/v/stable.png)](https://packagist.org/packages/api-clients/middleware-bearer-authorization)
5+
[![Total Downloads](https://poser.pugx.org/api-clients/middleware-bearer-authorization/downloads.png)](https://packagist.org/packages/api-clients/middleware-bearer-authorization)
6+
[![Code Coverage](https://scrutinizer-ci.com/g/php-api-clients/middleware-bearer-authorization/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/php-api-clients/middleware-bearer-authorization/?branch=master)
7+
[![License](https://poser.pugx.org/api-clients/middleware-bearer-authorization/license.png)](https://packagist.org/packages/api-clients/middleware-bearer-authorization)
8+
[![PHP 7 ready](http://php7ready.timesplinter.ch/php-api-clients/middleware-bearer-authorization/badge.svg)](https://travis-ci.org/php-api-clients/middleware-bearer-authorization)
9+
10+
# Installation
11+
12+
To install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `^`.
13+
14+
```
15+
composer require api-clients/middleware-bearer-authorization
16+
```
17+
# Usage
18+
19+
[See the transport package how to use this middleware.](https://github.com/php-api-clients/transport#middleware)
20+
21+
# License
22+
23+
The MIT License (MIT)
24+
25+
Copyright (c) 2017 Cees-Jan Kiewiet
26+
27+
Permission is hereby granted, free of charge, to any person obtaining a copy
28+
of this software and associated documentation files (the "Software"), to deal
29+
in the Software without restriction, including without limitation the rights
30+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
31+
copies of the Software, and to permit persons to whom the Software is
32+
furnished to do so, subject to the following conditions:
33+
34+
The above copyright notice and this permission notice shall be included in all
35+
copies or substantial portions of the Software.
36+
37+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
42+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
43+
SOFTWARE.

appveyor.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
build: false
2+
platform:
3+
- x64
4+
clone_folder: c:\projects\php-project-workspace
5+
6+
## Build matrix for lowest and highest possible targets
7+
environment:
8+
matrix:
9+
- dependencies: lowest
10+
php_ver_target: 7.0
11+
- dependencies: lowest
12+
php_ver_target: 7.1
13+
- dependencies: current
14+
php_ver_target: 7.0
15+
- dependencies: current
16+
php_ver_target: 7.1
17+
- dependencies: highest
18+
php_ver_target: 7.0
19+
- dependencies: highest
20+
php_ver_target: 7.1
21+
22+
## Cache composer bits
23+
cache:
24+
- '%LOCALAPPDATA%\Composer\files -> composer.lock'
25+
26+
## Set up environment varriables
27+
init:
28+
- SET PATH=C:\Program Files\OpenSSL;c:\tools\php;%PATH%
29+
- SET COMPOSER_NO_INTERACTION=1
30+
- SET PHP=1
31+
- SET ANSICON=121x90 (121x90)
32+
33+
## Install PHP and composer, and run the appropriate composer command
34+
install:
35+
- IF EXIST c:\tools\php (SET PHP=0)
36+
- ps: appveyor-retry cinst -y php --ignore-checksums --version ((choco search php --exact --all-versions -r | select-string -pattern $Env:php_ver_target | Select-Object -first 1) -replace '[php|]','')
37+
- cd c:\tools\php
38+
- IF %PHP%==1 copy php.ini-production php.ini /Y
39+
- IF %PHP%==1 echo date.timezone="UTC" >> php.ini
40+
- IF %PHP%==1 echo extension_dir=ext >> php.ini
41+
- IF %PHP%==1 echo extension=php_openssl.dll >> php.ini
42+
- IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini
43+
- IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini
44+
- IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat
45+
- appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar
46+
- cd c:\projects\php-project-workspace
47+
- IF %dependencies%==lowest appveyor-retry composer update --prefer-lowest --no-progress --profile -n
48+
- IF %dependencies%==current appveyor-retry composer install --no-progress --profile
49+
- IF %dependencies%==highest appveyor-retry composer update --no-progress --profile -n
50+
- composer show
51+
52+
## Run the actual test
53+
test_script:
54+
- cd c:\projects\php-project-workspace
55+
- vendor/bin/phpunit -c phpunit.xml.dist

0 commit comments

Comments
 (0)