work in progress: login with zitadel (Open ID Connect)

This commit is contained in:
Helmut Merz 2025-04-06 22:33:16 +02:00
parent 520c89f4b2
commit 636b209e9a
2 changed files with 44 additions and 4 deletions

View file

@ -5,10 +5,49 @@
from scopes.server import auth from scopes.server import auth
from zope.authentication.interfaces import IAuthentication from zope.authentication.interfaces import IAuthentication
from zope.component import getUtility, provideUtility from zope.component import provideAdapter, getUtility, provideUtility
from zope.interface import implementer, Interface
from zope.publisher.interfaces.browser import IBrowserRequest, IBrowserPage
from zope.publisher.browser import BrowserPage
from zope.security.proxy import removeSecurityProxy
def registerAuthentication(config):
registerAuthUtility(config)
#registerAuthViews(config)
def registerAuthUtility(config): def registerAuthUtility(config):
baseAuth = getUtility(IAuthentication) baseAuth = getUtility(IAuthentication)
print('*** registerAuthUtility, baseAuth:', baseAuth) print('*** registerAuthUtility, baseAuth:', baseAuth)
provideUtility(auth.JwtAuthentication(baseAuth)) provideUtility(auth.OidcAuthentication(baseAuth))
def registerAuthViews(config):
provideAdapter(LoginView, (Interface, IBrowserRequest), IBrowserPage,
name='auth_login')
provideAdapter(callback, (Interface, IBrowserRequest), IBrowserPage,
name='auth_callback')
@implementer(IBrowserPage)
def login(context, request):
removeSecurityProxy(context)
auth.Authenticator(request).login()
return context
@implementer(IBrowserPage)
def callback(context, request):
removeSecurityProxy(context)
auth.Authenticator(request).callback()
return DummyView(context, request)
class LoginView:
def __call__(self):
auth.Authenticator(self.request).login()
return ''
class CallbackView:
def __call__(self):
auth.Authenticator(self.request).callback()
return ''

View file

@ -23,7 +23,8 @@ def main():
zope_conf = getattr(config, 'zope_conf', 'zope.conf') zope_conf = getattr(config, 'zope_conf', 'zope.conf')
print(f'starting loops server... - conf: {zope_conf}') print(f'starting loops server... - conf: {zope_conf}')
app = getWSGIApplication(zope_conf) app = getWSGIApplication(zope_conf)
auth.registerAuthUtility(config) #auth.registerAuthUtility(config)
auth.registerAuthentication(config)
run(app, config) run(app, config)
if __name__ == '__main__': if __name__ == '__main__':