Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > htpasswd

Reply
Thread Tools

htpasswd

 
 
Anka Anka
Guest
Posts: n/a
 
      05-21-2008
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-forum.com/.

 
Reply With Quote
 
 
 
 
Jeremy Hinegardner
Guest
Posts: n/a
 
      05-22-2008
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.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

--
================================================== ======================
Jeremy Hinegardner http://www.velocityreviews.com/forums/(E-Mail Removed)


 
Reply With Quote
 
 
 
 
ara.t.howard
Guest
Posts: n/a
 
      05-22-2008

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




 
Reply With Quote
 
Anka Anka
Guest
Posts: n/a
 
      05-22-2008
Thanks. It works

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

 
Reply With Quote
 
Jeremy Hinegardner
Guest
Posts: n/a
 
      05-22-2008
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 (E-Mail Removed)


 
Reply With Quote
 
Phil Thompson
Guest
Posts: n/a
 
      03-01-2011
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.

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

 
Reply With Quote
 
Phil Thompson
Guest
Posts: n/a
 
      03-02-2011
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.

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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 9.13 How do I edit my .htpasswd and .htgroup files with Perl? PerlFAQ Server Perl Misc 0 04-13-2011 04:00 AM
Apache::Htpasswd question shawn modersohn Perl Misc 1 09-21-2006 03:51 AM
Get htpasswd username hgwoss@gmx.de Perl Misc 1 08-06-2005 11:25 AM
Htpasswd Christopher Brandsdal ASP General 3 12-13-2003 12:26 AM
Htpasswd Christopher Brandsdal ASP General 0 12-12-2003 07:02 PM



Advertisments