Index: /trunk/lib/BookmarksApp.pm
===================================================================
--- /trunk/lib/BookmarksApp.pm	(revision 113)
+++ /trunk/lib/BookmarksApp.pm	(revision 114)
@@ -116,4 +116,22 @@
     };
 
+    # if configured for auth, read in the htdigest database file
+    # and store the password hashes keyed by username
+    my %password_hash_for;
+    if ($config->{auth}) {
+        $config->{realm} ||= 'Bookmarks';
+        $config->{htdigest} or die "No htdigest configured for authentication\n";
+        open my $htdigest, '<', $config->{htdigest} or die "Can't open $$config{htdigest}\n";
+        while (my $credentials = <$htdigest>) {
+            chomp $credentials;
+            my ($username, $realm, $password_hash) = split /:/, $credentials;
+            # only add password digests for the configured realm
+            if ($realm eq $config->{realm}) {
+                $password_hash_for{$username} = $password_hash;
+            }
+        }
+        close $htdigest;
+    }
+
     $self->_app(
         builder {
@@ -121,8 +139,11 @@
                 if $config->{proxy_ip};
             enable_if { $_[0]->{REQUEST_METHOD} ne 'GET' } 'Auth::Digest', (
-                realm           => 'Bookmarks',
+                realm           => $config->{realm},
                 secret          => $config->{digest_key},
                 password_hashed => 1,
-                authenticator   => sub { $config->{digest_password} }
+                authenticator   => sub {
+                    my ($username, $env) = @_;
+                    return $password_hash_for{$username};
+                },
             ) if $config->{auth};
             sub { $router->dispatch(shift); };
