work in progress: login with zitadel (Open ID Connect)
This commit is contained in:
parent
520c89f4b2
commit
636b209e9a
2 changed files with 44 additions and 4 deletions
|
@ -5,10 +5,49 @@
|
|||
|
||||
from scopes.server import auth
|
||||
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):
|
||||
baseAuth = getUtility(IAuthentication)
|
||||
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 ''
|
||||
|
|
|
@ -23,7 +23,8 @@ def main():
|
|||
zope_conf = getattr(config, 'zope_conf', 'zope.conf')
|
||||
print(f'starting loops server... - conf: {zope_conf}')
|
||||
app = getWSGIApplication(zope_conf)
|
||||
auth.registerAuthUtility(config)
|
||||
#auth.registerAuthUtility(config)
|
||||
auth.registerAuthentication(config)
|
||||
run(app, config)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Reference in a new issue