From f22dbba9316ac61f186fb7a75a9bbef1c7dd0925 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 13 Dec 2019 13:45:10 +0100 Subject: [PATCH] providers/saml: add UID field --- docs/providers.md | 7 +++++++ passbook/providers/saml/base.py | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/docs/providers.md b/docs/providers.md index 8e896e402..dcefde902 100644 --- a/docs/providers.md +++ b/docs/providers.md @@ -14,3 +14,10 @@ The API exposes Username, E-Mail, Name and Groups in a GitHub-compatible format. ## SAML Provider This provider allows you to integrate Enterprise Software using the SAML2 Protocol. It supports signed Requests. This Provider also has [Property Mappings](property-mappings.md#saml-property-mapping), which allows you to expose Vendor-specific Fields. +Default fields are: + +- `eduPersonPrincipalName`: User's E-Mail +- `cn`: User's Full Name +- `mail`: User's E-Mail +- `displayName`: User's Username +- `uid`: User Unique Identifier diff --git a/passbook/providers/saml/base.py b/passbook/providers/saml/base.py index e70329c4f..84178f4d1 100644 --- a/passbook/providers/saml/base.py +++ b/passbook/providers/saml/base.py @@ -143,6 +143,7 @@ class Processor: def _format_assertion(self): """Formats _assertion_params as _assertion_xml.""" + # https://commons.lbl.gov/display/IDMgmt/Attribute+Definitions self._assertion_params['ATTRIBUTES'] = [ { 'FriendlyName': 'eduPersonPrincipalName', @@ -164,6 +165,11 @@ class Processor: 'Name': 'urn:oid:2.16.840.1.113730.3.1.241', 'Value': self._django_request.user.username, }, + { + 'FriendlyName': 'uid', + 'Name': 'urn:oid:0.9.2342.19200300.100.1.1', + 'Value': self._django_request.user.pk, + }, ] from passbook.providers.saml.models import SAMLPropertyMapping for mapping in self._remote.property_mappings.all().select_subclasses():