Skip to content

SQLAlchemy models

fastauth.contrib.sqlalchemy.models

SQLAlchemyBaseUser

Bases: Generic[ID]

id instance-attribute
id
email class-attribute instance-attribute
email = mapped_column(String(255), unique=True, index=True)
username class-attribute instance-attribute
username = mapped_column(String(200), unique=True, index=True)
hashed_password class-attribute instance-attribute
hashed_password = mapped_column(String(255))
is_active class-attribute instance-attribute
is_active = mapped_column(Boolean(), default=True)
is_verified class-attribute instance-attribute
is_verified = mapped_column(Boolean(), default=False)

SQLAlchemyBaseUserUUID

Bases: SQLAlchemyBaseUser[UUID]

email class-attribute instance-attribute
email = mapped_column(String(255), unique=True, index=True)
username class-attribute instance-attribute
username = mapped_column(String(200), unique=True, index=True)
hashed_password class-attribute instance-attribute
hashed_password = mapped_column(String(255))
is_active class-attribute instance-attribute
is_active = mapped_column(Boolean(), default=True)
is_verified class-attribute instance-attribute
is_verified = mapped_column(Boolean(), default=False)
id class-attribute instance-attribute
id = mapped_column(GUID(), primary_key=True, default=uuid4)

SQLAlchemyBaseRole

id class-attribute instance-attribute
id = mapped_column(primary_key=True, autoincrement=True)
codename class-attribute instance-attribute
codename = mapped_column(unique=True, index=True)
permissions
permissions()
Source code in fastauth/contrib/sqlalchemy/models.py
35
36
37
@declared_attr
def permissions(self) -> Mapped[list["SQLAlchemyBasePermission"]]:
    return relationship(secondary="role_permission_rel")

SQLAlchemyBasePermission

id class-attribute instance-attribute
id = mapped_column(primary_key=True, autoincrement=True)
codename class-attribute instance-attribute
codename = mapped_column(unique=True, index=True)

SQLAlchemyBaseRolePermissionRel

role_id class-attribute instance-attribute
role_id = mapped_column(ForeignKey('roles.id'), primary_key=True)
permission_id class-attribute instance-attribute
permission_id = mapped_column(ForeignKey('permissions.id'), primary_key=True)

SQLAlchemyBaseUserPermissionRel

Bases: Generic[ID]

user_id class-attribute instance-attribute
user_id = mapped_column(ForeignKey('users.id'), primary_key=True)
permission_id class-attribute instance-attribute
permission_id = mapped_column(ForeignKey('permissions.id'), primary_key=True)

SQLAlchemyBaseOAuthAccount

Bases: Generic[ID]

id instance-attribute
id
oauth_name class-attribute instance-attribute
oauth_name = mapped_column(String(255), index=True)
access_token instance-attribute
access_token
expires_at instance-attribute
expires_at
refresh_token instance-attribute
refresh_token
account_id class-attribute instance-attribute
account_id = mapped_column(String(200), index=True)
account_email class-attribute instance-attribute
account_email = mapped_column(String(255), index=True)

SQLAlchemyBaseOAuthAccountUUID

Bases: SQLAlchemyBaseOAuthAccount[UUID]

oauth_name class-attribute instance-attribute
oauth_name = mapped_column(String(255), index=True)
access_token instance-attribute
access_token
expires_at instance-attribute
expires_at
refresh_token instance-attribute
refresh_token
account_id class-attribute instance-attribute
account_id = mapped_column(String(200), index=True)
account_email class-attribute instance-attribute
account_email = mapped_column(String(255), index=True)
id class-attribute instance-attribute
id = mapped_column(GUID(), primary_key=True, default=uuid4)
user_id
user_id()
Source code in fastauth/contrib/sqlalchemy/models.py
80
81
82
83
84
@declared_attr
def user_id(self) -> Mapped[GUID]:
    return mapped_column(
        GUID, ForeignKey("users.id", ondelete="cascade"), nullable=False
    )

UserRBACMixin

role_id class-attribute instance-attribute
role_id = mapped_column(ForeignKey('roles.id'))
role
role()
Source code in fastauth/contrib/sqlalchemy/models.py
90
91
92
@declared_attr
def role(self) -> Mapped["SQLAlchemyBaseRole"]:
    return relationship()
permissions
permissions()
Source code in fastauth/contrib/sqlalchemy/models.py
94
95
96
@declared_attr
def permissions(self) -> Mapped[list["SQLAlchemyBasePermission"]]:
    return relationship(secondary="user_permission_rel")

UserOAuthMixin

oauth_accounts
oauth_accounts()
Source code in fastauth/contrib/sqlalchemy/models.py
100
101
102
@declared_attr
def oauth_accounts(self) -> Mapped["SQLAlchemyBaseOAuthAccount"]:
    return relationship()