Project

General

Profile

Actions

Feature #14940

closed

Support bcrypt password hashing in webrick

Added by jeremyevans0 (Jeremy Evans) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Target version:
-
[ruby-core:88111]

Description

Related to #14915, this adds bcrypt password hash support when using htpasswd files with Webrick basic auth, allowing a migration path away from the current String#crypt usage.


Files


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #14915: Deprecate String#cryptRejectedActions
Actions #1

Updated by normalperson (Eric Wong) over 5 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r64060.


webrick: Support bcrypt password hashing

This adds a password_hash keyword argument to
WEBrick::HTTPAuth::Htpasswd#initialize. If set to :bcrypt, it
will create bcrypt hashes instead of crypt hashes, and will
raise an exception if the .htpasswd file uses crypt hashes.

If :bcrypt is used, then instead of calling
BasicAuth.make_passwd (which uses crypt),
WEBrick::HTTPAuth::Htpasswd#set_passwd will set the bcrypt
password directly. It isn't possible to change the
make_passwd API to accept the password hash format, as that
would break configurations who use Htpasswd#auth_type= to set
a custom auth_type.

This modifies WEBrick::HTTPAuth::BasicAuth to handle checking
both crypt and bcrypt hashes.

There are commented out requires for 'string/crypt', to handle
when String#crypt is deprecated and the undeprecated version is
moved to a gem.

There is also a commented out warning for the case when
the password_hash keyword is not specified and 'string/crypt'
cannot be required. I think the warning makes sense to nudge
users to using bcrypt.

I've updated the tests to test nil, :crypt, and :bcrypt values
for the password_hash keyword, skipping the bcrypt tests if the
bcrypt library cannot be required.

[ruby-core:88111] [Feature #14940]

From: Jeremy Evans

Updated by normalperson (Eric Wong) over 5 years ago

Thanks, applied as r64060.

I needed to add RUBYLIB=/path/to/bcrypt/lib to my make command
line to test bcrypt; but I suppose that's fine

Actions #3

Updated by akr (Akira Tanaka) almost 5 years ago

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0