feat(developer): support custom OAuth 2.0 client
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
"""auth: support custom client
|
||||
|
||||
Revision ID: a8669ba11e96
|
||||
Revises: aa582c13f905
|
||||
Create Date: 2025-08-11 11:47:11.004301
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "a8669ba11e96"
|
||||
down_revision: str | Sequence[str] | None = "aa582c13f905"
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
"oauth_clients",
|
||||
sa.Column("client_id", sa.Integer(), nullable=False),
|
||||
sa.Column("client_secret", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column("redirect_uris", sa.JSON(), nullable=True),
|
||||
sa.Column("owner_id", sa.BigInteger(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["owner_id"],
|
||||
["lazer_users.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("client_id"),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_oauth_clients_client_id"), "oauth_clients", ["client_id"], unique=False
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_oauth_clients_client_secret"),
|
||||
"oauth_clients",
|
||||
["client_secret"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_oauth_clients_owner_id"), "oauth_clients", ["owner_id"], unique=False
|
||||
)
|
||||
op.add_column("oauth_tokens", sa.Column("client_id", sa.Integer(), nullable=False))
|
||||
op.create_index(
|
||||
op.f("ix_oauth_tokens_client_id"), "oauth_tokens", ["client_id"], unique=False
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f("ix_oauth_tokens_client_id"), table_name="oauth_tokens")
|
||||
op.drop_column("oauth_tokens", "client_id")
|
||||
op.drop_index(op.f("ix_oauth_clients_owner_id"), table_name="oauth_clients")
|
||||
op.drop_index(op.f("ix_oauth_clients_client_secret"), table_name="oauth_clients")
|
||||
op.drop_index(op.f("ix_oauth_clients_client_id"), table_name="oauth_clients")
|
||||
op.drop_table("oauth_clients")
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user