Add helper to build CSP host list (#2513)
This commit is contained in:
parent
82620525ba
commit
5ba0c11b58
|
@ -15,6 +15,7 @@ package Lemonldap::NG::Portal::Main;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use URI::Escape;
|
use URI::Escape;
|
||||||
|
use URI;
|
||||||
use JSON;
|
use JSON;
|
||||||
use Lemonldap::NG::Common::Util qw(getPSessionID);
|
use Lemonldap::NG::Common::Util qw(getPSessionID);
|
||||||
|
|
||||||
|
@ -1198,4 +1199,16 @@ sub loadTemplate {
|
||||||
return $tpl->output;
|
return $tpl->output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This method extracts the scheme://host:port part of a URL for use in
|
||||||
|
# Content-Security-Polity header
|
||||||
|
sub cspGetHost {
|
||||||
|
my ( $self, $url ) = @_;
|
||||||
|
my $uri = $url // "";
|
||||||
|
unless ( $uri->isa("URI") ) {
|
||||||
|
$uri = URI->new($uri);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
$uri->scheme . "://" . ( $uri->_port ? $uri->host_port : $uri->host ) );
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user