[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

htpasswd

Anka Anka

5/21/2008 10:52:00 PM

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...
--
Posted via http://www.ruby-....

5 Answers

Phlip

5/22/2008 3:48:00 AM

0

Anka Anka wrote:

> 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.

A password is typically a one-way encryption, such as a hash or CRC
algorithm. If you looked up which one htpasswd2 uses, you could then
get a Ruby library that does it.

Alternately, try some variation of

password = `htpasswd2 -m #{cleartext}`

or system(). That `` notation calls a command line for you.

Jeremy Hinegardner

5/22/2008 5:13:00 AM

0

On Thu, May 22, 2008 at 07:51:39AM +0900, Anka Anka wrote:
> 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.o...

> 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

--
========================================================================
Jeremy Hinegardner jeremy@hinegardner.org


ara.t.howard

5/22/2008 5:33:00 AM

0


On May 21, 2008, at 4:51 PM, Anka Anka wrote:

> 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://codeforp...
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama




Anka Anka

5/22/2008 10:16:00 AM

0

Thanks. It works

--
Posted via http://www.ruby-....

Jeremy Hinegardner

5/22/2008 4:18:00 PM

0

On Thu, May 22, 2008 at 07:16:24PM +0900, Anka Anka wrote:
> Thanks. It works

Glad to help out, let me know if you find any bugs.

enjoy,

-jeremy

--
========================================================================
Jeremy Hinegardner jeremy@hinegardner.org