Skip to content

Commit 47f6296

Browse files
authored
Merge pull request #5 from mctekk/master
Fix Syntax
2 parents fd54399 + 5e6f845 commit 47f6296

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
A simple JWT middleware for Phalcon Micro to handle stateless authentication.
44

55
## Installation
6-
```
6+
```bash
77
composer require dmkit/phalcon-jwt-auth
88
```
99
or in your composer.json
10-
```
10+
```json
1111
{
1212
"require": {
1313
"dmkit/phalcon-jwt-auth" : "dev-master"
@@ -16,7 +16,7 @@ or in your composer.json
1616

1717
```
1818
then run
19-
```
19+
```bash
2020
composer update
2121
```
2222

@@ -25,7 +25,7 @@ composer update
2525
### Configuration - Loading the config service
2626

2727
in config.ini or in any config file
28-
```
28+
```ini
2929
[jwtAuth]
3030

3131
; JWT Secret Key
@@ -54,7 +54,7 @@ ignoreUri[] = /auth/application
5454
```
5555

5656
in bootstrap or index file
57-
```
57+
```php
5858
use Phalcon\Mvc\Micro;
5959
use Phalcon\Config\Adapter\Ini as ConfigIni;
6060
use Phalcon\Di\FactoryDefault;
@@ -85,7 +85,7 @@ $app->handle();
8585

8686
### Configuration - Don't want to use a config file? then pass the config instead
8787
in bootstrap or index file
88-
```
88+
```php
8989
use Phalcon\Mvc\Micro;
9090
use Phalcon\Config\Adapter\Ini as ConfigIni;
9191
use Phalcon\Di\FactoryDefault;
@@ -131,7 +131,7 @@ or pass the token as a query string
131131
### Callbacks
132132

133133
By default if the authentication fails, the middleware will stop the execution of routes and will immediately return a response of 401 Unauthorized. If you want to add your own handler:
134-
```
134+
```php
135135
$auth->onUnauthorized(function($authMicro, $app) {
136136

137137
$response = $app["response"];
@@ -148,7 +148,7 @@ $auth->onUnauthorized(function($authMicro, $app) {
148148
```
149149

150150
If you want an additional checking on the authentication, like intentionally expiring a token based on the payload issued date, you may do so:
151-
```
151+
```php
152152
$auth->onCheck(function($auth) {
153153
// to get the payload
154154
$data = $auth->data();
@@ -164,7 +164,7 @@ $auth->onCheck(function($auth) {
164164
### The Auth service
165165

166166
You can access the middleware by calling the "auth" service.
167-
```
167+
```php
168168
print_r( $app['auth']->data() );
169169

170170
print_r( $app->getDI()->get('auth')->data('email') );
@@ -180,7 +180,7 @@ AuthMicro::$diName = 'jwtAuth';
180180
### Creating a token
181181

182182
In your controller or route handler
183-
```
183+
```php
184184
$payload = [
185185
'sub' => $user->id,
186186
'email' => $user->email,
@@ -193,7 +193,7 @@ $token = $this->auth->make($payload);
193193

194194
### Accessing the authenticated user / data
195195
In your controller or route handler
196-
```
196+
```php
197197
echo $this->auth->id(); // will look for sub or id payload
198198

199199
echo $this->auth->data(); // return all payload
@@ -204,7 +204,7 @@ echo $this->auth->data('email');
204204

205205
### Extending
206206
If you want to add your own middleware or play around:
207-
```
207+
```php
208208
Dmkit\Phalcon\Auth\Auth.php and its adapters - does all the authentication
209209

210210
Dmkit\Phalcon\Auth\TokenGetter\TokenGetter.php and its adapters - does the parsing or getting of token

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"require": {
1515
"php": ">=7.0",
1616
"ext-phalcon": "^3.0",
17-
"firebase/php-jwt": "^4.0"
17+
"firebase/php-jwt": "^5.0"
1818
},
1919
"autoload": {
2020
"psr-4": { "Dmkit\\Phalcon\\Auth\\": "src/Phalcon/Auth/" }

0 commit comments

Comments
 (0)