- Modernized authentication with the introduction of TenantProject

- Created a base mail template
- Adapt and improve document API to usage of catalogs and processors
- Adapt eveai_sync to new authentication mechanism and usage of catalogs and processors
This commit is contained in:
Josako
2024-11-21 17:24:33 +01:00
parent 4c009949b3
commit 7702a6dfcc
72 changed files with 2338 additions and 503 deletions

View File

@@ -0,0 +1,52 @@
"""Updating Tenant, User and TenantProject to cope with new authentication mechanism
Revision ID: 392d48aa045e
Revises: 51aba07aac6b
Create Date: 2024-11-20 14:23:28.742766
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '392d48aa045e'
down_revision = '51aba07aac6b'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('tenant', schema=None) as batch_op:
batch_op.drop_column('encrypted_chat_api_key')
batch_op.drop_column('encrypted_api_key')
batch_op.drop_column('fallback_algorithms')
batch_op.drop_column('usage_email')
with op.batch_alter_table('tenant_project', schema=None) as batch_op:
batch_op.add_column(sa.Column('responsible_email', sa.String(length=255), nullable=True))
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.add_column(sa.Column('is_primary_contact', sa.Boolean(), nullable=True))
batch_op.add_column(sa.Column('is_financial_contact', sa.Boolean(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.drop_column('is_financial_contact')
batch_op.drop_column('is_primary_contact')
with op.batch_alter_table('tenant_project', schema=None) as batch_op:
batch_op.drop_column('responsible_email')
with op.batch_alter_table('tenant', schema=None) as batch_op:
batch_op.add_column(sa.Column('usage_email', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('fallback_algorithms', postgresql.ARRAY(sa.VARCHAR(length=50)), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('encrypted_api_key', sa.VARCHAR(length=500), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('encrypted_chat_api_key', sa.VARCHAR(length=500), autoincrement=False, nullable=True))
# ### end Alembic commands ###

View File

@@ -0,0 +1,47 @@
"""Added TenantProject for API-key management
Revision ID: 51aba07aac6b
Revises: 741bb5dac7f3
Create Date: 2024-11-20 14:03:02.917769
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '51aba07aac6b'
down_revision = '741bb5dac7f3'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('tenant_project',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('tenant_id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=50), nullable=False),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('services', postgresql.ARRAY(sa.String(length=50)), nullable=False),
sa.Column('encrypted_api_key', sa.String(length=500), nullable=True),
sa.Column('visual_api_key', sa.String(length=20), nullable=True),
sa.Column('active', sa.Boolean(), nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('created_by', sa.Integer(), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_by', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['created_by'], ['public.user.id'], ),
sa.ForeignKeyConstraint(['tenant_id'], ['public.tenant.id'], ),
sa.ForeignKeyConstraint(['updated_by'], ['public.user.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='public'
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('tenant_project', schema='public')
# ### end Alembic commands ###

View File

@@ -0,0 +1,56 @@
"""Remove obsolete fields from tenants due to Catalog introduction
Revision ID: 741bb5dac7f3
Revises: a678c84d5633
Create Date: 2024-10-16 11:34:59.194992
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '741bb5dac7f3'
down_revision = 'a678c84d5633'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('tenant', schema=None) as batch_op:
batch_op.drop_column('rag_tuning')
batch_op.drop_column('html_excluded_classes')
batch_op.drop_column('html_tags')
batch_op.drop_column('chat_RAG_temperature')
batch_op.drop_column('html_excluded_elements')
batch_op.drop_column('embed_tuning')
batch_op.drop_column('es_similarity_threshold')
batch_op.drop_column('chat_no_RAG_temperature')
batch_op.drop_column('html_end_tags')
batch_op.drop_column('html_included_elements')
batch_op.drop_column('max_chunk_size')
batch_op.drop_column('min_chunk_size')
batch_op.drop_column('es_k')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('tenant', schema=None) as batch_op:
batch_op.add_column(sa.Column('es_k', sa.INTEGER(), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('min_chunk_size', sa.INTEGER(), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('max_chunk_size', sa.INTEGER(), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('html_included_elements', postgresql.ARRAY(sa.VARCHAR(length=50)), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('html_end_tags', postgresql.ARRAY(sa.VARCHAR(length=10)), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('chat_no_RAG_temperature', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('es_similarity_threshold', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('embed_tuning', sa.BOOLEAN(), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('html_excluded_elements', postgresql.ARRAY(sa.VARCHAR(length=50)), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('chat_RAG_temperature', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('html_tags', postgresql.ARRAY(sa.VARCHAR(length=10)), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('html_excluded_classes', postgresql.ARRAY(sa.VARCHAR(length=200)), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('rag_tuning', sa.BOOLEAN(), autoincrement=False, nullable=True))
# ### end Alembic commands ###

View File

@@ -0,0 +1,36 @@
"""Add Financial Role
Revision ID: f0ab991a6411
Revises: 392d48aa045e
Create Date: 2024-11-20 14:30:19.068984
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'f0ab991a6411'
down_revision = '392d48aa045e'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.execute("""
INSERT INTO public.role (name, description)
VALUES ('Tenant Financial', 'Role for managing tenant financial operations');
""")
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.execute("""
DELETE FROM public.role
WHERE name = 'Tenant Financial';
""")
# ### end Alembic commands ###