Lines 36-63
BEGIN {
Link Here
|
36 |
@ISA = qw(Exporter); |
36 |
@ISA = qw(Exporter); |
37 |
@EXPORT = qw(logout_shib login_shib_url checkpw_shib get_login_shib); |
37 |
@EXPORT = qw(logout_shib login_shib_url checkpw_shib get_login_shib); |
38 |
} |
38 |
} |
39 |
my $context = C4::Context->new() or die 'C4::Context->new failed'; |
39 |
|
40 |
my $shib = C4::Context->config('shibboleth') or croak 'No <shibboleth> in koha-conf.xml'; |
40 |
my $shib = C4::Context->config('shibboleth') or croak 'No <shibboleth> in koha-conf.xml'; |
41 |
my $shibbolethMatchField = $shib->{matchpoint} or croak 'No <matchpoint> defined in koha-conf.xml'; |
41 |
my $shibbolethMatchField = $shib->{matchpoint} or croak 'No <matchpoint> defined in koha-conf.xml'; |
42 |
my $shibbolethMatchAttribute = $shib->{mapping}->{$shibbolethMatchField}->{is} or croak 'Matchpoint not mapped in koha-conf.xml'; |
42 |
my $shibbolethMatchAttribute = $shib->{mapping}->{$shibbolethMatchField}->{is} or croak 'Matchpoint not mapped in koha-conf.xml'; |
43 |
my $protocol = "https://"; |
|
|
44 |
|
43 |
|
45 |
# Logout from Shibboleth |
44 |
# Logout from Shibboleth |
46 |
sub logout_shib { |
45 |
sub logout_shib { |
47 |
my ($query) = @_; |
46 |
my ($query) = @_; |
48 |
my $uri = $protocol . C4::Context->preference('OPACBaseURL'); |
47 |
my $uri = _get_uri(); |
49 |
print $query->redirect( $uri . "/Shibboleth.sso/Logout?return=$uri" ); |
48 |
print $query->redirect( $uri . "/Shibboleth.sso/Logout?return=$uri" ); |
50 |
} |
49 |
} |
51 |
|
50 |
|
52 |
# Returns Shibboleth login URL with callback to the requesting URL |
51 |
# Returns Shibboleth login URL with callback to the requesting URL |
53 |
sub login_shib_url { |
52 |
sub login_shib_url { |
54 |
|
|
|
55 |
my ($query) = @_; |
53 |
my ($query) = @_; |
56 |
my $param = $protocol . C4::Context->preference('OPACBaseURL') . $query->script_name(); |
54 |
my $param = _get_uri() . $query->script_name(); |
57 |
if ( $query->query_string() ) { |
55 |
if ( $query->query_string() ) { |
58 |
$param = $param . '%3F' . $query->query_string(); |
56 |
$param = $param . '%3F' . $query->query_string(); |
59 |
} |
57 |
} |
60 |
my $uri = $protocol . C4::Context->preference('OPACBaseURL') . "/Shibboleth.sso/Login?target=$param"; |
58 |
my $uri = _get_uri() . "/Shibboleth.sso/Login?target=$param"; |
61 |
return $uri; |
59 |
return $uri; |
62 |
} |
60 |
} |
63 |
|
61 |
|
Lines 106-111
sub checkpw_shib {
Link Here
|
106 |
} |
104 |
} |
107 |
} |
105 |
} |
108 |
|
106 |
|
|
|
107 |
sub _get_uri { |
108 |
|
109 |
my $protocol = "https://"; |
110 |
my $interface = C4::Context->interface; |
111 |
$debug and warn "shibboleth interface: " . $interface; |
112 |
|
113 |
my $return; |
114 |
if ( $interface eq 'intranet' ) { |
115 |
$return = $protocol . C4::Context->preference('staffClientBaseURL'); |
116 |
return $return; |
117 |
} else { |
118 |
$return = $protocol . C4::Context->preference('OPACBaseURL'); |
119 |
return $return; |
120 |
} |
121 |
} |
122 |
|
109 |
sub _autocreate { |
123 |
sub _autocreate { |
110 |
my ( $dbh, $shib, $match ) = @_; |
124 |
my ( $dbh, $shib, $match ) = @_; |
111 |
|
125 |
|