This commit is contained in:
yumoqing 2025-07-10 16:32:25 +08:00
parent fc4faed700
commit 102c65b2e9
3 changed files with 24 additions and 1 deletions

4
pyproject.toml Normal file
View File

@ -0,0 +1,4 @@
[build-system]
requires = ["setuptools>=61", "wheel"]
build-backend = "setuptools.build_meta"

View File

@ -125,6 +125,8 @@ async def bearer_auth(sor, auth):
async def getAuthenticationUserid(sor, request): async def getAuthenticationUserid(sor, request):
auth = request.headers.get('Authentication') auth = request.headers.get('Authentication')
if auth is None:
return None
for h,f in registered_auth_methods.items(): for h,f in registered_auth_methods.items():
if auth.startswith(h): if auth.startswith(h):
return await f(auth) return await f(auth)
@ -168,6 +170,7 @@ registered_auth_methods = {
"Basic ": basic_auth, "Basic ": basic_auth,
"Bearer ": bearer_auth "Bearer ": bearer_auth
} }
register_auth_method(heading, func):
def register_auth_method(heading, func):
registered_auth_methods[heading] = func registered_auth_methods[heading] = func

16
setup.cfg Normal file
View File

@ -0,0 +1,16 @@
[metadata]
name=rbac
version = 1.0.0
description = a RBAC user authenticate module
author = "yu moqing"
author_email = "yumoqing@gmail.com"
readme = "README.md"
license = "MIT"
[options]
packages = find:
requires_python = ">=3.8"
install_requires =
apppublic
sqlor
ahserver