codemation / easyauth

Create a centralized Authentication and Authorization token server. Easily secure FastAPI endpoints based on Users, Groups, Roles or Permissions with very little database usage.
https://easyauth.readthedocs.io/en/latest/
MIT License
553 stars 52 forks source link

Extend User model #30

Open jhonsfran1165 opened 3 years ago

jhonsfran1165 commented 3 years ago

Hi there! Thanks for the awesome work here!

I would like to know what is the best approach to extend the user's model. Should I send a PR for those changes or is there any other way to extend that model from my app?.

codemation commented 3 years ago

Hi There @jhonsfran1165 - glad you are enjoying it so far.

Perhaps you can outline in more detail how you might like to extend the current model. If the changes make since, I would be very happy to have a PR to extend it further.

jhonsfran1165 commented 3 years ago

Sure, I think we can add some fields:

is_active: bool = True and is_verified: bool = False

I'm using those fields to validate if the user is active and if the user was validated. I wonder if those are covered somehow in easyauth. I checked the code and I find this user model:

class User(BaseModel):  
    username: str = None  
    password: Optional[str] = None
    full_name: Optional[str] = None
    email: str = None
    groups: Union[list, dict] = None
codemation commented 3 years ago

There is a current flow for activated users, if user activation is required i.e via sending a verification code via email.

Having a field that allows an admin to toggle on/off is a nice idea via is_active, I would only question the intent of is_verified.

Here are some other ideas / points is_active when implementing: