hydra/src/lib/Hydra.pm

101 lines
2.5 KiB
Perl
Raw Normal View History

2008-11-25 11:01:42 +00:00
package Hydra;
use strict;
use warnings;
2013-01-23 12:41:57 +00:00
use parent 'Catalyst';
use Moose;
use Hydra::Plugin;
2012-03-13 12:30:41 +00:00
use Hydra::Model::DB;
use Catalyst::Runtime '5.70';
use Catalyst qw/ConfigLoader
Static::Simple
StackTrace
2008-11-26 19:48:04 +00:00
Authentication
Authorization::Roles
2008-11-26 19:48:04 +00:00
Session
Session::Store::FastMmap
Session::State::Cookie
2013-02-27 17:33:47 +00:00
AccessLog
Captcha/,
2013-01-23 12:41:57 +00:00
'-Log=warn,fatal,error';
use CatalystX::RoleApplicator;
2013-01-23 12:41:57 +00:00
our $VERSION = '0.01';
2008-11-18 14:48:40 +00:00
__PACKAGE__->config(
2008-11-25 11:01:42 +00:00
name => 'Hydra',
2008-11-28 14:36:04 +00:00
default_view => "TT",
authentication => {
default_realm => "dbic",
realms => {
dbic => {
credential => {
class => "Password",
password_field => "password",
password_type => "hashed",
password_hash_type => "SHA-1",
},
store => {
class => "DBIx::Class",
user_class => "DB::Users",
role_relation => "userroles",
role_field => "role",
},
},
},
},
2013-02-25 17:18:05 +00:00
'Plugin::Static::Simple' => {
send_etag => 1,
expires => 3600
},
'View::JSON' => {
expose_stash => 'json'
},
'Plugin::Session' => {
expires => 3600 * 24 * 2,
2012-04-17 20:25:32 +00:00
storage => Hydra::Model::DB::getHydraPath . "/session_data"
},
2012-11-05 16:37:23 +00:00
'Plugin::AccessLog' => {
2013-01-22 12:19:08 +00:00
formatter => {
format => '%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i" %[handle_time]',
2012-11-05 16:37:23 +00:00
},
},
2013-02-27 17:33:47 +00:00
'Plugin::Captcha' => {
session_name => 'hydra-captcha',
new => {
width => 270,
height => 80,
ptsize => 20,
lines => 30,
thickness => 1,
rndmax => 5,
scramble => 1,
#send_ctobg => 1,
bgcolor => '#ffffff',
font => __PACKAGE__->path_to("ttf/StayPuft.ttf"),
2013-02-27 17:33:47 +00:00
},
create => [ qw/ttf circle/ ],
particle => [ 3500 ],
out => { force => 'jpeg' }
},
2008-11-28 14:36:04 +00:00
);
__PACKAGE__->apply_request_class_roles(qw/Catalyst::TraitFor::Request::ProxyBase/);
my $plugins;
has 'hydra_plugins' => (
is => 'ro',
default => sub { return $plugins; }
);
after setup_finalize => sub {
my $class = shift;
$plugins = [Hydra::Plugin->plugins(db => $class->model('DB'), config => $class->config)];
};
__PACKAGE__->setup();
1;