fix(auth): Casdoor JWT verification and 401 semantics; add /auth/login password-grant endpoint
- verify kid from the JWT header (pyjwt decode() returns claims, not the header — the old lookup was always None and rejected every token) - convert JWK entries to crypto keys explicitly (pyjwt 2.13 dropped dict keys) and fetch the JWKS from /.well-known/jwks - 401 for missing/invalid/expired/wrong-issuer/wrong-audience tokens (was 403/400); 403 stays for valid-but-roleless users; 503 when Casdoor is unreachable; new CASDOOR_ISSUER setting separates the in-network endpoint from the browser-facing issuer - dev-header fallback in inventory/pm scopes now requires an explicit X-User-Role header (no auth info at all -> 401) - new POST /api/v1/auth/login: password grant against Casdoor, local JWT verification, auto-provisioning, returns token + profile with the role resolved from the app users table
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""All API routers, re-exported for main.py assembly."""
|
||||
from app.routers import (
|
||||
attribute_definitions,
|
||||
auth,
|
||||
brand_materials,
|
||||
brands,
|
||||
category_attributes,
|
||||
@@ -29,6 +30,7 @@ from app.routers import (
|
||||
)
|
||||
|
||||
ROUTERS = [
|
||||
auth.router,
|
||||
units.router,
|
||||
brands.router,
|
||||
material_categories.router,
|
||||
|
||||
Reference in New Issue
Block a user