View | Details | Raw Unified | Return to bug 5630
Collapse All | Expand All

(-)a/C4/Auth.pm (-5 / +26 lines)
Lines 943-954 sub checkauth { Link Here
943
    $template->param( OpacPublic => C4::Context->preference("OpacPublic"));
943
    $template->param( OpacPublic => C4::Context->preference("OpacPublic"));
944
    $template->param( loginprompt => 1 ) unless $info{'nopermission'};
944
    $template->param( loginprompt => 1 ) unless $info{'nopermission'};
945
945
946
    if ($cas) { 
946
    if ($cas) {
947
948
	# Is authentication against multiple CAS servers enabled?
949
950
        if (C4::Auth_with_cas::multipleAuth && !$casparam) {
951
	    my $casservers = C4::Auth_with_cas::getMultipleAuth();		    
952
#	    warn Data::Dumper::Dumper($casservers);
953
	    my @tmplservers;
954
	    foreach my $key (keys %$casservers) {
955
	    warn $key, $casservers->{$key};
956
		push @tmplservers, {name => $key, value => login_cas_url($query, $key)};
957
	    }
958
	    #warn Data::Dumper::Dumper(\@tmplservers);
959
	    $template->param(
960
		casServersLoop => \@tmplservers
961
	    );
962
	} else {
963
        $template->param(
964
            casServerUrl    => login_cas_url($query),
965
	    );
966
	}
967
947
	$template->param(
968
	$template->param(
948
        casServerUrl    => login_cas_url($query),
969
            invalidCasLogin => $info{'invalidCasLogin'}
949
	    invalidCasLogin => $info{'invalidCasLogin'}
970
        );
950
	);
971
    }
951
   }
972
952
    my $self_url = $query->url( -absolute => 1 );
973
    my $self_url = $query->url( -absolute => 1 );
953
    $template->param(
974
    $template->param(
954
        url         => $self_url,
975
        url         => $self_url,
(-)a/C4/Auth_with_cas.pm (-5 / +16 lines)
Lines 40-50 BEGIN { Link Here
40
my $context = C4::Context->new() or die 'C4::Context->new failed';
40
my $context = C4::Context->new() or die 'C4::Context->new failed';
41
my $defaultcasserver;
41
my $defaultcasserver;
42
my $casservers;
42
my $casservers;
43
my $yamlauthfile = "../C4/Auth_cas_servers.yaml";
43
44
44
45
45
# If there's a configuration for multiple cas servers, then we get it
46
# If there's a configuration for multiple cas servers, then we get it
46
if (-e qq($FindBin::Bin/../C4/Auth_cas_servers.yaml)) {
47
if (multipleAuth()) {
47
    ($defaultcasserver, $casservers) = YAML::LoadFile(qq($FindBin::Bin/../C4/Auth_cas_servers.yaml));
48
    ($defaultcasserver, $casservers) = YAML::LoadFile(qq($FindBin::Bin/$yamlauthfile));
48
    $defaultcasserver = $defaultcasserver->{'default'};
49
    $defaultcasserver = $defaultcasserver->{'default'};
49
} else {
50
} else {
50
# Else, we fall back to casServerUrl syspref
51
# Else, we fall back to casServerUrl syspref
Lines 52-57 if (-e qq($FindBin::Bin/../C4/Auth_cas_servers.yaml)) { Link Here
52
    $casservers = { 'default' => C4::Context->preference('casServerUrl') };
53
    $casservers = { 'default' => C4::Context->preference('casServerUrl') };
53
}
54
}
54
55
56
# Is there a configuration file for multiple cas servers?
57
sub multipleAuth {
58
    return (-e qq($FindBin::Bin/$yamlauthfile));
59
}
60
61
# Returns configured CAS servers' list if multiple authentication is enabled
62
sub getMultipleAuth {
63
   return $casservers; 
64
}
65
55
# Logout from CAS
66
# Logout from CAS
56
sub logout_cas {
67
sub logout_cas {
57
    my ($query) = @_;
68
    my ($query) = @_;
Lines 71-77 sub login_cas { Link Here
71
    my $casparam = $query->param('cas');
82
    my $casparam = $query->param('cas');
72
    # FIXME: This should be more generic and handle whatever parameters there might be
83
    # FIXME: This should be more generic and handle whatever parameters there might be
73
    $uri .= "?cas=" . $casparam if (defined $casparam);
84
    $uri .= "?cas=" . $casparam if (defined $casparam);
74
    warn $defaultcasserver;
75
    $casparam = $defaultcasserver if (not defined $casparam);
85
    $casparam = $defaultcasserver if (not defined $casparam);
76
    my $cas = Authen::CAS::Client->new($casservers->{$casparam});
86
    my $cas = Authen::CAS::Client->new($casservers->{$casparam});
77
    print $query->redirect( $cas->login_url($uri));
87
    print $query->redirect( $cas->login_url($uri));
Lines 79-91 sub login_cas { Link Here
79
89
80
# Returns CAS login URL with callback to the requesting URL
90
# Returns CAS login URL with callback to the requesting URL
81
sub login_cas_url {
91
sub login_cas_url {
82
    my ($query) = @_;
92
93
    my ($query, $key) = @_;
83
    my $uri = $ENV{'SCRIPT_URI'};
94
    my $uri = $ENV{'SCRIPT_URI'};
84
    my $casparam = $query->param('cas');
95
    my $casparam = $query->param('cas');
85
    # FIXME: This should be more generic and handle whatever parameters there might be
96
    # FIXME: This should be more generic and handle whatever parameters there might be
86
    $uri .= "?cas=" . $casparam if (defined $casparam);
97
    $uri .= "?cas=" . $casparam if (defined $casparam);
87
    $casparam = $defaultcasserver if (not defined $casparam);
98
    $casparam = $defaultcasserver if (not defined $casparam);
88
    warn $defaultcasserver;
99
    $casparam = $key if (defined $key);
89
    my $cas = Authen::CAS::Client->new($casservers->{$casparam});
100
    my $cas = Authen::CAS::Client->new($casservers->{$casparam});
90
    return $cas->login_url($uri);
101
    return $cas->login_url($uri);
91
}
102
}
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth.tmpl (-2 / +13 lines)
Lines 53-59 Link Here
53
<p>Sorry, the CAS login failed.</p>
53
<p>Sorry, the CAS login failed.</p>
54
<!-- /TMPL_IF -->
54
<!-- /TMPL_IF -->
55
55
56
<p>If you have a <acronym title="Central Authentication Service">CAS</acronym> account, please <a href="<!-- TMPL_VAR NAME="casServerUrl" -->">click here to login</a>.<p>
56
<p>If you have a <acronym title="Central Authentication Service">CAS</acronym> account, 
57
<!-- TMPL_IF name="casServerUrl" -->
58
    please <a href="<!-- TMPL_VAR NAME="casServerUrl" -->">click here to login</a>.<p>
59
<!-- /TMPL_IF -->
60
61
<!-- TMPL_IF name="casServersLoop" -->
62
please choose against which one you would like to authenticate: </p>
63
<ul>
64
    <!-- TMPL_LOOP name="casServersLoop" -->
65
	<li><a href="<!-- TMPL_VAR name="value" -->"><!-- TMPL_VAR name="name" --></a></li>
66
    <!-- /TMPL_LOOP -->
67
<!-- /TMPL_IF -->
68
</ul>
57
69
58
<h4>Local Login</h4>
70
<h4>Local Login</h4>
59
<p>If you do not have a CAS account, but a local account, you can still log in : </p>
71
<p>If you do not have a CAS account, but a local account, you can still log in : </p>
60
- 

Return to bug 5630