Bug 13799: Allow to set Mojolicious secret in $KOHA_CONF
authorJulian Maurice <julian.maurice@biblibre.com>
Wed, 7 Oct 2015 09:10:12 +0000 (11:10 +0200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Wed, 4 Nov 2015 16:47:33 +0000 (13:47 -0300)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Koha/REST/V1.pm
etc/koha-conf.xml

index 375dff5..62f7693 100644 (file)
@@ -19,6 +19,7 @@ use Modern::Perl;
 use Mojo::Base 'Mojolicious';
 
 use C4::Auth qw( check_cookie_auth get_session );
+use C4::Context;
 use Koha::Borrowers;
 
 sub startup {
@@ -42,6 +43,11 @@ sub startup {
     # Force charset=utf8 in Content-Type header for JSON responses
     $self->types->type(json => 'application/json; charset=utf8');
 
+    my $secret_passphrase = C4::Context->config('api_secret_passphrase');
+    if ($secret_passphrase) {
+        $self->secrets([$secret_passphrase]);
+    }
+
     $self->plugin(Swagger2 => {
         route => $route,
         url => $self->home->rel_file("api/v1/swagger.json"),
index 1f2b460..74a5720 100644 (file)
@@ -117,6 +117,9 @@ __PAZPAR2_TOGGLE_XML_POST__
  <queryparser_config>__KOHA_CONF_DIR__/searchengine/queryparser.yaml</queryparser_config>
  <log4perl_conf>__KOHA_CONF_DIR__/log4perl.conf</log4perl_conf>
 
+ <!-- Secret passphrase used by Mojolicious for signed cookies -->
+ <api_secret_passphrase>CHANGEME</api_secret_passphrase>
+
  <!-- true type font mapping accoding to type from $font_types in C4/Creators/Lib.pm -->
  <ttf>
     <font type="TR" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf</font>