Compare commits
	
		
			2 commits
		
	
	
		
			ab050ba360
			...
			eaa2055c76
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| eaa2055c76 | |||
| a3da3f07f0 | 
					 2 changed files with 45 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -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
									
								
							
							
						
						
									
										38
									
								
								scopes/server/auth.py
									
										
									
									
									
										Normal 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)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	Add table
		
		Reference in a new issue