|
Last change
on this file since 53 was
53,
checked in by peter, 12 years ago
|
- converted from a regular CGI application to a PSGI web application
- added an app.psgi main script
- use Plack::Middleware::ReverseProxy to adjust environment for when behind a reverse proxy
- use Plack::Middleware::Auth::Digest to do HTTP digest authentication for non-GET requests
- read in the db name, reverse proxy server IP, and digest password hash from a conf.yml config file
- use the CGI::url method instead of trying to build the base URI from the %ENV hash
- default to an empty tags parameter so split does not emit a warning
|
-
Property svn:executable set to
*
|
|
File size:
694 bytes
|
| Rev | Line | |
|---|
| [53] | 1 | #!/usr/bin/perl -w |
|---|
| 2 | use strict; |
|---|
| 3 | |
|---|
| 4 | use YAML; |
|---|
| 5 | use Plack::Builder; |
|---|
| 6 | |
|---|
| 7 | use BookmarkApp::Dispatch; |
|---|
| 8 | |
|---|
| 9 | -e 'conf.yml' or die "Missing required conf.yml config file\n"; |
|---|
| 10 | |
|---|
| 11 | my $config = YAML::LoadFile('conf.yml'); |
|---|
| 12 | my $app = BookmarkApp::Dispatch->as_psgi( |
|---|
| 13 | args_to_new => { |
|---|
| 14 | PARAMS => { dbname => $config->{dbname} }, |
|---|
| 15 | }, |
|---|
| 16 | ); |
|---|
| 17 | |
|---|
| 18 | builder { |
|---|
| 19 | enable_if { $_[0]->{REMOTE_ADDR} eq $config->{proxy_ip} } 'ReverseProxy'; |
|---|
| 20 | enable_if { $_[0]->{REQUEST_METHOD} ne 'GET' } 'Auth::Digest', ( |
|---|
| 21 | realm => 'Bookmarks', |
|---|
| 22 | secret => 'blahblahblah', #TODO: change this! |
|---|
| 23 | password_hashed => 1, |
|---|
| 24 | authenticator => sub { $config->{digest_password} } |
|---|
| 25 | ); |
|---|
| 26 | $app; |
|---|
| 27 | }; |
|---|
Note: See
TracBrowser
for help on using the repository browser.