-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from cleanenergyexchange/dev
fix: nbf claim and zitadel_host
- Loading branch information
Showing
12 changed files
with
107 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,54 @@ | ||
## Zitadel setup | ||
|
||
### Project | ||
* Create a new project. | ||
* in the General settings, tick **"Assert Roles on Authentication"** and **"Check authorization on Authentication"** | ||
* Note the **project ID** (also called "resource Id") | ||
* Under Roles, **create a new role** with key: `user` and Display Name "user" and assign it to the project. | ||
|
||
### App 1: API | ||
* Create a new application in the project of **type "API"** and **Authentication Method "JWT (Private Key JWT)"** | ||
* Create a key of type "JSON" | ||
|
||
### App 2: User Agent | ||
* Create a new application in the project of **type "User Agent"** and **Authentication Method "PKCE"**. | ||
* Toggle "Development Mode" to allow non-https redirect URIs | ||
* Under **"Redirect URIs"**, add `http://localhost:8001/oauth2-redirect` | ||
* Token settings | ||
* Change **"Auth Token Type"** from "Bearer Token" to **"JWT"** | ||
* Tick **"Add user roles to the access token"** | ||
* Tick **"User roles inside ID token"** | ||
* Note the **Client Id** | ||
|
||
### User creation | ||
* Create a **new User** in the Zitadel instance. | ||
* Under Authorizations, create **new authorization** by searching for the project name and **assign the "user" role** to the new user | ||
|
||
### Service User creation | ||
* Create a **new Service User** in the Zitadel instance and select the **Access Token Type to be "JWT".** | ||
* Under Authorizations, create **new authorization** by searching for the project name and **assign the "user" role** to the new service user | ||
* Under Keys, **create a new key of type "JSON"** and note the key ID and **download** the key (JSON file). | ||
* **Update the config** in `demo_project/service_user.py` | ||
# Zitadel Setup Guide | ||
|
||
This guide walks you through setting up Zitadel authentication for your FastAPI application using `fastapi-zitadel-auth`. It covers configuring: | ||
- OAuth2 project settings | ||
- API application for service authentication | ||
- User Agent application for Swagger UI integration | ||
- User and service user permissions | ||
|
||
Follow these steps to enable secure authentication and API documentation through Swagger UI. | ||
|
||
## Project Configuration | ||
1. Create new project | ||
2. Enable security features in General settings: | ||
- "Assert Roles on Authentication" | ||
- "Check authorization on Authentication" | ||
3. Record the **project ID** (resource ID) | ||
4. Create role (e.g., `user`) and assign to project | ||
|
||
## API Application Setup | ||
Create application with: | ||
- Type: "API" | ||
- Authentication: "JWT (Private Key JWT)" | ||
|
||
## User Agent Application Setup | ||
Create application with: | ||
- Type: "User Agent" | ||
- Authentication: "PKCE" | ||
|
||
Configure token settings: | ||
- Set "Auth Token Type" to "JWT" | ||
- Enable "Add user roles to access token" | ||
- Enable "User roles inside ID token" | ||
|
||
Configure redirect URIs: | ||
- Add `http://localhost:8001/oauth2-redirect` (or your FastAPI app URL + `/oauth2-redirect`) | ||
- Development Mode: Enable for non-HTTPS redirects (development only) | ||
|
||
Record the Client ID. | ||
|
||
## User Setup | ||
1. Create user account | ||
2. Grant authorization: | ||
- Search project | ||
- Assign created role | ||
|
||
## Service User Setup | ||
1. Create service user with JWT access token type | ||
2. Grant project authorization with required role | ||
3. Generate JSON key: | ||
- Create new key (type: "JSON") | ||
- Download key file | ||
4. Keep key file secure | ||
|
||
To use this key in the demo app, update the path in `demo_project/service_user.py`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.