Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make user and claims model configurable #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thijsvanwinden
Copy link

Hi all,

I would like to use this for a simple API backend.

Currently the claims and user are not configurable which is often required for other applications. This enables extension of the claims and user in a simple manner.

Let me know what you think of this change.

Kind regards,

Thijs van Winden

Currently the claims and user are not configurable which is often required for other applications. This enables extension of the claims and user in a simple manner.
@davidhuser
Copy link
Contributor

Hi Thijs, thanks for your suggestion!

We support in general a configuration option for the Claims and User object. I created an issue to describe the new feature.

In this PR however I do not see yet how to achieve it, and which claims and user you'd like to use instead, as examples.

Right now I'm not able to implement it due to time constraints but perhaps at the end of the month. If you'd like to create/update your PR (see issue for details) I'm happy to respond to implementations. Many thanks! 😊

@thijsvanwinden
Copy link
Author

Hi David,

Thanks for your swift reply. In my use-case I have a custom claim in Zitadel that I need to check.

How I achieved it using the code in the PR is:

from typing import Any
from pydantic import Field
from fastapi_zitadel_auth import ZitadelAuth
from fastapi_zitadel_auth.models import AuthenticatedUser, ZitadelClaims
from starlette.requests import Request
from fastapi.security import SecurityScopes

class Claims(ZitadelClaims):
    organizations: list[str] = Field(
        default_factory=list, alias="whiffle:whs:orgs"
    )

class Auth(ZitadelAuth):
    claims_model = Claims

I tried configuring this, but I believe you anyway need to extend the ZitadelClaims model in order to propagate them. I can add examples and some docs if you agree with the approach.

Thijs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants