forked from tuupola/slim-jwt-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d7b5c17
Showing
12 changed files
with
2,380 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.php] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.travis.yml export-ignore | ||
/.editorconfig export-ignore | ||
/phpunit.xml export-ignore | ||
/tests export-ignore | ||
/Gruntfile.js export-ignore | ||
/package.json export-ignore | ||
/phpunit.xml export-ignore | ||
/README.md export-ignore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/node_modules/ | ||
/vendor/ | ||
/report/ | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Contributing | ||
|
||
Contributions are **welcome** and will be fully **credited**. | ||
|
||
We accept contributions via Pull Requests on [Github](https://github.com/tuupola/slim-jwt-auth). | ||
|
||
|
||
## Pull Requests | ||
|
||
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). | ||
|
||
- **Add tests!** - Your patch won't be accepted if it doesn't have tests. | ||
|
||
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. | ||
|
||
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. | ||
|
||
- **Create feature branches** - Don't ask us to pull from your master branch. | ||
|
||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. | ||
|
||
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting. | ||
|
||
|
||
## Running Tests | ||
|
||
``` bash | ||
$ phpunit | ||
``` | ||
|
||
|
||
**Happy coding**! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module.exports = function(grunt) { | ||
"use strict"; | ||
|
||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON("package.json"), | ||
watch: { | ||
php: { | ||
files: ["src/**/*.php", "tests/**/*.php"], | ||
tasks: ["testphp"] | ||
} | ||
}, | ||
phpunit: { | ||
unit: { | ||
dir: "tests" | ||
}, | ||
options: { | ||
bin: "vendor/bin/phpunit --bootstrap=vendor/autoload.php --coverage-text --coverage-html ./report", | ||
colors: true, | ||
testdox: false | ||
} | ||
}, | ||
phplint: { | ||
options: { | ||
swapPath: "/tmp" | ||
}, | ||
all: ["src/**/*.php", "tests/**/*.php"] | ||
}, | ||
phpcs: { | ||
application: { | ||
src: ["src/**/*.php", "tests/**/*.php"] | ||
}, | ||
options: { | ||
bin: "vendor/bin/phpcs", | ||
standard: "PSR2" | ||
} | ||
} | ||
}); | ||
|
||
require("load-grunt-tasks")(grunt); | ||
|
||
grunt.registerTask("testphp", ["phplint", "phpcs", "phpunit"]); | ||
grunt.registerTask("default", ["testphp"]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Mika Tuupola <[email protected]> | ||
|
||
> 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# JWT Authentication Middleware for Slim | ||
|
||
[](https://github.com/tuupola/slim-jwt-auth/releases) | ||
[](LICENSE.md) | ||
[](https://travis-ci.org/tuupola/slim-jwt-auth) | ||
[](http://hhvm.h4cc.de/package/tuupola/slim-jwt-auth) | ||
[](https://codecov.io/github/tuupola/slim-jwt-auth) | ||
[](https://packagist.org/packages/tuupola/slim-jwt-auth) | ||
|
||
This middleware implements JSON Web Token Authentication for Slim Framework. It does **not** implement OAuth 2.0 authorization server nor does it provide ways to generate, issue or store authentication tokens. It only parses and authenticates a token when passed via header, cookie or querystring. This is useful when you want to use [JSON Web Tokens as API keys](https://auth0.com/blog/2014/12/02/using-json-web-tokens-as-api-keys/). | ||
|
||
## Install | ||
|
||
You can install latest version using [composer](https://getcomposer.org/). | ||
|
||
``` bash | ||
$ composer require tuupola/slim-jwt-auth | ||
``` | ||
|
||
## Usage | ||
|
||
``` php | ||
$app = new \Slim\Slim(); | ||
$app->add(new \Slim\Middleware\JwtAuthentication([ | ||
"secret" => "supersecretkeyyoushouldnotcommittogithub" | ||
])); | ||
|
||
$app->get("/hello", function () use ($app) { | ||
print_r($app->jwt->data()); | ||
}); | ||
``` | ||
|
||
## Testing | ||
|
||
``` bash | ||
$ phpunit | ||
``` | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details. | ||
|
||
## Security | ||
|
||
If you discover any security related issues, please email [email protected] instead of using the issue tracker. | ||
|
||
## Credits | ||
|
||
- [Mika Tuupola](https://github.com/tuupola) | ||
- [All Contributors](../../contributors) | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "tuupola/slim-jwt-auth", | ||
"description": "JSON Web Token Authorization Middleware for Slim Framework", | ||
"keywords": [ | ||
"slim", | ||
"middleware", | ||
"jwt", | ||
"json", | ||
"auth" | ||
], | ||
"homepage": "https://github.com/tuupola/slim-jwt-auth", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Mika Tuupola", | ||
"email": "[email protected]", | ||
"homepage": "http://www.appelsiini.net/", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php" : ">=5.3.0", | ||
"firebase/php-jwt": "~2.0", | ||
"slim/slim": "~2.3" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit" : "~4.6", | ||
"squizlabs/php_codesniffer": "~2.3" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Slim\\Middleware\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Slim\\Middleware\\Test\\": "tests" | ||
} | ||
} | ||
} |
Oops, something went wrong.