htpasswd

A

Anka Anka

How to generate apache password with ruby? I have to generate from ruby
code the same password like htpasswd2 -m make. In other words: from ruby
on rails application I have to generate a password, which will be used
not only for login, but also to generate apache config files (e.g.
password files for subversion) - so the password must be exactly the
same.
Can someone help me?
Sorry for my english...
 
J

Jeremy Hinegardner

How to generate apache password with ruby? I have to generate from ruby
code the same password like htpasswd2 -m make. In other words: from ruby
on rails application I have to generate a password, which will be used
not only for login, but also to generate apache config files (e.g.
password files for subversion) - so the password must be exactly the
same.
Can someone help me?
Sorry for my english...

Try out the htauth gem and see if it works for you:

gem install htauth

http://copiousfreetime.rubyforge.org/htauth/
HTAuth is a pure ruby replacement for the Apache support programs htdigest
and htpasswd. Command line and API access are provided for access and
control of htdigest and htpasswd files.

enjoy,

-jeremy
 
A

ara.t.howard

How to generate apache password with ruby? I have to generate from
ruby
code the same password like htpasswd2 -m make. In other words: from
ruby
on rails application I have to generate a password, which will be used
not only for login, but also to generate apache config files (e.g.
password files for subversion) - so the password must be exactly the
same.
Can someone help me?
Sorry for my english...

the webrick library, which is included with ruby, has tools for
generating and manipulating htpasswd files - the docs are slim but the
code is quite easy to read

start with

webrick/httpauth/htpasswd.rb

cheers.

a @ http://codeforpeople.com/
 
P

Phil Thompson

Needed to know this so found out what to run from Webrick:


require 'webrick/httpauth/basicauth'
WEBrick::HTTPAuth::UserDB::BasicAuth::make_passwd('realm', 'user',
'pass')
-> "uVYUjG9q8pg8o"


Thanks to Ara for the pointer.
 
P

Phil Thompson

In fact, looking at webrick/httpauth/basicauth.rb it seems all you need
is to use crypt.

require 'webrick/utils'
crypted_pass.crypt(WEBrick::Utils.random_string(2))

I have not yet tested this with Apache but I need the same thing for
Nginx.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top