From ecbd2287adff9451d46acc077a92ff72c89f24e2 Mon Sep 17 00:00:00 2001
From: Krish Moodbidri <krish94@uab.edu>
Date: Tue, 7 Jan 2025 11:44:08 -0600
Subject: [PATCH] Update Apache configuration for OOD rewrite rules during
 deploy phase
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We lookup the value of the placeholder (RewriteCond %{HTTP:REMOTE_USER}  \’^(.+)$\’) in this case in the apache conf during build and replace it with the rewrite conditions during deploy phase.
---
 ansible/roles/rewrite_map/tasks/main.yaml | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/ansible/roles/rewrite_map/tasks/main.yaml b/ansible/roles/rewrite_map/tasks/main.yaml
index 36c671a..ed79cc8 100644
--- a/ansible/roles/rewrite_map/tasks/main.yaml
+++ b/ansible/roles/rewrite_map/tasks/main.yaml
@@ -6,3 +6,11 @@
     owner: root
     group: root
     dest: /var/www/rewrite_map_config.py
+
+- name: Replace OOD rewrite placeholder in Apache configuration
+  ansible.builtin.replace:
+    path: /etc/httpd/conf.d/front-end.conf
+    regexp: "RewriteCond %{HTTP:REMOTE_USER} '\\^\\(\\.\\+\\)\\$'"
+    replace: |
+      RewriteCond %{HTTP:REMOTE_USER} '([a-zA-Z0-9_.+-]+)@uab.edu$' [OR]
+      RewriteCond %{HTTP:REMOTE_USER} 'urn:mace:incommon:uab.edu!https://uabgrid.uab.edu/shibboleth!(.+)$'
-- 
GitLab