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

(-)a/C4/Auth.pm (-8 / +3 lines)
Lines 55-61 BEGIN { Link Here
55
    %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
55
    %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
56
    $ldap        = C4::Context->config('useldapserver') || 0;
56
    $ldap        = C4::Context->config('useldapserver') || 0;
57
    $cas         = C4::Context->preference('casAuthentication');
57
    $cas         = C4::Context->preference('casAuthentication');
58
    $shib        = C4::Context->preference('shibbolethAuthentication');
58
    $shib        = C4::Context->config('useshibboleth') || 0;
59
    $caslogout   = C4::Context->preference('casLogout');
59
    $caslogout   = C4::Context->preference('casLogout');
60
    require C4::Auth_with_cas;             # no import
60
    require C4::Auth_with_cas;             # no import
61
    require C4::Auth_with_Shibboleth;
61
    require C4::Auth_with_Shibboleth;
Lines 825-831 sub checkauth { Link Here
825
            || $userid
825
            || $userid
826
            || $shib
826
            || $shib
827
            || $pki_field ne 'None'
827
            || $pki_field ne 'None'
828
	    || $persona )
828
            || $persona )
829
        {
829
        {
830
            my $password = $query->param('password');
830
            my $password = $query->param('password');
831
831
Lines 1083-1089 sub checkauth { Link Here
1083
        login                => 1,
1083
        login                => 1,
1084
        INPUTS               => \@inputs,
1084
        INPUTS               => \@inputs,
1085
        casAuthentication    => C4::Context->preference("casAuthentication"),
1085
        casAuthentication    => C4::Context->preference("casAuthentication"),
1086
        shibbolethAuthentication => C4::Context->preference("shibbolethAuthentication"),
1086
        shibbolethAuthentication => $shib,
1087
        suggestion           => C4::Context->preference("suggestion"),
1087
        suggestion           => C4::Context->preference("suggestion"),
1088
        virtualshelves       => C4::Context->preference("virtualshelves"),
1088
        virtualshelves       => C4::Context->preference("virtualshelves"),
1089
        LibraryName          => "" . C4::Context->preference("LibraryName"),
1089
        LibraryName          => "" . C4::Context->preference("LibraryName"),
Lines 1602-1612 sub checkpw { Link Here
1602
        # (defined in the shibbolethLoginAttribute) tto contain the login of the
1602
        # (defined in the shibbolethLoginAttribute) tto contain the login of the
1603
        # shibboleth-authenticated user
1603
        # shibboleth-authenticated user
1604
1604
1605
        # Shibboleth attributes are mapped into http environmement variables,
1606
        # so we're getting the login of the user this way
1607
        my $attributename = C4::Context->preference('shibbolethLoginAttribute');
1608
        my $attributevalue = $ENV{$attributename};
1609
1610
        # Then, we check if it matches a valid koha user
1605
        # Then, we check if it matches a valid koha user
1611
        if ($shib_login) {
1606
        if ($shib_login) {
1612
            my ( $retval, $retcard, $retuserid ) = C4::Auth_with_Shibboleth::checkpw_shib( $dbh, $shib_login );    # EXTERNAL AUTH
1607
            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 8781-8794 if ( CheckVersion($DBversion) ) { Link Here
8781
    SetVersion($DBversion);
8781
    SetVersion($DBversion);
8782
}
8782
}
8783
8783
8784
$DBversion = "XXX";
8785
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
8786
    $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('shibbolethAuthentication','','','Enable or disable Shibboleth authentication','YesNo')");
8787
    $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('shibbolethLoginAttribute','','','Which shibboleth user attribute should be used to match koha user login?','')");
8788
    print "Upgrade to $DBversion done (Adds shibbolethAuthentication and shibbolethLoginAttribute preferences)\n";
8789
    SetVersion ($DBversion);
8790
}
8791
8792
=head1 FUNCTIONS
8784
=head1 FUNCTIONS
8793
8785
8794
=head2 TableExists($table)
8786
=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 44-51 $template->param( Link Here
44
    casAuthentication   => $casAuthentication,
44
    casAuthentication   => $casAuthentication,
45
);
45
);
46
46
47
my $shibbolethAuthentication = C4::Context->preference('shibbolethAuthentication');
47
$template->param( shibbolethAuthentication => C4::Context->config('useshibboleth') );
48
$template->param( shibbolethAuthentication => $shibbolethAuthentication);
49
48
50
# display news
49
# display news
51
# use cookie setting for language, bug default to syspref if it's not set
50
# use cookie setting for language, bug default to syspref if it's not set
(-)a/opac/opac-user.pl (-3 / +1 lines)
Lines 74-81 for ( C4::Context->preference("OPACShowHoldQueueDetails") ) { Link Here
74
my $patronupdate = $query->param('patronupdate');
74
my $patronupdate = $query->param('patronupdate');
75
my $canrenew = 1;
75
my $canrenew = 1;
76
76
77
my $shibbolethAuthentication = C4::Context->preference('shibbolethAuthentication');
77
$template->param( shibbolethAuthentication => C4::Context->config('useshibboleth') );
78
$template->param( shibbolethAuthentication => $shibbolethAuthentication );
79
78
80
# get borrower information ....
79
# get borrower information ....
81
my ( $borr ) = GetMemberDetails( $borrowernumber );
80
my ( $borr ) = GetMemberDetails( $borrowernumber );
82
- 

Return to bug 8446