Forked from
DM / dm-docs
261 commits behind, 863 commits ahead of the upstream repository.
-
sveseli authored
moved common authorization/authentication classes into their own module to better reflect their functionality; added checks for admin role name into principal retrievers
sveseli authoredmoved common authorization/authentication classes into their own module to better reflect their functionality; added checks for admin role name into principal retrievers
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
cryptedPasswordPrincipalAuthenticator.py 1.14 KiB
#!/usr/bin/env python
from dm.common.utility.cryptUtility import CryptUtility
from authorizationPrincipalAuthenticator import AuthorizationPrincipalAuthenticator
class CryptedPasswordPrincipalAuthenticator(AuthorizationPrincipalAuthenticator):
def __init__(self):
AuthorizationPrincipalAuthenticator.__init__(self, self.__class__.__name__)
def authenticatePrincipal(self, principal, password):
if principal is not None:
principalToken = principal.getToken()
if principalToken is not None and len(principalToken):
if CryptUtility.verifyPasswordWithPbkdf2(password, principalToken):
self.logger.debug('Authentication successful for %s' % principal.getName())
return principal
else:
self.logger.debug('Authentication failed for %s' % principal.getName())
else:
self.logger.debug('Token is empty for %s, authentication not performed' % principal.getName())
return None
#######################################################################
# Testing.
if __name__ == '__main__':
pass