feat: API key auth for agents (create/list/revoke) + dual auth (JWT or API key)
This commit is contained in:
15
app/models/apikey.py
Normal file
15
app/models/apikey.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Boolean, ForeignKey
|
||||
from sqlalchemy.sql import func
|
||||
from app.core.config import Base
|
||||
|
||||
|
||||
class APIKey(Base):
|
||||
__tablename__ = "api_keys"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
key = Column(String(64), unique=True, nullable=False, index=True)
|
||||
name = Column(String(100), nullable=False) # e.g. "agent-zhi", "agent-lyn"
|
||||
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
||||
is_active = Column(Boolean, default=True)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
last_used_at = Column(DateTime(timezone=True), nullable=True)
|
||||
Reference in New Issue
Block a user