-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWeb.pm.patch
More file actions
61 lines (57 loc) · 2.19 KB
/
Web.pm.patch
File metadata and controls
61 lines (57 loc) · 2.19 KB
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
--- Web_orig.pm 2017-03-15 14:25:44.000000000 +0000
+++ Web.pm 2017-04-11 08:37:02.137167486 +0000
@@ -226,6 +226,21 @@
return RequestENV('REMOTE_USER') ? lc RequestENV('REMOTE_USER') : RequestENV('REMOTE_USER');
}
+sub utf8_fix {
+
+ my $string = shift;
+
+ # If reasonably sure it's not utf8 already; convert it, else just pass through
+ if ( !utf8::is_utf8($string) and utf8::valid($string) ) {
+ $RT::Logger->debug("String before decode: $string\n");
+ utf8::decode($string);
+ $RT::Logger->debug("String after decode: $string\n");
+ return $string;
+ } else {
+ return $string;
+ }
+
+}
=head2 WebRemoteUserAutocreateInfo($user);
@@ -252,6 +267,36 @@
$user_info{'Comments'} = $comments if defined $comments;
$user_info{'RealName'} = $realname if defined $realname;
+ # So this is experimental support for Shibboleth; get and populate
+ # RT-fields with attributes set in environment variables from Shib
+ # ...or any other source that sends REMOTE_USER data at user create.
+ if (RT->Config->Get('WebRemoteUser')) {
+
+ my $settings = RT->Config->Get('ExternalSettingsRemoteUser');
+ my $config = $settings->{'RemoteUser'};
+
+
+ if ($config->{'type'} eq 'shib') {
+ for (keys(%{$config->{attr_map}})) {
+ my $rtVar = $_;
+ my @envVar = @{ $config->{attr_map}->{$_} };
+ for(my $i=0; $i < scalar(@envVar); $i++) {
+ my $value = RequestENV("$envVar[$i]");
+ $RT::Logger->debug("Found header: $envVar[$i] Mapped to RT variable: $rtVar \n");
+ # Make sure header is not empty before adding it, if empty; see if there's another mapping
+ if ((defined($value) and length($value)) and (not defined($user_info{"$rtVar"}))) {
+ $value = utf8_fix("$value");
+ $user_info{"$rtVar"} = $value;
+ $RT::Logger->debug("RT variable $rtVar set to $value taken from header $envVar[$i]\n");
+ } elsif (defined($user_info{"$rtVar"})) {
+ $RT::Logger->debug("RT variable $rtVar is already set to $user_info{\"$rtVar\"} so skipping header $envVar[$i]\n");
+ }
+ }
+ }
+
+ }
+ }
+
# and return the wad of stuff
return {%user_info};
}