[#279] Web sessions use cookies instead of files on disk (M. Johnson)

This commit is contained in:
Oliver Gorwits
2016-10-01 16:27:48 +01:00
parent a6839a5850
commit 0cc7e029f3
8 changed files with 25 additions and 7 deletions

View File

@@ -1217,10 +1217,10 @@ you're doing.
=head3 C<session>
Value: String. Default: C<YAML>.
Value: String. Default: C<cookie>.
How to handle web sessions. Default is to store on disk so they can be shared
between multiple web server processes (although it's slower).
How to handle web sessions. Default is to store in an encrypted cookie
using a key stored in the database by C<netdisco-deploy>.
=head3 C<template>

View File

@@ -56,6 +56,13 @@ if (setting('extra_web_plugins') and ref [] eq ref setting('extra_web_plugins'))
push @{ config->{engines}->{netdisco_template_toolkit}->{INCLUDE_PATH} },
setting('views');
# load cookie key from database
setting('session_cookie_key' => undef);
my $sessions = schema('netdisco')->resultset('Session');
my $skey = $sessions->find({id => 'dancer_session_cookie_key'});
setting('session_cookie_key' => $skey->get_column('a_session')) if $skey;
Dancer::Session::Cookie::init(session);
# workaround for https://github.com/PerlDancer/Dancer/issues/935
hook after_error_render => sub { setting('layout' => 'main') };