work in progress: oidc authentication: start login processing
This commit is contained in:
		
							parent
							
								
									3e25b5e593
								
							
						
					
					
						commit
						87c0c1db2e
					
				
					 5 changed files with 32 additions and 7 deletions
				
			
		|  | @ -18,3 +18,7 @@ dbuser = getenv('DBUSER', 'demo') | ||||||
| dbpassword = getenv('DBPASSWORD', 'secret') | dbpassword = getenv('DBPASSWORD', 'secret') | ||||||
| dbschema = getenv('DBSCHEMA', 'demo') | dbschema = getenv('DBSCHEMA', 'demo') | ||||||
| 
 | 
 | ||||||
|  | # authentication settings | ||||||
|  | oidc_params = dict( | ||||||
|  |     clientid=getenv('OIDC_CLIENTID', '311613119816392525') | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | @ -17,7 +17,6 @@ def run(app, config): | ||||||
| 
 | 
 | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     import config |     import config | ||||||
|     #run(config.app, config) |  | ||||||
|     app = config.app_factory(config) |     app = config.app_factory(config) | ||||||
|     run(app, config) |     run(app, config) | ||||||
|     # see zope.app.wsgi.getWSGIApplication |     # see zope.app.wsgi.getWSGIApplication | ||||||
|  |  | ||||||
|  | @ -7,6 +7,8 @@ from zope.publisher.interfaces import Unauthorized | ||||||
| from scopes.server.browser import DefaultView, register | from scopes.server.browser import DefaultView, register | ||||||
| from scopes.storage.folder import DummyFolder, Root | from scopes.storage.folder import DummyFolder, Root | ||||||
| 
 | 
 | ||||||
|  | import config | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| def authenticate(request): | def authenticate(request): | ||||||
|     #print('*** authenticate') |     #print('*** authenticate') | ||||||
|  | @ -21,6 +23,7 @@ class OidcAuthentication: | ||||||
| 
 | 
 | ||||||
|     def authenticate(self, request): |     def authenticate(self, request): | ||||||
|         prc = authenticate(request) |         prc = authenticate(request) | ||||||
|  |         # prc = Authenticator().authenticate(request) | ||||||
|         if prc is None and self.baseAuth is not None: |         if prc is None and self.baseAuth is not None: | ||||||
|             prc = self.baseAuth.authenticate(request) |             prc = self.baseAuth.authenticate(request) | ||||||
|         return prc |         return prc | ||||||
|  | @ -38,21 +41,40 @@ class OidcAuthentication: | ||||||
|             return self.baseAuth.unauthorized(id, request) |             return self.baseAuth.unauthorized(id, request) | ||||||
| 
 | 
 | ||||||
|     def logout(self, request): |     def logout(self, request): | ||||||
|         print('*** JwtAuthentication: logout') |         print('*** OidcAuthentication: logout') | ||||||
| 
 | 
 | ||||||
| JwtAuthentication = OidcAuthentication  # old name - still used? | JwtAuthentication = OidcAuthentication  # old name - still used? | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class Authenticator(DummyFolder): | class Authenticator(DummyFolder): | ||||||
|  | 
 | ||||||
|     prefix = 'auth' |     prefix = 'auth' | ||||||
| 
 | 
 | ||||||
|  |     def authenticate(request): | ||||||
|  |         return None | ||||||
|  | 
 | ||||||
|  |     def login(self, request): | ||||||
|  |         params = config.oidc_params | ||||||
|  |         print('*** login', self, request.getTraversalStack(), request['PATH_INFO']) | ||||||
|  |         print('***', dir(request)) | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| @register('auth', Root) | @register('auth', Root) | ||||||
| def authView(context, request): | def authView(context, request): | ||||||
|     print('*** auth', context, request['PATH_INFO'], request.getTraversalStack()) |     print('*** auth', context, request['PATH_INFO']) | ||||||
|     return Authenticator() |     return Authenticator() | ||||||
| 
 | 
 | ||||||
| @register('login', Authenticator) | @register('login', Authenticator) | ||||||
| def login(context, request): | def login(context, request): | ||||||
|     print('*** login', context, request['PATH_INFO'], request.getTraversalStack()) |     context.login(request) | ||||||
|  |     return DefaultView(context, request) | ||||||
|  | 
 | ||||||
|  | @register('callback', Authenticator) | ||||||
|  | def login(context, request): | ||||||
|  |     print('*** callback', context, request['PATH_INFO'], request.getTraversalStack()) | ||||||
|  |     return DefaultView(context, request) | ||||||
|  | 
 | ||||||
|  | @register('logout', Authenticator) | ||||||
|  | def login(context, request): | ||||||
|  |     print('*** logout', context, request['PATH_INFO'], request.getTraversalStack()) | ||||||
|     return DefaultView(context, request) |     return DefaultView(context, request) | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ class DummyFolder(dict): | ||||||
|         return self |         return self | ||||||
| 
 | 
 | ||||||
|     def __repr__(self): |     def __repr__(self): | ||||||
|         return '%s: %s' % (self.__class__.__name__,  |         return '<%s: %s>' % (self.__class__.__name__,  | ||||||
|                              super(DummyFolder, self).__repr__()) |                              super(DummyFolder, self).__repr__()) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -67,7 +67,7 @@ class Track(object): | ||||||
|         return str(self.trackId) |         return str(self.trackId) | ||||||
| 
 | 
 | ||||||
|     def __repr__(self): |     def __repr__(self): | ||||||
|         return '%s: %s' % (self.__class__.__name__, self.asDict()) |         return '<%s: %s>' % (self.__class__.__name__, self.asDict()) | ||||||
| 
 | 
 | ||||||
|     def asDict(self): |     def asDict(self): | ||||||
|         return dict(uid=self.uid, head=self.head, data=self.data,  |         return dict(uid=self.uid, head=self.head, data=self.data,  | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue