Lines 83-95
sub get_login_shib {
Link Here
|
83 |
sub checkpw_shib { |
83 |
sub checkpw_shib { |
84 |
$debug and warn "checkpw_shib"; |
84 |
$debug and warn "checkpw_shib"; |
85 |
|
85 |
|
86 |
my ( $dbh, $userid ) = @_; |
86 |
my ( $dbh, $match ) = @_; |
87 |
my $retnumber; |
87 |
my ( $retnumber, $userid ); |
88 |
$debug and warn "User Shibboleth-authenticated as: $userid"; |
88 |
$debug and warn "User Shibboleth-authenticated as: $match"; |
89 |
|
89 |
|
90 |
# Does the given shibboleth attribute value ($userid) match a valid koha user ? |
90 |
# Does the given shibboleth attribute value ($match) match a valid koha user ? |
91 |
my $sth = $dbh->prepare("select cardnumber, userid from borrowers where $shibbolethMatchField=?"); |
91 |
my $sth = $dbh->prepare("select cardnumber, userid from borrowers where $shibbolethMatchField=?"); |
92 |
$sth->execute($userid); |
92 |
$sth->execute($match); |
93 |
if ( $sth->rows ) { |
93 |
if ( $sth->rows ) { |
94 |
my @retvals = $sth->fetchrow; |
94 |
my @retvals = $sth->fetchrow; |
95 |
$retnumber = $retvals[1]; |
95 |
$retnumber = $retvals[1]; |
Lines 97-115
sub checkpw_shib {
Link Here
|
97 |
return ( 1, $retnumber, $userid ); |
97 |
return ( 1, $retnumber, $userid ); |
98 |
} |
98 |
} |
99 |
|
99 |
|
|
|
100 |
# If we reach this point, the user is not yet a valid koha user |
100 |
if ( $shib->{'autocreate'} ) { |
101 |
if ( $shib->{'autocreate'} ) { |
101 |
return _autocreate( $dbh, $shib, $userid ); |
102 |
return _autocreate( $dbh, $shib, $match ); |
102 |
} else { |
103 |
} else { |
103 |
# If we reach this point, the user is not a valid koha user |
104 |
$debug and warn "User $match is not a valid Koha user"; |
104 |
$debug and warn "User $userid is not a valid Koha user"; |
|
|
105 |
return 0; |
105 |
return 0; |
106 |
} |
106 |
} |
107 |
} |
107 |
} |
108 |
|
108 |
|
109 |
sub _autocreate { |
109 |
sub _autocreate { |
110 |
my ( $dbh, $shib, $userid ) = @_; |
110 |
my ( $dbh, $shib, $match ) = @_; |
111 |
|
111 |
|
112 |
my %borrower = ( userid => $userid ); |
112 |
my %borrower = ( $shibbolethMatchField => $match ); |
113 |
|
113 |
|
114 |
while ( my ( $key, $entry ) = each %{$shib->{'mapping'}} ) { |
114 |
while ( my ( $key, $entry ) = each %{$shib->{'mapping'}} ) { |
115 |
$borrower{$key} = ( $entry->{'is'} && $ENV{ $entry->{'is'} } ) || $entry->{'content'} || ''; |
115 |
$borrower{$key} = ( $entry->{'is'} && $ENV{ $entry->{'is'} } ) || $entry->{'content'} || ''; |
Lines 238-243
Given a database handle and a shib_login attribute, this routine checks for a ma
Link Here
|
238 |
|
238 |
|
239 |
my ( $retval, $retcard, $retuserid ) = C4::Auth_with_shibboleth::checkpw_shib( $dbh, $shib_login ); |
239 |
my ( $retval, $retcard, $retuserid ) = C4::Auth_with_shibboleth::checkpw_shib( $dbh, $shib_login ); |
240 |
|
240 |
|
|
|
241 |
=head2 _autocreate |
242 |
|
243 |
my ( $retval, $retcard, $retuserid ) = _autocreate( $dbh, $shib, $userid ); |
244 |
|
245 |
Given a database handle, a shibboleth attribute reference and a userid this internal routine will add the given user to koha and return their user credentials |
246 |
|
247 |
This routine is NOT exported |
248 |
|
241 |
=head1 SEE ALSO |
249 |
=head1 SEE ALSO |
242 |
|
250 |
|
243 |
=cut |
251 |
=cut |
244 |
- |
|
|