summaryrefslogtreecommitdiff
path: root/www/ap2-auth-mellon/patches/patch-af
blob: 59bbf9caefb5b117c27b5785befd91d49819e8a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
$NetBSD: patch-af,v 1.1 2011/04/04 08:46:42 manu Exp $

Make remapped attribute usable for MellonUser

--- auth_mellon_cache.c.orig	2011-02-28 17:12:42.000000000 +0100
+++ auth_mellon_cache.c	2011-02-28 17:59:02.000000000 +0100
@@ -367,21 +367,8 @@
             }
         }
     }
 
-    if(t->user[0] != '\0') {
-        /* We have a user-"name". Set r->user and r->ap_auth_type. */
-        r->user = apr_pstrdup(r->pool, t->user);
-        r->ap_auth_type = apr_pstrdup(r->pool, "Mellon");
-    } else {
-        /* We don't have a user-"name". Log error. */
-        ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r,
-                      "Didn't find the attribute \"%s\" in the attributes"
-                      " which were received from the IdP. Cannot set a user"
-                      " for this request without a valid user attribute.",
-                      d->userattr);
-    }
-
     /* Allocate a set of counters for duplicate variables in the list. */
     counters = apr_hash_make(r->pool);
 
     /* Populate the subprocess environment with the attributes we
@@ -398,8 +385,13 @@
         }
 
         value = t->env[i].value;
 
+        /*  
+         * If we find a variable remapping to MellonUser, use it.
+         */
+        if ((t->user[0] == '\0') && (strcmp(varname, d->userattr) == 0))
+            strcpy(t->user, value);
 
         /* Find the number of times this variable has been set. */
         count = apr_hash_get(counters, varname, APR_HASH_KEY_STRING);
         if(count == NULL) {
@@ -425,8 +417,22 @@
         /* Increase the count. */
         ++(*count);
     }
 
+    if(t->user[0] != '\0') {
+        /* We have a user-"name". Set r->user and r->ap_auth_type. */
+        r->user = apr_pstrdup(r->pool, t->user);
+        r->ap_auth_type = apr_pstrdup(r->pool, "Mellon");
+    } else {
+        /* We don't have a user-"name". Log error. */
+        ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r,
+                      "Didn't find the attribute \"%s\" in the attributes"
+                      " which were received from the IdP. Cannot set a user"
+                      " for this request without a valid user attribute.",
+                      d->userattr);
+    }
+
+
     /* Populate with the session? */
     if (d->dump_session) {
         char *session;
         int srclen, dstlen;