Skip to content

Class tigrbl_auth.orm.revoked_token.RevokedToken

tigrbl_auth.orm.revoked_token.RevokedToken

Bases: Base, GUIDPk, Timestamped

token class-attribute instance-attribute

token = acol(
    storage=S(String(512), nullable=False, unique=True)
)

created_at class-attribute instance-attribute

created_at = acol(
    spec=ColumnSpec(
        storage=S(
            type_=TZDateTime,
            default=tzutcnow,
            nullable=False,
        ),
        field=F(py_type=datetime),
        io=RO_IO,
    )
)

updated_at class-attribute instance-attribute

updated_at = acol(
    spec=ColumnSpec(
        storage=S(
            type_=TZDateTime,
            default=tzutcnow,
            onupdate=tzutcnow,
            nullable=False,
        ),
        field=F(py_type=datetime),
        io=RO_IO,
    )
)

id class-attribute instance-attribute

id = acol(
    spec=ColumnSpec(
        storage=S(
            type_=PgUUID(as_uuid=True),
            primary_key=True,
            default=uuid4,
        ),
        field=F(
            py_type=UUID,
            constraints={"examples": [uuid_example]},
        ),
        io=RO_IO,
    )
)

metadata class-attribute instance-attribute

metadata = MetaData(
    naming_convention={
        "pk": "pk_%(table_name)s",
        "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
        "ix": "ix_%(table_name)s_%(column_0_name)s",
        "uq": "uq_%(table_name)s_%(column_0_name)s",
        "ck": "ck_%(table_name)s_%(column_0_name)s_%(constraint_type)s",
    }
)

revoke async

revoke(ctx)
Source code in tigrbl_auth/orm/revoked_token.py
28
29
30
31
32
33
34
35
36
37
38
@op_ctx(alias="revoke", target="create", arity="collection")
async def revoke(cls, ctx):
    if not settings.enable_rfc7009:
        raise HTTPException(status.HTTP_404_NOT_FOUND, "revocation disabled")
    payload = ctx.get("payload") or {}
    token = payload.get("token")
    if not token:
        raise HTTPException(status.HTTP_400_BAD_REQUEST, "token required")
    await cls.handlers.create.core({"payload": {"token": token}})
    _cache_revoke(token)
    return {}