diff --git a/fabric_cm/credmgr/external_apis/ldap.py b/fabric_cm/credmgr/external_apis/ldap.py index 9433ef1..2ce27cf 100644 --- a/fabric_cm/credmgr/external_apis/ldap.py +++ b/fabric_cm/credmgr/external_apis/ldap.py @@ -65,7 +65,6 @@ def get_user_and_project_info(self, eppn: str, email: str, sub: str, project_id: ldap_search_filter = '(mail=' + email + ')' LOG.debug("ldap_host:%s", self.ldap_host) LOG.debug("ldap_user:%s", self.ldap_user) - LOG.debug("ldap_password:%s", self.ldap_password) LOG.debug("ldap_search_base:%s", self.ldap_search_base) LOG.debug("ldap_search_filter:%s", ldap_search_filter) try: diff --git a/fabric_cm/credmgr/token/token_encoder.py b/fabric_cm/credmgr/token/token_encoder.py index 91767e4..358bb2d 100644 --- a/fabric_cm/credmgr/token/token_encoder.py +++ b/fabric_cm/credmgr/token/token_encoder.py @@ -22,6 +22,7 @@ # SOFTWARE. # # Author Komal Thareja (kthare10@renci.org) +import re from datetime import datetime from dateutil import tz from fss_utils.jwt_manager import JWTManager, ValidateCode @@ -122,6 +123,14 @@ def _validate_lifetime(self, *, validity: int, roles: dict, project_id: str): return False + # Function to exclude roles with name containing UUIDs + @staticmethod + def exclude_uuid_roles(*, claims): + if "roles" in claims: + claims["roles"] = [role for role in claims["roles"] if not re.search( + r'[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}', role["name"])] + return claims + def _add_fabric_claims(self): """ Set the claims for the Token by adding membership, project and scope @@ -157,6 +166,7 @@ def _add_fabric_claims(self): self.claims[self.UUID] = uuid if self.claims.get(self.EMAIL) is None: self.claims[self.EMAIL] = email + self.exclude_uuid_roles(claims=self.claims) LOG.debug("Claims %s", self.claims) self.unset = False