Download the PHP package auth0-samples/laravel without Composer
On this page you can find all versions of the php package auth0-samples/laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download auth0-samples/laravel
More information about auth0-samples/laravel
Files in auth0-samples/laravel
Package laravel
Short Description Sample application demonstrating how to integrate Auth0 with Laravel 9 or Laravel 10 for session-based authentication and token-based authorization.
License MIT
Informations about the package laravel
:books: Default Changes
This is a sample project demonstrating how to integrate the Auth0 Laravel SDK into a Laravel 9 application. For Laravel 10 applications, the integration steps are identical.
Documentation
Guidance on integrating Auth0 into your Laravel application can be found here:
- Auth0 Laravel SDK Readme
- Auth0 Laravel SDK Session Authentication Quickstart
- Auth0 Laravel SDK Token Authorization Quickstart
You may also find the following documentation from the SDK's GitHub repository useful:
Getting Started
Use Composer's create-project
command to clone this repository and install the dependencies:
Authenticate with Auth0 using the bundled Auth0 CLI:
Note
Authenticate as a "user" if prompted.
Create an Auth0 Application:
Create an Auth0 API:
Run the application:
Demonstration Routes
This sample includes a few demonstration routes to help you get started.
Session-Based Authentication
The SDK automatically registers the following routes for session-based authentication:
Method | Route | Description |
---|---|---|
GET | /login | Starts the user authentication flow. Sets up some initial cookies, and redirects to Auth0 to authenticate. |
GET | /callback | Handles the return callback from Auth0. Completes setting up the user's Laravel session. |
GET | /logout | Logs the user out. |
The routes/web.php
file contains routes that demonstrate working with session-based authentication. These are:
Method | Route | Description |
---|---|---|
GET | /private | Demonstrates how to protect a route with the auth middleware. |
GET | /scope | Demonstrates how to protect a route with the can middleware. |
GET | /colors | Demonstrates how to make Management API calls. |
Token-Based Authorization
The routes/api.php
file contains routes that demonstrate token-based authorization. These are:
Method | Route | Description |
---|---|---|
GET | /api | Demonstrates how to extract information from the request token. |
GET | /api/private | Demonstrates how to protect an API route with the auth middleware. |
GET | /api/scope | Demonstrates how to protect an API route with the can middleware. |
GET | /api/me | Demonstrates how to make Management API calls. |
Changes to the Default Laravel Application
This sample is based on the default Laravel application you can create using laravel new
or composer create-project
.
Note
For Laravel 10, usecomposer create-project laravel/laravel:^10.0
and follow the same steps outlined below.
Few changes are necessary to get started, as the SDK automatically sets up all the necessary guards, middleware and other services necessary to support authentication and authorization. The following is a list of changes that have been applied:
-
The
auth0/login
package has been added to thecomposer.json
file, using: -
The
config/auth0.php
file was generated, using: - The
routes/web.php
file was updated to include the demonstration routes. - The
routes/api.php
file was updated to include the demonstration routes.
Feedback
We appreciate your feedback! Please create an issue in this repository or reach out to us on Community.
Vulnerability Reporting
Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.
What is Auth0?
Auth0 helps you to easily:
- implement authentication with multiple identity providers, including social (e.g., Google, Facebook, Microsoft, LinkedIn, GitHub, Twitter, etc), or enterprise (e.g., Windows Azure AD, Google Apps, Active Directory, ADFS, SAML, etc.)
- log in users with username/password databases, passwordless, or multi-factor authentication
- link multiple user accounts together
- generate signed JSON Web Tokens to authorize your API calls and flow the user identity securely
- access demographics and analytics detailing how, when, and where users are logging in
- enrich user profiles from other data sources using customizable JavaScript rules
License
This project is licensed under the MIT license. See the LICENSE file for more info.