def setup_idxs(cls): cls.by_profile_field_name = {} for key, mapping in ATTRIBUTE_MAPPING.iteritems(): if mapping.get('profile_field_name'): l = cls.by_profile_field_name.setdefault(mapping['profile_field_name'], []) l.append(key)
def get_definition_from_alias(alias): if not alias: return None for def_name, content in ATTRIBUTE_MAPPING.items(): if 'alias' in content: if alias in content['alias']: return ATTRIBUTE_MAPPING[def_name] return None
def get_definition_from_oid(oid): if not oid: return None for def_name, content in ATTRIBUTE_MAPPING.items(): if 'oid' in content: if content['oid'] == oid: return ATTRIBUTE_MAPPING[def_name] return None
def get_definition_from_profile_field_name(field_name): if not field_name: return None for def_name, content in ATTRIBUTE_MAPPING.items(): if 'profile_field_name' in content: if field_name == content['profile_field_name']: return def_name return None
def get_def_name_from_name_and_ns_of_attribute(name, namespace): if not name or not namespace: return None for def_name, content in ATTRIBUTE_MAPPING.items(): if "namespaces" in content \ and namespace in content["namespaces"].keys(): if name in content["namespaces"][namespace]["identifiers"]: return def_name if name in content["namespaces"][namespace]["friendly_names"]: return def_name return None
def get_all_attribute_definitions(): return ATTRIBUTE_MAPPING.keys()
from django.db import models from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic from django.utils.translation import ugettext_lazy as _ from django.conf import settings from authentic2.attribute_aggregator.mapping_loader import ATTRIBUTE_MAPPING, \ ATTRIBUTE_NAMESPACES from authentic2.attribute_aggregator.models import AttributeSource ATTRIBUTES = [(key, key) \ for key in sorted(ATTRIBUTE_MAPPING.iterkeys())] ATTRIBUTES_NS = [('Default', 'Default')] \ + [(ns, ns) for ns in ATTRIBUTE_NAMESPACES] ATTRIBUTE_VALUE_FORMATS = ( (lasso.SAML2_ATTRIBUTE_NAME_FORMAT_URI, 'SAMLv2 URI'), (lasso.SAML2_ATTRIBUTE_NAME_FORMAT_BASIC, 'SAMLv2 BASIC')) def set_user_consent_attributes(user, provider, attributes): if not user or not provider: return None return UserConsentAttributes.objects.get_or_create(user=user, object_id=provider.id, content_type=ContentType.objects.get_for_model(provider))