Compare commits

...

2 commits

2 changed files with 45 additions and 1 deletions

View file

@ -21,7 +21,13 @@ postgres = [
"transaction",
"zope.sqlalchemy",
]
app = ["python-dotenv", "zope.publisher", "zope.traversing"]
app = [
"python-dotenv",
"zope.authentication",
"zope.interface",
"zope.publisher",
"zope.traversing",
]
test = ["zope.testrunner"]
#test = ["pytest"]

38
scopes/server/auth.py Normal file
View file

@ -0,0 +1,38 @@
# scopes.server.auth
from zope.authentication.interfaces import IAuthentication
from zope.interface import implementer
from zope.publisher.interfaces import Unauthorized
def authenticate(request):
#print('*** authenticate')
return None
@implementer(IAuthentication)
class JwtAuthentication:
def __init__(self, baseAuth):
self.baseAuth = baseAuth
def authenticate(self, request):
prc = authenticate(request)
if prc is None and self.baseAuth is not None:
prc = self.baseAuth.authenticate(request)
if prc is None:
raise Unauthorized
return prc
def getPrincipal(self, id):
if self.baseAuth is not None:
return self.baseAuth.getPrincipal(id)
def unauthenticatedPrincipal(self):
if self.baseAuth is not None:
return self.baseAuth.unauthenticatedPrincipal()
def unauthorized(self, id, request):
if self.baseAuth is not None:
return self.baseAuth.unauthorized(id, request)