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
Copy file name to clipboardExpand all lines: Auth0.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -126,6 +126,48 @@ For Feedback Flow to work properly, you need to create two API configurations in
126
126
127
127
2. Add the same permissions and settings as the Production API
128
128
129
+
## Step 5.5: Machine-to-Machine App for Auth0 Management API (Feedback Flow Management)
130
+
131
+
To let the Cloudflare Worker request an Auth0 Management token securely, you need a Machine-to-Machine (M2M) application. This application issues Client Credentials (client_id / client_secret) used by the `/api/__auth0/token` endpoint. These credentials are stored in environment variables `AUTH0_MANAGEMENT_API_CLIENT_ID` and `AUTH0_MANAGEMENT_API_CLIENT_SECRET`.
132
+
133
+
### Why you need a Management M2M app
134
+
- The Cloudflare Worker needs a Management API token to perform administrative tasks and to retrieve management-level information from Auth0. Rather than storing user credentials, we create a dedicated M2M application that can request tokens using the client credentials flow.
135
+
136
+
### Create the Management M2M application
137
+
1. In your Auth0 dashboard, go to **Applications > Applications** and click **Create Application**.
138
+
2. Enter the **Name**: `Feedback Flow Management`.
139
+
3. Select **Machine to Machine Application** as the application type.
140
+
4. Click **Create**.
141
+
142
+
### Grant access to the Auth0 Management API
143
+
1. After creation, you will be prompted to select an API to grant access to. Select **Auth0 Management API** from the list.
144
+
2. Choose the scopes/permissions the M2M app should have. To keep a simple setup, you may choose **All** (for testing), or you can choose specific scopes such as `read:users`, `create:users`, `update:users`, `delete:users`, `read:clients` etc. (see note on *least privilege* below).
145
+
3. Save the authorization changes.
146
+
147
+
### Get the client credentials
148
+
1. Go to the **Settings** tab of the `Feedback Flow Management` application.
149
+
2. Copy the **Client ID** and **Client Secret** (the secret might be revealed as a button you must click to show).
150
+
3. Store those values securely. Add them to your `.env` file for local development or set them as GitHub secrets in your repo (`AUTH0_MANAGEMENT_API_CLIENT_ID` and `AUTH0_MANAGEMENT_API_CLIENT_SECRET`) for CI/CD deployments.
151
+
152
+
**Example `.env` entries (local development only)**
- Add the `AUTH0_MANAGEMENT_API_CLIENT_ID` and `AUTH0_MANAGEMENT_API_CLIENT_SECRET` secrets in the fork or origin GitHub repository (see the README Cloudflare deployment section for a list of all secrets the workflow requires).
160
+
161
+
### Usage
162
+
The Worker `/api/__auth0/token` endpoint will use `AUTH0_MANAGEMENT_API_CLIENT_ID` and `AUTH0_MANAGEMENT_API_CLIENT_SECRET` to request a Management API token from Auth0 via the Client Credentials OAuth flow. The token will be cached by the Worker in Cloudflare KV (if available) to avoid excessive calls to Auth0.
163
+
164
+
### Least Privilege and Security Notes
165
+
- Prefer selecting only the Management API scopes required by the Worker instead of granting every scope. The more limited the permission set, the lower the blast radius if the M2M credentials are compromised.
166
+
- Treat `AUTH0_MANAGEMENT_API_CLIENT_SECRET` as a secret: store it in CI/CD secrets (for GitHub Actions), and never commit it to source control.
167
+
- Rotate Management API client secrets periodically and update your GitHub secrets accordingly.
168
+
- Consider creating a dedicated Auth0 tenant or environment for production and limiting the M2M application access only to the production management features it requires.
169
+
170
+
129
171
## Step 6: Create Roles for Access Control
130
172
131
173
Roles simplify permission management by grouping permissions together:
0 commit comments