FastAPI-User-Auth is a simple and powerful FastAPI user RBAC authentication and authorization library. Based on FastAPI-Amis-Admin and provides a freely extensible visual management interface.
319
stars
43
forks
source link
[postgresql+asyncpg] 登录提示'接口报错:"Internal Server Error"' #5
将 fastapi_amis_admin.amis_admin 改为 fastapi_user_auth.site 中的 AuthAdminSite 后,能够显示登录页面,但是输入账号密码后,提示 "Internal Server Error"。
使用的是 fastapi_user_auth 内部自带的 models,模型部分无任何修改。
检查日志,有如下输出:
sys:1: SAWarning: Class SelectOfScalar will not make use of SQL compilation caching as it does not set the 'inherit_cache' attribute to ``True``. This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions. Set this attribute to True if this object can make use of the cache key generated by the superclass. Alternatively, this attribute may be set to False which will disable this warning. (Background on this error at: https://sqlalche.me/e/14/cprf)
INFO: 127.0.0.1:53295 - "POST /auth/form/login/api HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 366, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 75, in __call__
return await self.app(scope, receive, send)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\fastapi\applications.py", line 261, in __call__
await super().__call__(scope, receive, send)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\starlette\applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\starlette\middleware\errors.py", line 181, in __call__
raise exc
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\starlette\middleware\errors.py", line 159, in __call__
await self.app(scope, receive, _send)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\starlette\exceptions.py", line 82, in __call__
raise exc
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\starlette\exceptions.py", line 71, in __call__
await self.app(scope, receive, sender)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in __call__
raise e
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__
await self.app(scope, receive, send)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\starlette\routing.py", line 656, in __call__
await route.handle(scope, receive, send)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\starlette\routing.py", line 408, in handle
await self.app(scope, receive, send)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\fastapi\applications.py", line 261, in __call__
await super().__call__(scope, receive, send)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\starlette\applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\starlette\middleware\errors.py", line 181, in __call__
raise exc
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\starlette\middleware\errors.py", line 159, in __call__
await self.app(scope, receive, _send)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\starlette\exceptions.py", line 82, in __call__
raise exc
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\starlette\exceptions.py", line 71, in __call__
await self.app(scope, receive, sender)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in __call__
raise e
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__
await self.app(scope, receive, send)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\starlette\routing.py", line 656, in __call__
await route.handle(scope, receive, send)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\starlette\routing.py", line 259, in handle
await self.app(scope, receive, send)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\starlette\routing.py", line 61, in app
response = await func(request)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\fastapi\routing.py", line 217, in app
solved_result = await solve_dependencies(
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\fastapi\dependencies\utils.py", line 527, in solve_dependencies
solved = await call(**sub_values)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\fastapi_amis_admin\amis_admin\admin.py", line 739, in route
return await self.handle(request, data)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\fastapi_user_auth\admin.py", line 39, in handle
user = await request.auth.authenticate_user(username=data.username, password=data.password) # type:ignore
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\fastapi_user_auth\auth\auth.py", line 92, in authenticate_user
if user and self.pwd_context.verify(pwd, pwd2): # 用户存在 且 密码验证通过
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\passlib\context.py", line 2343, in verify
record = self._get_or_identify_record(hash, scheme, category)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\passlib\context.py", line 2031, in _get_or_identify_record
return self._identify_record(hash, category)
File "$SOMEPATH\FastAPIDemo\venv\lib\site-packages\passlib\context.py", line 1132, in identify_record
raise exc.UnknownHashError("hash could not be identified")
passlib.exc.UnknownHashError: hash could not be identified
将
fastapi_amis_admin.amis_admin
改为fastapi_user_auth.site
中的AuthAdminSite
后,能够显示登录页面,但是输入账号密码后,提示"Internal Server Error"
。使用的是
fastapi_user_auth
内部自带的 models,模型部分无任何修改。检查日志,有如下输出: