grim/containers/reviewboard

cd6e1e51c0bf
Parents e1aaae52c85e
Children c69a17f8c13e
Add a patch to support a User.FullName SAML assertion
--- a/Dockerfile Fri Sep 23 23:01:34 2022 -0500
+++ b/Dockerfile Sat Sep 24 01:06:08 2022 -0500
@@ -21,6 +21,11 @@
RUN set -ex && \
pip install --no-cache rbjbhub ReviewBoard[saml]
+COPY saml-fullname.patch /
+RUN set -ex && \
+ cd /venv/lib/python3.8/site-packages && \
+ patch -p1 < /saml-fullname.patch
+
FROM docker.io/nginx:1.21 AS nginx
COPY --from=app /venv/lib/python3.8/site-packages/reviewboard/htdocs /var/www/reviewboard/htdocs/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/saml-fullname.patch Sat Sep 24 01:06:08 2022 -0500
@@ -0,0 +1,31 @@
+diff --git a/reviewboard/accounts/sso/backends/saml/views.py b/reviewboard/accounts/sso/backends/saml/views.py
+index 5b6397a1b..f792d8dca 100644
+--- a/reviewboard/accounts/sso/backends/saml/views.py
++++ b/reviewboard/accounts/sso/backends/saml/views.py
+@@ -328,6 +328,26 @@ class SAMLACSView(SAMLViewMixin, BaseSSOView):
+ if value and isinstance(value, list):
+ return value[0]
+
++ if key in ('User.FirstName', 'User.LastName'):
++ try:
++ fullname = self._get_user_attr_value(auth, 'User.FullName')
++ except KeyError:
++ # Just raise the KeyError with the original key, as
++ # KeyError.__str__ will quote the entire parameter. So if we
++ # tried to append 'User.FUllName` we would output something like
++ # "'User.FullName or User.LastName'" instead of
++ # "'User.FullName' or 'User.LastName'".
++ raise KeyError(key)
++
++ # we don't have a good way to split the username to a first
++ # name/last name, so we split on the first space and then treat the
++ # two parts as the first and last names.
++ name_parts = fullname.split(' ', 1)
++ if key == 'User.FirstName':
++ return name_parts[0]
++ else:
++ return len(name_parts) > 1 and name_parts[1] or ''
++
+ raise KeyError(key)
+
+