work in progress: JWT authentication
This commit is contained in:
parent
ab050ba360
commit
a3da3f07f0
2 changed files with 46 additions and 1 deletions
|
@ -21,7 +21,14 @@ postgres = [
|
||||||
"transaction",
|
"transaction",
|
||||||
"zope.sqlalchemy",
|
"zope.sqlalchemy",
|
||||||
]
|
]
|
||||||
app = ["python-dotenv", "zope.publisher", "zope.traversing"]
|
app = [
|
||||||
|
"python-dotenv",
|
||||||
|
"zope.authentication",
|
||||||
|
"zope.component",
|
||||||
|
"zope.interface",
|
||||||
|
"zope.publisher",
|
||||||
|
"zope.traversing",
|
||||||
|
]
|
||||||
test = ["zope.testrunner"]
|
test = ["zope.testrunner"]
|
||||||
#test = ["pytest"]
|
#test = ["pytest"]
|
||||||
|
|
||||||
|
|
38
scopes/server/auth.py
Normal file
38
scopes/server/auth.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# scopes.server.auth
|
||||||
|
|
||||||
|
from zope.authentication.interfaces import IAuthentication
|
||||||
|
from zope.principalregistry.principalregistry import PrincipalRegistry
|
||||||
|
from zope.component import getUtility, provideUtility, queryNextUtility
|
||||||
|
from zope.interface import implementer
|
||||||
|
|
||||||
|
baseAuth = None
|
||||||
|
|
||||||
|
class JwtAuthentication(PrincipalRegistry):
|
||||||
|
|
||||||
|
def authenticate(self, request):
|
||||||
|
prc = authenticate(request)
|
||||||
|
if prc is None:
|
||||||
|
return baseAuth.authenticate(request)
|
||||||
|
|
||||||
|
def getPrincipal(self, id):
|
||||||
|
return baseAuth.getPrincipal(id)
|
||||||
|
|
||||||
|
def unauthenticatedPrincipal(self):
|
||||||
|
return baseAuth.unauthenticatedPrincipal()
|
||||||
|
|
||||||
|
def unauthorized(self, id, request):
|
||||||
|
return baseAuth.unauthorized(id, request)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def authenticate(request):
|
||||||
|
print('*** authenticate')
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def registerAuthUtility():
|
||||||
|
global baseAuth
|
||||||
|
baseAuth = getUtility(IAuthentication)
|
||||||
|
print('*** registerAuthUtility, baseAuth:', baseAuth)
|
||||||
|
provideUtility(JwtAuthentication(), IAuthentication)
|
||||||
|
|
Loading…
Add table
Reference in a new issue