Skip to content

Commit

Permalink
Merge pull request #5 from auth0/api_v2
Browse files Browse the repository at this point in the history
Api v2 + SDK 1.0 support
  • Loading branch information
glena committed May 8, 2015
2 parents a20c6cd + 9f58d0c commit fe16410
Show file tree
Hide file tree
Showing 27 changed files with 2,271 additions and 1,108 deletions.
Binary file added .DS_Store
Binary file not shown.
49 changes: 36 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@ JWT Authentication bundle for Symphony

Check the usage demo: https://github.com/auth0/jwt-auth-bundle/tree/master/example

##News

###Version 1.2 release

- PSR-4 compliance
- Support for API v2 & auth0-php 1.0

#### BC breaks

- Config
- package name space changed to `jwt_auth`
- `domain` is no longer needed
- added optional `secret_base64_encoded` field
- Removed dependency with Auth0. Now you can use non base64 tokens.
- The profile data is not longer a `stdClass`, is an asociative array.
- There are some BC issues related to the auth0-php changes. We recomment to read the [auth0-php README](https://github.com/auth0/Auth0-PHP).

#### Auth0 integration

This package has built in Auth0 integration (as you can check on the example) but is not mandatory. You can use this package to authenticate other JWT.

The auth-php SDK is used to decode the JWT and if you are woking with Auth0 you can inject to your `UserProvider` to get the user profile (as you can check on the [example](https://github.com/auth0/jwt-auth-bundle/blob/master/example/src/AppBundle/Security/A0UserProvider.php)).

##Usage

###1. Install dependencies
Expand All @@ -20,7 +43,7 @@ Modify your `composer.json` to add the following dependencies and run `composer
"require": {
"firebase/php-jwt": "dev-master",
"adoy/oauth2": "dev-master",
"auth0/jwt-auth-bundle": "1.0.0"
"auth0/jwt-auth-bundle": "~1.1"
}
}
~~~
Expand All @@ -34,31 +57,31 @@ class AppKernel extends Kernel
public function registerBundles()
{
$bundles = array(

...
new \Auth0\JWTAuthBundle\Auth0JWTAuthBundle(),

new \Auth0\JWTAuthBundle\JWTAuthBundle(),

...

);

...

return $bundles;
}

~~~

###3. Configure your Auth0 app data

Modify the file /app/config/config.yml

~~~yml
auth0_jwt_auth:
domain: yourdomain.auth0.com
jwt-auth-bundle:
client_id: YOURCLIENTID
client_secret: YOURCLIENTSECRET
secret_base64_encoded: (optional) TRUE if the secret is base64 encoded (true by default as the Auth0 secret)
~~~

###4. Setup your User and UserProvider
Expand All @@ -76,7 +99,7 @@ The configure your services on /app/config/services.yml
services:
a0_user_provider:
class: AppBundle\Security\A0UserProvider
arguments: ["@auth0_jwt_auth.auth0_service"]
arguments: ["@jwt_auth.auth0_service"]
~~~

###5. Setup the SecurityProvider
Expand All @@ -99,7 +122,7 @@ security:
pattern: ^/api
stateless: true
simple_preauth:
authenticator: auth0_jwt_aut.jwt_authenticator
authenticator: jwt_auth.jwt_authenticator

access_control:
- { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
Expand Down
8 changes: 0 additions & 8 deletions Resources/config/services.yml

This file was deleted.

89 changes: 0 additions & 89 deletions Security/Auth0Service.php

This file was deleted.

11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"require": {
"php": ">=5.3.3",
"firebase/php-jwt": "dev-master",
"adoy/oauth2": "dev-master"
"adoy/oauth2": "dev-master",
"auth0/auth0-php": "~1.0"
},

"require-dev": {
Expand All @@ -32,10 +33,8 @@
},

"autoload": {
"psr-0": {
"Auth0\\JWTAuthBundle\\": ""
"psr-4": {
"Auth0\\JWTAuthBundle\\": "src/"
}
},

"target-dir": "Auth0/JWTAuthBundle"
}
}
Loading

0 comments on commit fe16410

Please sign in to comment.