Find the answer to your Linux question:
Results 1 to 6 of 6
I run a php application on my website and we have a protected directory where some pdfs are stored and we give out the username and password to selected users. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2011
    Posts
    11

    need an htpasswd replacement


    I run a php application on my website and we have a protected directory where some pdfs are stored and we give out the username and password to selected users.

    the problem we're faced with is that with the advent of kindles. etc - those devices like to capitalize the first letter of the username that get's prompted for my .htpasswd in apache and I need to have the same username in there twice - once with a capital first letter and once with a lower case first letter.

    It does not appear as there are any work-arounds in apache so I'm looking for an application or add-on module (rpm etc) that would allow me to do this.

    any ideas?

  2. #2
    Linux User
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    362
    Perhaps at the point of adding usernames, you could do something like this:
    Code:
    #!/bin/sh
    read -e -p'enter username >' user
    USER=$(echo $user|sed "s/.*/\u&/")
    echo $USER
    gives
    Code:
    enter username >joecool
    Joecool

  3. #3
    Just Joined!
    Join Date
    Jun 2011
    Posts
    11
    that's really great code but apache controls the input through it's own dialogue box

  4. #4
    Linux Engineer
    Join Date
    Apr 2012
    Location
    Virginia, USA
    Posts
    886
    Have you considered mod_auth_pam ?
    Authenticate Apache using PAM

  5. #5
    Just Joined!
    Join Date
    Apr 2009
    Posts
    3
    If I understand correctly you simply want to add 2 entries for joecool and Joecool at the same time with the same password with one command. Right?

    This can be easily achieved with a wrapper shell script. Augmenting what Miven has provided below, something like this should do the trick

    Code:
    #!/bin/bash
    
    # define the name of the password file to update
    passwdfile=".htaccess" # assumes it will be the current folder
    
    read -e -p 'Enter username >' user
    USER=$(echo $user|sed "s/.*/\u&/")
    #echo $USER
    
    read -s -e -p 'Enter password >' password
    #echo $password
    
    # now invoke htpasswd 2 times (once with the user name in all lower case and once with a capitalized first letter)
    htpasswd -b passwdfile user password
    htpasswd -b passwdfile USER password
    You could even change the script to generate a random password (rather than input it) if your customers don't have to enter it by hand, but can copy/paste from an e-mail, etc.


    Quote Originally Posted by Miven View Post
    Perhaps at the point of adding usernames, you could do something like this:
    Code:
    #!/bin/sh
    read -e -p'enter username >' user
    USER=$(echo $user|sed "s/.*/\u&/")
    echo $USER
    gives
    Code:
    enter username >joecool
    Joecool

  6. #6
    Just Joined!
    Join Date
    Jun 2011
    Posts
    11
    no my request has been mis-intrepreted

    this is what the user wants for directory access to be granted - any of these username/password combinations to work.

    UN: jack2013
    PW: freelunch

    UN: Jack2013
    PW: freelunch

    UN: Jack2013
    PW: Freelunch

    UN: jack2013
    PW: Freelunch

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •