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

(-)a/C4/Auth.pm (-8 / +3 lines)
Lines 54-60 BEGIN { Link Here
54
    %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
54
    %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
55
    $ldap        = C4::Context->config('useldapserver') || 0;
55
    $ldap        = C4::Context->config('useldapserver') || 0;
56
    $cas         = C4::Context->preference('casAuthentication');
56
    $cas         = C4::Context->preference('casAuthentication');
57
    $shib        = C4::Context->preference('shibbolethAuthentication');
57
    $shib        = C4::Context->config('useshibboleth') || 0;
58
    $caslogout   = C4::Context->preference('casLogout');
58
    $caslogout   = C4::Context->preference('casLogout');
59
    require C4::Auth_with_cas;             # no import
59
    require C4::Auth_with_cas;             # no import
60
    require C4::Auth_with_Shibboleth;
60
    require C4::Auth_with_Shibboleth;
Lines 805-811 sub checkauth { Link Here
805
            || $userid
805
            || $userid
806
            || $shib
806
            || $shib
807
            || $pki_field ne 'None'
807
            || $pki_field ne 'None'
808
	    || $persona )
808
            || $persona )
809
        {
809
        {
810
            my $password = $query->param('password');
810
            my $password = $query->param('password');
811
811
Lines 1063-1069 sub checkauth { Link Here
1063
        login                => 1,
1063
        login                => 1,
1064
        INPUTS               => \@inputs,
1064
        INPUTS               => \@inputs,
1065
        casAuthentication    => C4::Context->preference("casAuthentication"),
1065
        casAuthentication    => C4::Context->preference("casAuthentication"),
1066
        shibbolethAuthentication => C4::Context->preference("shibbolethAuthentication"),
1066
        shibbolethAuthentication => $shib,
1067
        suggestion           => C4::Context->preference("suggestion"),
1067
        suggestion           => C4::Context->preference("suggestion"),
1068
        virtualshelves       => C4::Context->preference("virtualshelves"),
1068
        virtualshelves       => C4::Context->preference("virtualshelves"),
1069
        LibraryName          => "" . C4::Context->preference("LibraryName"),
1069
        LibraryName          => "" . C4::Context->preference("LibraryName"),
Lines 1581-1591 sub checkpw { Link Here
1581
        # (defined in the shibbolethLoginAttribute) tto contain the login of the
1581
        # (defined in the shibbolethLoginAttribute) tto contain the login of the
1582
        # shibboleth-authenticated user
1582
        # shibboleth-authenticated user
1583
1583
1584
        # Shibboleth attributes are mapped into http environmement variables,
1585
        # so we're getting the login of the user this way
1586
        my $attributename = C4::Context->preference('shibbolethLoginAttribute');
1587
        my $attributevalue = $ENV{$attributename};
1588
1589
        # Then, we check if it matches a valid koha user
1584
        # Then, we check if it matches a valid koha user
1590
        if ($shib_login) {
1585
        if ($shib_login) {
1591
            my ( $retval, $retcard, $retuserid ) = C4::Auth_with_Shibboleth::checkpw_shib( $dbh, $shib_login );    # EXTERNAL AUTH
1586
            my ( $retval, $retcard, $retuserid ) = C4::Auth_with_Shibboleth::checkpw_shib( $dbh, $shib_login );    # EXTERNAL AUTH
(-)a/C4/Auth_with_Shibboleth.pm (-3 / +8 lines)
Lines 22-27 use warnings; Link Here
22
22
23
use C4::Debug;
23
use C4::Debug;
24
use C4::Context;
24
use C4::Context;
25
use Carp;
25
use CGI;
26
use CGI;
26
27
27
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug);
28
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug);
Lines 64-74 sub get_login_shib { Link Here
64
    # Shibboleth attributes are mapped into http environmement variables,
65
    # Shibboleth attributes are mapped into http environmement variables,
65
    # so we're getting the login of the user this way
66
    # so we're getting the login of the user this way
66
67
67
    my $shibbolethLoginAttribute = C4::Context->preference('shibbolethLoginAttribute');
68
    my $shib = C4::Context->config('shibboleth') or croak 'No <shibboleth> in koha-conf.xml';
68
    $debug and warn "shibbolethLoginAttribute value: $shibbolethLoginAttribute";
69
70
    my $shibbolethLoginAttribute = $shib->{'userid'};
71
    $debug and warn "shibboleth->userid value: $shibbolethLoginAttribute";
69
    $debug and warn "$shibbolethLoginAttribute value: " . $ENV{$shibbolethLoginAttribute};
72
    $debug and warn "$shibbolethLoginAttribute value: " . $ENV{$shibbolethLoginAttribute};
70
73
71
    return $ENV{$shibbolethLoginAttribute};
74
    return $ENV{$shibbolethLoginAttribute} || '';
72
}
75
}
73
76
74
# Checks for password correctness
77
# Checks for password correctness
Lines 80-85 sub checkpw_shib { Link Here
80
    my $retnumber;
83
    my $retnumber;
81
    $debug and warn "User Shibboleth-authenticated as: $userid";
84
    $debug and warn "User Shibboleth-authenticated as: $userid";
82
85
86
    my $shib = C4::Context->config('shibboleth') or croak 'No <shibboleth> in koha-conf.xml';
87
83
    # Does it match one of our users ?
88
    # Does it match one of our users ?
84
    my $sth = $dbh->prepare("select cardnumber from borrowers where userid=?");
89
    my $sth = $dbh->prepare("select cardnumber from borrowers where userid=?");
85
    $sth->execute($userid);
90
    $sth->execute($userid);
(-)a/installer/data/mysql/updatedatabase.pl (-8 lines)
Lines 8056-8069 if ( CheckVersion($DBversion) ) { Link Here
8056
   SetVersion ($DBversion);
8056
   SetVersion ($DBversion);
8057
}
8057
}
8058
8058
8059
$DBversion = "XXX";
8060
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
8061
    $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('shibbolethAuthentication','','','Enable or disable Shibboleth authentication','YesNo')");
8062
    $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('shibbolethLoginAttribute','','','Which shibboleth user attribute should be used to match koha user login?','')");
8063
    print "Upgrade to $DBversion done (Adds shibbolethAuthentication and shibbolethLoginAttribute preferences)\n";
8064
    SetVersion ($DBversion);
8065
}
8066
8067
=head1 FUNCTIONS
8059
=head1 FUNCTIONS
8068
8060
8069
=head2 TableExists($table)
8061
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (-11 lines)
Lines 105-121 Administration: Link Here
105
                  yes: Allow
105
                  yes: Allow
106
                  no: "Don't Allow"
106
                  no: "Don't Allow"
107
            - Mozilla persona for login
107
            - Mozilla persona for login
108
    Shibboleth Authentication:
109
        -
110
            - pref: shibbolethAuthentication
111
              default: 0
112
              choices:
113
                  yes: Use
114
                  no: "Don't use"
115
            - Shibboleth for login authentication.
116
        -
117
            - Which shibboleth user attribute should be used to match koha user login?
118
            - pref: shibbolethLoginAttribute
119
    Search Engine:
108
    Search Engine:
120
        -
109
        -
121
            - pref: SearchEngine
110
            - pref: SearchEngine
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt (+16 lines)
Lines 57-62 Link Here
57
                                </div>
57
                                </div>
58
                            [% END %]
58
                            [% END %]
59
59
60
                            [% IF ( shibbolethAuthentication ) %]
61
                                <h4>Shibboleth Login</h4>
62
63
                                [% IF ( invalidShibLogin ) %]
64
                                <!-- This is what is displated if shibboleth login has failed -->
65
                                <p>Sorry, the Shibboleth login failed.</p>
66
                                [% END %]
67
68
                                <p>If you have a Shibboleth account,
69
                                please <a href="[% shibbolethLoginUrl %]">click here to login</a>.</p>
70
71
                                <h4>Local Login</h4>
72
                                <p>If you do not have a Shibboleth account, but a local account, you can still log in : </p>
73
74
                            [% END %]
75
60
                            [% IF ( casAuthentication ) %]
76
                            [% IF ( casAuthentication ) %]
61
                                <h4>CAS login</h4>
77
                                <h4>CAS login</h4>
62
78
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt (-1 / +1 lines)
Lines 65-71 Link Here
65
            <div class="span3">
65
            <div class="span3">
66
                [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
66
                [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
67
                    [% UNLESS ( loggedinusername ) %]
67
                    [% UNLESS ( loggedinusername ) %]
68
                        [% UNLESS ( casAuthentication ) %]
68
                        [% UNLESS ( casAuthentication || shibbolethAuthentication ) %]
69
                            <div id="login">
69
                            <div id="login">
70
                                <form action="/cgi-bin/koha/opac-user.pl" method="post" name="auth" id="auth">
70
                                <form action="/cgi-bin/koha/opac-user.pl" method="post" name="auth" id="auth">
71
                                    <input type="hidden" name="koha_login_context" value="opac" />
71
                                    <input type="hidden" name="koha_login_context" value="opac" />
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth.tt (-3 / +3 lines)
Lines 51-64 Link Here
51
51
52
[% IF ( invalidShibLogin ) %]
52
[% IF ( invalidShibLogin ) %]
53
<!-- This is what is displated if shibboleth login has failed -->
53
<!-- This is what is displated if shibboleth login has failed -->
54
<p>Sorry, the shibboleth login failed.</p>
54
<p>Sorry, the Shibboleth login failed.</p>
55
[% END %]
55
[% END %]
56
56
57
<p>If you have a shibboleth account,
57
<p>If you have a Shibboleth account,
58
please <a href="[% shibbolethLoginUrl %]">click here to login</a>.</p>
58
please <a href="[% shibbolethLoginUrl %]">click here to login</a>.</p>
59
59
60
<h4>Local Login</h4>
60
<h4>Local Login</h4>
61
<p>If you do not have a shibboleth account, but a local account, you can still log in : </p>
61
<p>If you do not have a Shibboleth account, but a local account, you can still log in : </p>
62
62
63
[% END %]
63
[% END %]
64
64
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt (-2 / +1 lines)
Lines 46-53 Link Here
46
    <div class="yui-u">
46
    <div class="yui-u">
47
    [% IF ( opacuserlogin ) %]
47
    [% IF ( opacuserlogin ) %]
48
    [% UNLESS ( loggedinusername ) %]
48
    [% UNLESS ( loggedinusername ) %]
49
    [% UNLESS ( casAuthentication ) %]
49
    [% UNLESS ( casAuthentication || shibbolethAuthentication ) %]
50
    [% UNLESS ( shibbolethAuthentication ) %]
51
    <div id="login" class="container clearfix">
50
    <div id="login" class="container clearfix">
52
	<form action="/cgi-bin/koha/opac-user.pl" method="post" name="auth" id="auth">
51
	<form action="/cgi-bin/koha/opac-user.pl" method="post" name="auth" id="auth">
53
    <input type="hidden" name="koha_login_context" value="opac" />
52
    <input type="hidden" name="koha_login_context" value="opac" />
(-)a/opac/opac-main.pl (-2 / +1 lines)
Lines 43-50 $template->param( Link Here
43
    casAuthentication   => $casAuthentication,
43
    casAuthentication   => $casAuthentication,
44
);
44
);
45
45
46
my $shibbolethAuthentication = C4::Context->preference('shibbolethAuthentication');
46
$template->param( shibbolethAuthentication => C4::Context->config('useshibboleth') );
47
$template->param( shibbolethAuthentication => $shibbolethAuthentication);
48
47
49
# display news
48
# display news
50
# use cookie setting for language, bug default to syspref if it's not set
49
# use cookie setting for language, bug default to syspref if it's not set
(-)a/opac/opac-user.pl (-3 / +1 lines)
Lines 71-78 for ( C4::Context->preference("OPACShowHoldQueueDetails") ) { Link Here
71
my $patronupdate = $query->param('patronupdate');
71
my $patronupdate = $query->param('patronupdate');
72
my $canrenew = 1;
72
my $canrenew = 1;
73
73
74
my $shibbolethAuthentication = C4::Context->preference('shibbolethAuthentication');
74
$template->param( shibbolethAuthentication => C4::Context->config('useshibboleth') );
75
$template->param( shibbolethAuthentication => $shibbolethAuthentication );
76
75
77
# get borrower information ....
76
# get borrower information ....
78
my ( $borr ) = GetMemberDetails( $borrowernumber );
77
my ( $borr ) = GetMemberDetails( $borrowernumber );
79
- 

Return to bug 8446