You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**This is a major release and includes breaking changes!** This release also includes a major version change for the PHP SDK that it relies on. Please see the [migration guide](https://github.com/auth0/auth0-PHP/blob/master/MIGRATE-v5-TO-v7.md) for the PHP SDK for more information.
7
+
8
+
**Closed issues**
9
+
- auth0-PHP 7.0 - State and nonce handling [\#163](https://github.com/auth0/laravel-auth0/issues/163)
10
+
- Cannot use actingAs unit tests functionality [\#161](https://github.com/auth0/laravel-auth0/issues/161)
- Use array for Auth0JWTUser and add repo return types [\#176](https://github.com/auth0/laravel-auth0/pull/176) ([joshcanhelp](https://github.com/joshcanhelp))
17
+
- Update PHP SDK to v7.0.0 [\#162](https://github.com/auth0/laravel-auth0/pull/162) ([joshcanhelp](https://github.com/joshcanhelp))
18
+
- Bind SessionState handler interface in container [\#147](https://github.com/auth0/laravel-auth0/pull/147) ([nstapelbroek](https://github.com/nstapelbroek))
Copy file name to clipboardExpand all lines: README.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,36 @@ You can implement your own cache strategy by creating a new class that implement
46
46
47
47
You can customize the way you handle the users in your application by creating your own `UserRepository`. This class should implement the `Auth0\Login\Contract\Auth0UserRepository` contract. Please see the [Custom User Handling section of the Laravel Quickstart](https://auth0.com/docs/quickstart/webapp/laravel#optional-custom-user-handling) for the latest example.
48
48
49
+
### Using auth guard
50
+
51
+
To protect APIs using an access token generated by Auth0, there is an `auth0` API guard provided ([Laravel documentation on guards](https://laravel.com/docs/7.x/authentication#adding-custom-guards)). To use this guard, add it to `config/auth.php` with the driver `auth0`:
52
+
```
53
+
'guards' => [
54
+
...
55
+
'auth0' => [
56
+
'driver' => 'auth0',
57
+
'provider' => 'auth0',
58
+
],
59
+
],
60
+
61
+
'providers' => [
62
+
...
63
+
'auth0' => [
64
+
'driver' => 'auth0',
65
+
],
66
+
],
67
+
```
68
+
69
+
Once that has been added, add the guard to the middleware of any API route and check authentication during the request:
70
+
```
71
+
// get user
72
+
auth('auth0')->user();
73
+
// check if logged in
74
+
auth('auth0')->check();
75
+
// protect routes via middleware use
76
+
Route::group(['middleware' => 'auth:auth0'], function () {});
77
+
```
78
+
49
79
## Installation
50
80
51
81
Install this plugin into a new or existing project using [Composer](https://getcomposer.org/doc/00-intro.md):
0 commit comments