- Timestamp:
- 02/18/16 17:16:31 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/BookmarksApp.pm
r112 r114 116 116 }; 117 117 118 # if configured for auth, read in the htdigest database file 119 # and store the password hashes keyed by username 120 my %password_hash_for; 121 if ($config->{auth}) { 122 $config->{realm} ||= 'Bookmarks'; 123 $config->{htdigest} or die "No htdigest configured for authentication\n"; 124 open my $htdigest, '<', $config->{htdigest} or die "Can't open $$config{htdigest}\n"; 125 while (my $credentials = <$htdigest>) { 126 chomp $credentials; 127 my ($username, $realm, $password_hash) = split /:/, $credentials; 128 # only add password digests for the configured realm 129 if ($realm eq $config->{realm}) { 130 $password_hash_for{$username} = $password_hash; 131 } 132 } 133 close $htdigest; 134 } 135 118 136 $self->_app( 119 137 builder { … … 121 139 if $config->{proxy_ip}; 122 140 enable_if { $_[0]->{REQUEST_METHOD} ne 'GET' } 'Auth::Digest', ( 123 realm => 'Bookmarks',141 realm => $config->{realm}, 124 142 secret => $config->{digest_key}, 125 143 password_hashed => 1, 126 authenticator => sub { $config->{digest_password} } 144 authenticator => sub { 145 my ($username, $env) = @_; 146 return $password_hash_for{$username}; 147 }, 127 148 ) if $config->{auth}; 128 149 sub { $router->dispatch(shift); };
Note: See TracChangeset
for help on using the changeset viewer.