Skip to content

Commit

Permalink
First working concept
Browse files Browse the repository at this point in the history
  • Loading branch information
tuupola committed Apr 11, 2015
0 parents commit d7b5c17
Show file tree
Hide file tree
Showing 12 changed files with 2,380 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
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
11 changes: 11 additions & 0 deletions .gitattributes
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

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/node_modules/
/vendor/
/report/
composer.lock
32 changes: 32 additions & 0 deletions CONTRIBUTING.md
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**!
43 changes: 43 additions & 0 deletions Gruntfile.js
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"]);
};
21 changes: 21 additions & 0 deletions LICENSE.md
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.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# JWT Authentication Middleware for Slim

[![Latest Version](https://img.shields.io/github/release/tuupola/slim-jwt-auth.svg?style=flat-square)](https://github.com/tuupola/slim-jwt-auth/releases)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Build Status](https://img.shields.io/travis/tuupola/slim-jwt-auth/master.svg?style=flat-square)](https://travis-ci.org/tuupola/slim-jwt-auth)
[![HHVM Status](https://img.shields.io/hhvm/tuupola/slim-jwt-auth.svg?style=flat-square)](http://hhvm.h4cc.de/package/tuupola/slim-jwt-auth)
[![Coverage](http://img.shields.io/codecov/c/github/tuupola/slim-jwt-auth.svg?style=flat-square)](https://codecov.io/github/tuupola/slim-jwt-auth)
[![Total Downloads](https://img.shields.io/packagist/dt/tuupola/slim-jwt-auth.svg?style=flat-square)](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.
40 changes: 40 additions & 0 deletions composer.json
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"
}
}
}
Loading

0 comments on commit d7b5c17

Please sign in to comment.