htpasswd

Discussion in 'Ruby' started by Anka Anka, May 21, 2008.

  1. Anka Anka

    Anka Anka Guest

    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/.
     
    Anka Anka, May 21, 2008
    #1
    1. Advertising

  2. 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
     
    Jeremy Hinegardner, May 22, 2008
    #2
    1. Advertising

  3. Anka Anka

    ara.t.howard Guest

    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
     
    ara.t.howard, May 22, 2008
    #3
  4. Anka Anka

    Anka Anka Guest

    Anka Anka, May 22, 2008
    #4
  5. 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, May 22, 2008
    #5
  6. 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/.
     
    Phil Thompson, Mar 1, 2011
    #6
  7. 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/.
     
    Phil Thompson, Mar 2, 2011
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christopher Brandsdal

    Htpasswd

    Christopher Brandsdal, Dec 12, 2003, in forum: ASP General
    Replies:
    3
    Views:
    118
    Mark Schupp
    Dec 13, 2003
  2. Christopher Brandsdal

    Htpasswd

    Christopher Brandsdal, Dec 12, 2003, in forum: ASP General
    Replies:
    0
    Views:
    111
    Christopher Brandsdal
    Dec 12, 2003
  3. Get htpasswd username

    , Aug 6, 2005, in forum: Perl Misc
    Replies:
    1
    Views:
    160
    Paul Lalli
    Aug 6, 2005
  4. shawn modersohn

    Apache::Htpasswd question

    shawn modersohn, Sep 21, 2006, in forum: Perl Misc
    Replies:
    1
    Views:
    125
  5. PerlFAQ Server
    Replies:
    0
    Views:
    132
    PerlFAQ Server
    Apr 13, 2011
Loading...

Share This Page