/[smecontribs]/rpms/smeserver-userpanel/contribs8/smeserver-userpanel-0.9-logout-menu.patch
ViewVC logotype

Annotation of /rpms/smeserver-userpanel/contribs8/smeserver-userpanel-0.9-logout-menu.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Thu Nov 28 22:35:28 2013 UTC (11 years ago) by unnilennium
Branch: MAIN
CVS Tags: smeserver-userpanel-0_9-16_el5_sme, smeserver-userpanel-0_9-12_el5_sme, smeserver-userpanel-0_9-18_el5_sme, smeserver-userpanel-0_9-13_el5_sme, smeserver-userpanel-0_9-15_el5_sme, HEAD
* Thu Nov 28 2013 JP Pialasse <tests@pialasse.com>  0.9-12.sme
- NFR: logout button  [SME: 8022]
- NFR: show username [SME: 8025]
- should fix 500 error by adding action in most events [SME: 7667]
- spec file tidying

1 unnilennium 1.1 diff -Nur smeserver-userpanel-0.9-old/root/etc/e-smith/web/common/cgi-bin/logout-user smeserver-userpanel-0.9/root/etc/e-smith/web/common/cgi-bin/logout-user
2     --- smeserver-userpanel-0.9-old/root/etc/e-smith/web/common/cgi-bin/logout-user 1970-01-01 01:00:00.000000000 +0100
3     +++ smeserver-userpanel-0.9/root/etc/e-smith/web/common/cgi-bin/logout-user 2013-11-28 19:29:54.000000000 +0100
4     @@ -0,0 +1,128 @@
5     +#!/usr/bin/perl -w
6     +#
7     +# mod_auth_tkt sample logout script
8     +#
9     +# Note that this needs script needs to be available locally on all domains
10     +# if using multiple domains (unlike login.cgi, which only needs to exist
11     +# on one domain).
12     +#
13     +
14     +use File::Basename;
15     +use lib dirname($ENV{SCRIPT_FILENAME});
16     +use Apache::AuthTkt 0.03;
17     +use CGI qw(:standard);
18     +use URI::Escape;
19     +use URI;
20     +use strict;
21     +
22     +# ------------------------------------------------------------------------
23     +# Configure this section to taste
24     +
25     +# CSS stylesheet to use (optional)
26     +my $STYLESHEET = '/server-common/css/tkt.css';
27     +# Page title (optional)
28     +my $TITLE = '';
29     +# Boolean flag, whether to fallback to HTTP_REFERER for back link
30     +my $BACK_REFERER = 1;
31     +# Additional cookies to clear on logout e.g. PHPSESSID
32     +my @NUKE_COOKIES = qw();
33     +
34     +# ------------------------------------------------------------------------
35     +# Main code begins
36     +my $debug = 0;
37     +my $at = Apache::AuthTkt->new(conf => "/etc/e-smith/web/common/cgi-bin/AuthTKT.cfg");
38     +my $q = CGI->new;
39     +my ($server_name, $server_port) = split /:/, $q->http('X-Forwarded-Host') || $ENV{HTTP_HOST};
40     +#warn "servername is $server_name; HOST is $ENV{HTTP_HOST}\n";
41     +$server_name ||= $ENV{SERVER_NAME};
42     +$server_port ||= $ENV{SERVER_PORT};
43     +$server_port = '443';
44     +my $AUTH_DOMAIN = $server_name;
45     +my $back = $q->cookie($at->back_cookie_name) if $at->back_cookie_name;
46     +$back ||= $q->param($at->back_arg_name) if $at->back_arg_name;
47     +$back ||= $ENV{HTTP_REFERER} if $BACK_REFERER;
48     +$back = "/user-manager/";
49     +if ($back && $back =~ m!^/!) {
50     + my $hostname = $server_name;
51     + my $port = $server_port;
52     + $hostname .= ':' . $port if $port && $port != 80 && $port != 443;
53     + $back = sprintf "http%s://%s%s", ($port == 443 ? 's' : ''), $hostname, $back;
54     +} elsif ($back && $back !~ m/^http/i) {
55     + $back = 'http://' . $back;
56     +}
57     +$back = uri_unescape($back) if $back =~ m/^https?%3A%2F%2F/;
58     +my $back_html = escapeHTML($back) if $back;
59     +
60     +# Logout by resetting the auth cookie
61     +my @cookies = cookie(-name => $at->cookie_name, -value => '', -expires => '-1h',
62     + ($AUTH_DOMAIN && $AUTH_DOMAIN =~ /\./ ? (-domain => $AUTH_DOMAIN) : ()));
63     +push @cookies, map { cookie(-name => $_, -value => '', -expires => '-1h') } @NUKE_COOKIES;
64     +
65     +my $redirected = 0;
66     +if ($back) {
67     + my $b = URI->new($back);
68     + # If $back domain doesn't match $AUTH_DOMAIN, add ticket reset to back
69     + if ($b->host !~ m/\b$AUTH_DOMAIN$/i) {
70     + $back .= $b->query ? '&' : '?';
71     + $back .= $at->cookie_name . '=';
72     + }
73     +
74     + if ($debug) {
75     + print $q->header(-cookie => \@cookies);
76     + }
77     +
78     + else {
79     + # Set (local) cookie, and redirect to $back
80     + print $q->header(
81     + -cookie => \@cookies,
82     +# -location => $back,
83     + );
84     + # For some reason, a Location: redirect doesn't seem to then see the cookie,
85     + # but a meta refresh one does - weird
86     + print $q->start_html(
87     + -head => meta({
88     + -http_equiv => 'refresh', -content => "0;URL=$back"
89     + }));
90     + $redirected = 1;
91     + }
92     +}
93     +
94     +# If no $back, just set the auth cookie and hope for the best
95     +else {
96     + print $q->header(-cookie => \@cookies);
97     +}
98     +
99     +my @style = $STYLESHEET ? ('-style' => { src => $STYLESHEET }) : ();
100     +$TITLE ||= 'Logout Page';
101     +unless ($redirected) {
102     + # If here, either some kind of error or no back ref found
103     + print $q->start_html(
104     + -title => $TITLE,
105     + @style,
106     + );
107     + print <<EOD;
108     +<div align="center">
109     +<h1>$TITLE</h1>
110     +EOD
111     + if ($debug) {
112     + print <<EOD;
113     +<pre>
114     +back: $back
115     +back_html: $back_html
116     +</pre>
117     +EOD
118     + }
119     + print <<EOD;
120     +<p>You are now logged out.</p>
121     +EOD
122     + print qq(<p><a href="$back_html">Return to server manager login</a></p>\n) if $back_html;
123     + print <<EOD;
124     +</div>
125     +</body>
126     +</html>
127     +EOD
128     +}
129     +
130     +# arch-tag: 09c96fc6-5119-4c79-8086-6c6b24951f96
131     +# vim:sw=2:sm:cin
132     +
133     diff -Nur smeserver-userpanel-0.9-old/root/etc/e-smith/web/functions/userpanel-navigation.logout-menu smeserver-userpanel-0.9-old/root/etc/e-smith/web/functions/userpanel-navigation
134     --- smeserver-userpanel-0.9-old/root/etc/e-smith/web/functions/userpanel-navigation.logout-menu 2013-11-28 15:56:16.000000000 -0500
135     +++ smeserver-userpanel-0.9-old/root/etc/e-smith/web/functions/userpanel-navigation 2013-11-28 16:34:57.000000000 -0500
136     @@ -67,8 +67,40 @@
137     my $q = new CGI;
138    
139     showNavigation ($q);
140     +logmeout($q);
141     +
142     exit (0);
143    
144     +#------------------------------------------------------
145     +# subroutine to print logout
146     +#------------------------------------------------------
147     +sub logmeout ($)
148     +{
149     +my $user = $ENV{'REMOTE_USER'};
150     +
151     +print <<EOF;
152     +<table width="100%" border="0" cellspacing="0" cellpadding="0">
153     + <tr>
154     + <td align=left nowrap class="infobar">
155     + <img src="/server-common/spacer.gif" height="14" width="1" align="left">
156     + </td>
157     + <td align=left nowrap class="infobar">
158     + $user
159     + </td>
160     +</tr>
161     + <tr>
162     + <td align=left nowrap class="infobar">
163     + <img src="/server-common/spacer.gif" height="14" width="1" align="left">
164     + </td>
165     + <td align=left nowrap class="infobar">
166     + <a target="_parent" href="/server-common/cgi-bin/logout-user"><b>Logout</b></a></td>
167     +
168     + </tr>
169     +</table>
170     +EOF
171     +
172     +
173     +}
174    
175     #------------------------------------------------------
176     # subroutine to determine which group a user belongs to

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed