* new Plugin Catalyst/Plugin/NGCP/RealmCookie.pm that extends Catalyst::Plugin::Session::State::Cookie and overloads methods responsible for cookie_name creation. It uses NGCP_REALM fastcgi header to append it to the cookie name. Empty cookie with name "appprefix"_session is suppressed on Session pre-setup. * Base cookie_name is now set to 'ngcp-panel' Change-Id: I6b4c10c5e1728d0dd7a6398bf5191925d5b904f6mr9.5.1
parent
4d72ec99e0
commit
61fc16dec8
@ -0,0 +1,43 @@
|
||||
package Catalyst::Plugin::NGCP::RealmCookie;
|
||||
use Moose;
|
||||
use namespace::autoclean;
|
||||
extends 'Catalyst::Plugin::Session::State::Cookie';
|
||||
|
||||
# prevents creation of an empty ..._session cookies during
|
||||
# session pre-setup
|
||||
sub setup_session {
|
||||
my $c = shift;
|
||||
|
||||
$c->maybe::next::method(@_);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sub get_cookie_name {
|
||||
my $c = shift;
|
||||
my $ngcp_api_realm = $c->request->env->{NGCP_REALM} // "";
|
||||
|
||||
my $cookie_name = $c->_session_plugin_config->{cookie_name} //
|
||||
Catalyst::Utils::appprefix($c);
|
||||
$cookie_name .= $ngcp_api_realm ? '_'.$ngcp_api_realm : '';
|
||||
return $cookie_name;
|
||||
}
|
||||
|
||||
sub update_session_cookie {
|
||||
my ( $c, $updated ) = @_;
|
||||
|
||||
unless ( $c->cookie_is_rejecting( $updated ) ) {
|
||||
my $cookie_name = $c->get_cookie_name;
|
||||
$c->response->cookies->{$cookie_name} = $updated;
|
||||
}
|
||||
}
|
||||
|
||||
sub get_session_cookie {
|
||||
my $c = shift;
|
||||
|
||||
my $cookie_name = $c->get_cookie_name;
|
||||
|
||||
return $c->request->cookies->{$cookie_name};
|
||||
}
|
||||
|
||||
1;
|
Loading…
Reference in new issue