Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
evansims committed Jun 26, 2023
1 parent 771fba9 commit f4cfc34
Showing 1 changed file with 1 addition and 68 deletions.
69 changes: 1 addition & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,6 @@
# Auth0 + PHP Backend API Sample

This Quickstart demonstrates how to create an API that authenticates incoming requests with [PHP](http://php.net/) using JWTs signed by [Auth0](https://auth0.com). For a complete understanding of this Quickstart, please follow along with the [documentation](https://auth0.com/docs/quickstart/backend/php).

For demonstration purposes, this Quickstart includes the [auth0-spa-js](https://github.com/auth0/auth0-spa-js) library to authenticate end users from a mockup frontend, and passes the resulting access token to a custom PHP API backend to authorize endpoints. You are not required to use this or any particular frontend library, it's merely a useful example of a common use case.

## Configuration

### Create a free account in Auth0

1. Go to [Auth0](https://auth0.com) and click Sign Up.
2. Use Google, GitHub, or Microsoft Account to login.

### Create an Auth0 Application

You will need to create a Single Page Application using the [Auth0 Dashboard](https://manage.auth0.com). This will give you a Domain, Client ID, and Client Secret you will need below.

### Configure Credentials

Your project needs to be configured with your Auth0 Domain, Client ID, and Client Secret for the authentication flow to work.

Copy .env.example into a new file in the same folder called .env, and replace the values with your Auth0 application credentials:

```sh
# Your Auth0 Application's Client ID
AUTH0_CLIENT_ID={CLIENT_ID}

# The URL of your Auth0 tenant domain
AUTH0_DOMAIN={DOMAIN}

# Your Auth0 application's Client Secret
AUTH0_CLIENT_SECRET={CLIENT_SECRET}

# The Identifier from your custom Auth0 API.
AUTH0_AUDIENCE={API_IDENTIFIER}
```

**Note**: Ensure you are consistent in your use of 'localhost' and/or '127.0.0.1' when testing. These must match your Auth0 Application settings or you will encounter errors. They must also match for session cookies to work properly.

## Run the sample

Before continuing, please ensure you have [PHP](https://www.php.net/manual/en/install.php) 8.0+ and [Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos) installed and accessible from your shell. These are required.

Next, use the following command to install the necessary dependencies and start the sample:

```bash
composer run app
```

Your Quickstart should now be accessible at [http://127.0.0.1:3000/](http://127.0.0.1:3000/) from your web browser.

## Running with Docker

Before continuing, make sure you have [Docker](https://docs.docker.com/get-docker/) installed. This is required.

Next, use the following command to install the necessary dependencies and start the sample within a Docker container:

```bash
composer run docker
```

Your Quickstart should now be accessible at [http://127.0.0.1:3000/](http://127.0.0.1:3000/) from your web browser.

## Running the unit tests

Unit tests are setup to run through [Docker](https://docs.docker.com/get-docker/) for portability. Use the following command to install the necessary dependencies and start the sample test suite:

```bash
composer run tests
```
This sample demonstrates how to add endpoint authorization to a [PHP](http://php.net/) backend API service using [Auth0](https://auth0.com). The project source code can be found in the [app directory](./app). Check the [PHP Quickstart](https://auth0.com/docs/quickstart/backend/php) to understand this sample better.

## Vulnerability Reporting

Expand Down

0 comments on commit f4cfc34

Please sign in to comment.