work in progress: create external (zitadel) users: prepare for testing, start implementation in loops.organize.party

This commit is contained in:
Helmut Merz 2025-08-08 23:18:18 +02:00
parent 1e044e7aef
commit cab2d09737
4 changed files with 19 additions and 2 deletions

View file

@ -80,6 +80,10 @@ class Person(AdapterBase, BasePerson):
_adapterAttributes = ('context', '__parent__', 'userId', 'phoneNumbers') _adapterAttributes = ('context', '__parent__', 'userId', 'phoneNumbers')
_contextAttributes = list(IPerson) + list(IConcept) _contextAttributes = list(IPerson) + list(IConcept)
def createExtUser(self, userId):
from scopes.org import user
#print('*** Person.createExtUser', userId)
def getUserId(self): def getUserId(self):
return getattr(self.context, '_userId', None) return getattr(self.context, '_userId', None)
def setUserId(self, userId): def setUserId(self, userId):
@ -111,6 +115,8 @@ class Person(AdapterBase, BasePerson):
self.context._userId = userId self.context._userId = userId
setter.propagateSecurity() setter.propagateSecurity()
allowEditingForOwner(self.context, revert=not userId) # why this? allowEditingForOwner(self.context, revert=not userId) # why this?
if not oldUserId:
self.createExtUser(userId)
userId = property(getUserId, setUserId) userId = property(getUserId, setUserId)
def removeReferenceFromPrincipal(self, userId): def removeReferenceFromPrincipal(self, userId):

View file

@ -1,5 +1,9 @@
# loops.organize.tests # loops.organize.tests
import os, sys
#sys.path = [os.path.dirname(__file__)] + sys.path
sys.path = ['loops/tests'] + sys.path
import unittest, doctest import unittest, doctest
from zope.interface.verify import verifyClass from zope.interface.verify import verifyClass

View file

@ -27,7 +27,8 @@ class LoginView:
class CallbackView: class CallbackView:
def __call__(self): def __call__(self):
oidc.Authenticator(self.request).callback() oidc.Authenticator(
self.request).callback(groupsProvider=self.getGroupsForPrincipal)
return '' return ''
def getGroupsForPrincipal(self, prcId): def getGroupsForPrincipal(self, prcId):

View file

@ -20,8 +20,14 @@ dbschema = getenv('DBSCHEMA', 'demo')
base_url = 'test://' base_url = 'test://'
# special testing stuff
from scopes.tests import data_auth # add oidc URIs and keys to dummy_requests data
from scopes.tests import dummy_requests
import sys
sys.modules['requests'] = dummy_requests
# authentication settings # authentication settings
oidc_provider = '' oidc_provider = 'test://oidc'
oidc_client_id = getenv('OIDC_CLIENT_ID', '12345') oidc_client_id = getenv('OIDC_CLIENT_ID', '12345')
oidc_params = dict( oidc_params = dict(
op_config_url=oidc_provider + '/.well-known/openid-configuration', op_config_url=oidc_provider + '/.well-known/openid-configuration',