Skip to content
Browse files

authentication for writer

  • Loading branch information...
1 parent 81b3bcb commit b11c9ac76823479cc984284f450f265e9212c75c @nobuo-danjou nobuo-danjou committed Jan 11, 2011
Showing with 16 additions and 0 deletions.
  1. +12 −0 app.p6sgi
  2. +4 −0 config.pl.sample
View
12 app.p6sgi
@@ -3,13 +3,25 @@ use Journal;
use Plackdo::Builder;
use Plackdo::Middleware::Runtime;
use Plackdo::Middleware::Static;
+use Plackdo::Middleware::Auth::Basic;
+use Plackdo::Middleware::Conditional;
my $conf = eval slurp 'config.pl';
$conf or die 'invalid config';
my $j = Journal.new(|$conf<database>);
my $b = Plackdo::Builder.new;
+$b.add_middleware(
+ Plackdo::Middleware::Conditional.new(
+ middleware => Plackdo::Middleware::Auth::Basic.new(
+ authenticator => sub ($user, $pass, %env) {
+ ($user eq $conf<auth><name>) && ($pass eq $conf<auth><password>)
+ }
+ ),
+ condition => sub (%env) {%env<PATH_INFO> ~~ m{ ^ '/writer' } }
+ )
+);
$b.add_middleware( Plackdo::Middleware::Static.new(|$conf<static>) );
$b.add_middleware( Plackdo::Middleware::Runtime.new );
$b.to_app($j.webapp);
View
4 config.pl.sample
@@ -15,6 +15,10 @@ use v6;
static => {
root => '.',
path => rx{ ^ '/static' }
+ },
+ auth => {
+ name => 'yourname',
+ password => 'password',
}
}

0 comments on commit b11c9ac

Please sign in to comment.
Something went wrong with that request. Please try again.