MCPcopy Create free account
hub / github.com/TheSmallHanCat/flow2api / AuthManager

Class AuthManager

src/core/auth.py:12–34  ·  view source on GitHub ↗

Authentication manager

Source from the content-addressed store, hash-verified

10optional_security = HTTPBearer(auto_error=False)
11
12class AuthManager:
13 """Authentication manager"""
14
15 @staticmethod
16 def verify_api_key(api_key: str) -> bool:
17 """Verify API key"""
18 return api_key == config.api_key
19
20 @staticmethod
21 def verify_admin(username: str, password: str) -> bool:
22 """Verify admin credentials"""
23 # Compare with current config (which may be from database or config file)
24 return username == config.admin_username and password == config.admin_password
25
26 @staticmethod
27 def hash_password(password: str) -> str:
28 """Hash password"""
29 return bcrypt.hashpw(password.encode(), bcrypt.gensalt()).decode()
30
31 @staticmethod
32 def verify_password(password: str, hashed: str) -> bool:
33 """Verify password"""
34 return bcrypt.checkpw(password.encode(), hashed.encode())
35
36async def verify_api_key_header(credentials: HTTPAuthorizationCredentials = Security(security)) -> str:
37 """Verify API key from Authorization header"""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected