Authenticate a user using same password as linux password

This is a discussion on Authenticate a user using same password as linux password within the PHP Language forums, part of the PHP Programming Forums category; We're working on an intranet site where we will require user's to only be able to access their ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-16-2005
joltman
 
Posts: n/a
Default Authenticate a user using same password as linux password

We're working on an intranet site where we will require user's to only
be able to access their own page in some instances. Rather than
introducing another password to the mix, we were thinking about seeing
if we could use the same credentials (username and password) as their
linux credentials. The web site will be running off of the same machine
that we want to access the credentials on.

Thanx!
-joltman

Reply With Quote
  #2 (permalink)  
Old 05-16-2005
Mike Willbanks
 
Posts: n/a
Default Re: Authenticate a user using same password as linux password

joltman,
> We're working on an intranet site where we will require user's to only
> be able to access their own page in some instances. Rather than
> introducing another password to the mix, we were thinking about seeing
> if we could use the same credentials (username and password) as their
> linux credentials. The web site will be running off of the same machine
> that we want to access the credentials on.


I would advice against this as PHP/Apache would need read access to the
linux password file. Although it is possible. You would read the linux
password file with the usernames and passwords and use the same
algorithm for checking the passwords.

I forget exactly how the algorithm for checking works but you can do a
google search and find it.

Mike
Reply With Quote
  #3 (permalink)  
Old 05-16-2005
NC
 
Posts: n/a
Default Re: Authenticate a user using same password as linux password

joltman wrote:
>
> We're working on an intranet site where we will require user's to

only
> be able to access their own page in some instances. Rather than
> introducing another password to the mix, we were thinking about

seeing
> if we could use the same credentials (username and password) as their
> linux credentials. The web site will be running off of the same

machine
> that we want to access the credentials on.


The credentials (the user name and encrypted password) are available
for reading from Linux password file, /etc/password. If you know
what encryption is used on your Linux system and can reproduce it
with PHP, you should be able to authenticate against Linux' user
database.

As to being able "require users to only be able to access their own
page", this is going to be slightly more complicated. Usually, PHP
is configured as an Apache module, so any PHP application runs with
Apache's credentials. So you will have to either put access control
into your application logic or figure out a way to start your
application as a CGI program on behalf of a particular user...

Cheers,
NC

Reply With Quote
  #4 (permalink)  
Old 05-16-2005
Daniel Tryba
 
Posts: n/a
Default Re: Authenticate a user using same password as linux password

joltman <joltman@geocities.com> wrote:
> We're working on an intranet site where we will require user's to only
> be able to access their own page in some instances. Rather than
> introducing another password to the mix, we were thinking about seeing
> if we could use the same credentials (username and password) as their
> linux credentials. The web site will be running off of the same machine
> that we want to access the credentials on.


It's possible but like others have already stated: potenitally dangerous
since apache needs to be able to read the password files (/etc/shadow in
most cases). So use with care: http://pam.sourceforge.net/mod_auth_pam/

Reply With Quote
  #5 (permalink)  
Old 05-16-2005
Ian Taylor
 
Posts: n/a
Default Re: Authenticate a user using same password as linux password

joltman wrote:
> We're working on an intranet site where we will require user's to only
> be able to access their own page in some instances. Rather than
> introducing another password to the mix, we were thinking about seeing
> if we could use the same credentials (username and password) as their
> linux credentials. The web site will be running off of the same machine
> that we want to access the credentials on.


Do the users log in via samba by any chance? if so, you might be able to
use something like winbind and htaccess to authenticate the users.
Obviously wouldn't work outside of the local samba network, though.
Reply With Quote
  #6 (permalink)  
Old 05-16-2005
joltman
 
Posts: n/a
Default Re: Authenticate a user using same password as linux password

Well, they would be logging in from a Windows machine, if that would
work the same way as samba. It wouldn't be a problem only working in
the network, as that's the only place it will be used anyway.

Reply With Quote
  #7 (permalink)  
Old 05-16-2005
Malcolm Dew-Jones
 
Posts: n/a
Default Re: Authenticate a user using same password as linux password

joltman (joltman@geocities.com) wrote:
: Well, they would be logging in from a Windows machine, if that would
: work the same way as samba. It wouldn't be a problem only working in
: the network, as that's the only place it will be used anyway.

I would try to find a unix utility that handles this for you.

I would suggest "su" but I don't know off hand how to pass in the password
without a tty (though I suspect it is possible, perhaps something like
"expect" could do it).

_IF_ you could use su, then you would simply use it with no further ado.
You would call it with the username and password to run a script that does
the work for the user. Either it works if the login is correct, or fails
if it isn't. In either case you would not need access to the password
file, or need to write much code as "su" already does all the work. If
you research then I suspect that there are other utilities that could be
used in a similar manner, the fact that none spring to my mind just means
I have a lousy memory.

If you do this then you would need to protect the passords more carefully
though, because they would be more "valuable" since they access more stuff
than just a web page. That means using HTTPS so noone could snoop the
network and find peoples passwords.



--

This space not for rent.
Reply With Quote
  #8 (permalink)  
Old 05-17-2005
Cristian
 
Posts: n/a
Default Re: Authenticate a user using same password as linux password

You shouldn't do that. it isn't secure at all.

add a script to your system, when a new *nix user is created,then your
system can add the user to an .htpasswd file to be used with apache
mod_auth or something like that.
or better,use a database,ldap...

Reply With Quote
  #9 (permalink)  
Old 05-17-2005
Colin McKinnon
 
Posts: n/a
Default Re: Authenticate a user using same password as linux password

Mike Willbanks wrote:

> joltman,
>> We're working on an intranet site where we will require user's to only
>> be able to access their own page in some instances. Rather than
>> introducing another password to the mix, we were thinking about seeing
>> if we could use the same credentials (username and password) as their
>> linux credentials. The web site will be running off of the same machine
>> that we want to access the credentials on.

>
> I would advice against this as PHP/Apache would need read access to the
> linux password file. Although it is possible. You would read the linux
> password file with the usernames and passwords and use the same
> algorithm for checking the passwords.
>
> I forget exactly how the algorithm for checking works but you can do a
> google search and find it.
>


No it doesn't.

Linux, along with most flavours of *nix now implements PAM - (pluggable
authentication modules) these can be configured to authenticate using
old-fashioned /etc/passwd, shadow passwords, NIS[+], SMB, radius, kerberos
and more.

In order to access some of these resources (specifically shadow passwords)
the process must be running as 'root'. The process does not have to be
apache. It is fairly painless to create a suid program or daemon which
interfaces to PAM - there a couple of GPL programs available for squid (a
web proxy) which do exactly this (although they are setup to process lots
of requests per invocation - a single one may be more appropriate). Try the
squid web pages for more info.

C.
Reply With Quote
  #10 (permalink)  
Old 05-17-2005
joltman
 
Posts: n/a
Default Re: Authenticate a user using same password as linux password

The only problem with that is that we are trying to avoid adding
another password to the mix, as most people already have 3 to deal with
(windows, e-mail, erp program)

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:46 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0