Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ make up
FastID is available at [http://localhost:8012](http://localhost:8012):

![Sign In](img/signin.png)
![Profile](img/profile.png)
![Connections](img/connections.png)
![Profile](img/profile1.png)
![Connections](img/profile2.png)

Admin panel is available at: [http://localhost:8012/admin](http://localhost:8012/admin):

Expand All @@ -90,7 +90,7 @@ To start using FastID, you need to [create](http://localhost:8012/admin/app/crea
This will allow you to use FastID for
authentication in your application.

![Sign In](img/create_app.png)
![Create app](img/admin_create_app.png)

Once you have created an application, you can use the standard OAuth 2.0 flow to authenticate users. FastID supports the
authorization code flow, which is the most secure and recommended way to authenticate users.
Expand Down Expand Up @@ -143,7 +143,6 @@ def callback(code: str) -> Any:
headers={"Authorization": f"Bearer {token}"},
)
return response.json()

```

In this example, we define two routes:
Expand All @@ -158,9 +157,13 @@ Run the FastAPI application:
fastapi dev examples/httpx.py
```

Visit [http://localhost:8000/login](http://localhost:8000/login) to start the authentication process. After logging in,
you will be redirected to the `/callback` route, where you can see the user's information.
Visit [http://localhost:8000/login](http://localhost:8000/login) to start the authentication process. You will be
redirected to the FastID login page, where you can log in with your credentials or use a third-party provider.

![Login](img/oauth_consent.png)

After logging in, you will be redirected to the `/callback` route, where you can access the user's information.

![Test Response](img/test_response.png)
![Test Response](img/oauth_callback.png)

**Made with ❤️**
Binary file removed docs/docs/img/action_confirmation.png
Binary file not shown.
Binary file modified docs/docs/img/admin_apps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docs/img/admin_create_app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/docs/img/admin_login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docs/img/admin_oauth_accounts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/docs/img/admin_users.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docs/img/admin_view_app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/docs/img/api_docs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docs/img/api_request.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docs/img/change_email.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/docs/img/change_password.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/docs/img/connections.png
Binary file not shown.
Binary file removed docs/docs/img/create_app.png
Binary file not shown.
Binary file modified docs/docs/img/delete_account.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file removed docs/docs/img/logo_fully_transparent.png
Binary file not shown.
Binary file added docs/docs/img/logo_transparent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/docs/img/logo_white.png
Binary file not shown.
Binary file added docs/docs/img/oauth_callback.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docs/img/oauth_consent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docs/img/oauth_login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/docs/img/profile.png
Binary file not shown.
Binary file added docs/docs/img/profile1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docs/img/profile2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docs/img/restore_account.png
Binary file modified docs/docs/img/signin.png
Binary file modified docs/docs/img/signup.png
Binary file added docs/docs/img/verify_action.png
12 changes: 9 additions & 3 deletions docs/docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@

![Sign In](img/signin.png)
![Sign Up](img/signup.png)
![Profile](img/profile.png)
![Connections](img/connections.png)
![Action Confirmation](img/action_confirmation.png)
![Profile](img/profile1.png)
![Profile](img/profile2.png)
![Action Confirmation](img/verify_action.png)
![Change Password](img/change_password.png)
![Change Email](img/change_email.png)
![Delete Account](img/delete_account.png)
![Restore Account](img/restore_account.png)

## Admin Dashboard

![Admin Login](img/admin_login.png)
![Admin Apps](img/admin_apps.png)
![Admin Users](img/admin_users.png)
![Admin OAuth Accounts](img/admin_oauth_accounts.png)
![Admin Create App](img/admin_create_app.png)
![Admin View App](img/admin_view_app.png)

## API Docs

![API Docs](img/api_docs.png)
![API Docs](img/api_request.png)
34 changes: 19 additions & 15 deletions docs/docs/tutorial/get_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ To start using FastID, you need to [create](http://localhost:8012/admin/app/crea
This will allow you to use FastID for
authentication in your application.

![Sign In](../img/create_app.png)
![Sign In](../img/admin_create_app.png)

Once you have created an application, you can use the standard OAuth 2.0 flow to authenticate users. FastID supports the
authorization code flow, which is the most secure and recommended way to authenticate users.

## HTTPX example
## HTTPX Example

Here is an example of how to use FastID for authentication in a Python application using the
[FastAPI](https://fastapi.tiangolo.com/) framework and the [httpx](https://www.python-httpx.org/) library.
Expand Down Expand Up @@ -64,7 +64,7 @@ def callback(code: str) -> Any:

```

## FastLink example
## FastLink Example

You can also use the [FastLink](https://github.com/everysoftware/fastlink) as a faster and safer way:

Expand All @@ -78,24 +78,24 @@ from fastlink.schemas import OAuth2Callback, ProviderMeta

app = FastAPI()
fastid = FastLink(
ProviderMeta(server_url="http://localhost:8012", scope=["openid"]),
..., # Client ID
..., # Client Secret
"http://localhost:8000/callback",
ProviderMeta(server_url="http://localhost:8012", scope=["openid"]),
..., # Client ID
..., # Client Secret
"http://localhost:8000/callback",
)


@app.get("/login")
async def login() -> Any:
async with fastid:
url = await fastid.login_url()
return RedirectResponse(url=url)
async with fastid:
url = await fastid.login_url()
return RedirectResponse(url=url)


@app.get("/callback")
async def callback(call: Annotated[OAuth2Callback, Depends()]) -> Any:
async with fastid:
return await fastid.callback_raw(call)
async with fastid:
return await fastid.callback_raw(call)
```

## Results
Expand All @@ -112,7 +112,11 @@ Run the FastAPI application:
fastapi dev examples/httpx.py
```

Visit [http://localhost:8000/login](http://localhost:8000/login) to start the authentication process. After logging in,
you will be redirected to the `/callback` route, where you can see the user's information.
Visit [http://localhost:8000/login](http://localhost:8000/login) to start the authentication process. You will be
redirected to the FastID login page, where you can log in with your credentials or use a third-party provider.

![Test Response](../img/test_response.png)
![Login](../img/oauth_consent.png)

After logging in, you will be redirected to the `/callback` route, where you can access the user's information.

![Test Response](../img/oauth_callback.png)
19 changes: 19 additions & 0 deletions docs/docs/tutorial/observability.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Observability

FastID provides built-in support for observability using **Grafana**, **Prometheus**,
**Tempo**, and **Loki**. This allows you to monitor your application performance and log data effectively.

## Setup

Repository containing the required infrastructure and sample
dashboards: [https://github.com/everysoftware/fastapi-obs](https://github.com/everysoftware/fastapi-obs).

To use the observability features, you need to have the following environment variables set in your `.env` file:

```
OBS_ENABLED=1
OBS_TEMPO_URL="http://TEMPO_URL:4317"
```

![Metrics](../img/grafana_metrics.png)
![Logs](../img/grafana_logs.png)
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ nav:
- tutorial/get_started.md
- tutorial/notifications.md
- tutorial/social.md
- tutorial/observability.md
- tutorial/api.md

extra:
Expand Down
3 changes: 2 additions & 1 deletion fastid/pages/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ def verify_action(
@router.get("/change-password")
def change_password(
request: Request,
user: Annotated[User | None, Depends(get_user_or_none)],
verified: Annotated[bool, Depends(is_action_verified)],
) -> Response:
if not verified:
return RedirectResponse(f"/verify-action?action={UnsafeAction.change_password}")
return templates.TemplateResponse(
"change-password.html",
{"request": request},
{"request": request, "user": user},
)


Expand Down
Binary file removed img/action_confirmation.png
Diff not rendered.
Binary file modified img/admin_apps.png
Binary file added img/admin_create_app.png
Binary file modified img/admin_login.png
Binary file added img/admin_oauth_accounts.png
Binary file modified img/admin_users.png
Binary file added img/admin_view_app.png
Binary file modified img/api_docs.png
Binary file added img/api_request.png
Binary file added img/change_email.png
Binary file modified img/change_password.png
Binary file removed img/connections.png
Diff not rendered.
Binary file removed img/create_app.png
Diff not rendered.
Binary file modified img/delete_account.png
File renamed without changes
File renamed without changes
Binary file removed img/logo_fully_transparent.png
Diff not rendered.
Binary file removed img/logo_white.png
Diff not rendered.
Binary file added img/oauth_callback.png
Binary file added img/oauth_consent.png
Binary file added img/oauth_login.png
Binary file removed img/profile.png
Diff not rendered.
Binary file added img/profile1.png
Binary file added img/profile2.png
Binary file added img/restore_account.png
Binary file modified img/signin.png
Binary file modified img/signup.png
Binary file removed img/test_response.png
Diff not rendered.
Binary file added img/verify_action.png
5 changes: 5 additions & 0 deletions static/js/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ document.addEventListener('DOMContentLoaded', () => {
alert("Passwords do not match.");
return;
}
const passwordRegex = /^((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{8,20})$/;
if (!passwordRegex.test(password)) {
alert("Password must be at least 8 characters long and include a number and a special character.");
return;
}
const body = {
email: document.getElementById("email").value,
password: password,
Expand Down