473,383 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Application user login/management

Hello all,

Recently I've been thinking about different methods of managing users
that log into a PostgreSQL-backed application. The users I'm thinking
of are not necessarily DBAs: they're application users that really
shouldn't even be aware that they are being served by the world's most
advanced open source database server. I appreciate any thoughts or
feedback people may have, as I'm trying to decide which is the most
appropriate way to move forward.

Method 1: Use PostgreSQL users and groups.
All application users will (unknowingly) be PostgreSQL users as well.
Restrict access for these users to prevent them from logging into the
PostgreSQL server directly, and limit their access to the DB using the
built-in PostgreSQL access privilege mechanism. Updates occur through
functions; selects are against views or using set returning functions.
This method leverages built-in functionality. Drawbacks I see are that
PostgreSQL users are unique to a cluster, rather that the db. This
means that once a user exists in one db, they exist in all of the dbs.
There might be users with the same name in other dbs, so that name is
no longer available (though of course this can also occur in a single
db as well). Also, it may be desirable to let usernames be retired for
one person, but the user is not deleted, for example if their data is
still required even though they are no longer active. One might want to
allow a new user to be able to use this username, i.e., active
usernames would be unique, rather than usernames in general.

Method 2: Store username/password information as data in tables, using
pgcrypto for authentication
In this scenario, middleware passes username/password combinations to
PostgreSQL and functions within the database use contrib/pgcrypto to
handle authentication. This allows a username to be 'retired' for one
person and assigned to another. Another advantage is that using
PostgreSQL functions for authentication mean that this doesn't need to
be duplicated in middleware. A possible disadvantage is that it
requires pgcrypto, though I don't know how much of a disadvantage this
is, as it is a contrib library that ships with the standard PostgreSQL
package.

Method 3: Store username/password information as data in tables, and
use middleware for authentication
This seems to be the most popular method from what I've seen of open
source packages. One reason for this may be that the middleware is
designed to work with a number of different dbms backends, and
different dbms' have different capabilities with respect to user
management: it's just easier to take care of it in the middleware.

I lean towards the first and second methods, as I like to keep as much
in the server as possible, and portability wrt the database server
isn't as important to me as being able to develop different middleware
against the same data.

Another thing on my mind is security. Any thoughts on the relative
security of the three methods I've outlined above?

Thank you for any and all thoughts on this. I appreciate hearing
other's views.

Regards,

Michael
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #1
3 2294


Michael Glaesemann wrote:
Hello all,

Recently I've been thinking about different methods of managing users
that log into a PostgreSQL-backed application. The users I'm thinking
of are not necessarily DBAs: they're application users that really
shouldn't even be aware that they are being served by the world's most
advanced open source database server. I appreciate any thoughts or
feedback people may have, as I'm trying to decide which is the most
appropriate way to move forward.

Method 1: Use PostgreSQL users and groups.
All application users will (unknowingly) be PostgreSQL users as well.
Restrict access for these users to prevent them from logging into the
PostgreSQL server directly, and limit their access to the DB using the
built-in PostgreSQL access privilege mechanism. Updates occur through
functions; selects are against views or using set returning functions.
This method leverages built-in functionality. Drawbacks I see are that
PostgreSQL users are unique to a cluster, rather that the db. This
means that once a user exists in one db, they exist in all of the dbs.
There might be users with the same name in other dbs, so that name is
no longer available (though of course this can also occur in a single
db as well). Also, it may be desirable to let usernames be retired for
one person, but the user is not deleted, for example if their data is
still required even though they are no longer active. One might want
to allow a new user to be able to use this username, i.e., active
usernames would be unique, rather than usernames in general.
I've seen this method used successfully in some applications, I prefer
to avoid using it as you must also create a PostgreSQL user for each
application user. Instead I use either method 2 or 3 for user
authentication and then use method 1 to restrict the middleware's access
to the database itself (don't give the application more access than it
requires).

Method 2: Store username/password information as data in tables, using
pgcrypto for authentication
In this scenario, middleware passes username/password combinations to
PostgreSQL and functions within the database use contrib/pgcrypto to
handle authentication. This allows a username to be 'retired' for one
person and assigned to another. Another advantage is that using
PostgreSQL functions for authentication mean that this doesn't need to
be duplicated in middleware. A possible disadvantage is that it
requires pgcrypto, though I don't know how much of a disadvantage this
is, as it is a contrib library that ships with the standard PostgreSQL
package.
If you are confident that (a.) you will either run the database server
or (b.) have the authority to require that pgcrypto be installed on the
database for all installations this may be a good solution. Keep in
mind you are limited to the encryption types supported by pgcrypto and
moving to another database solution may be difficult. I also can't
comment on the availability of pgcrypto on Win32 but with PostgreSQL 8
just around the corner the desire might be there to run the DB on
Windows at some point. libmcrypt is currently available in win32 but
I've occasionally seen behavior differences with it on win32 v.s. Unix.

Also keep in mind that if you are not using encrypted database
connections (using PostgreSQL's built in SSL support or SSH tunneling or
another technique) you may be sending user's passwords across the
network in plain text for the database to use. I would either insure
that all connections will be encrypted or preferably at hash the
password with at least SHA-1 on the application side and pass that as
the password to the back-end, SHA-1 is available in almost all languages
these days; this technique may also remove the requirement of using
pgcrypto on the back-end.

If you are going to use multiple interfaces to the application this may
be the best choice as you don't have to re-implement the security system
for each client application.
Method 3: Store username/password information as data in tables, and
use middleware for authentication
This seems to be the most popular method from what I've seen of open
source packages. One reason for this may be that the middleware is
designed to work with a number of different dbms backends, and
different dbms' have different capabilities with respect to user
management: it's just easier to take care of it in the middleware.

I lean towards the first and second methods, as I like to keep as much
in the server as possible, and portability wrt the database server
isn't as important to me as being able to develop different middleware
against the same data.
This is the technique I've used pretty often, it gives me very powerful
application integration and allows me to more easily support different
back-ends if the customer so chooses (I currently go with PostgreSQL and
SQLite). The biggest drawback you've already touched is the system is
implemented in the middleware so other interfaces to the application
must also implement the security system.
Another thing on my mind is security. Any thoughts on the relative
security of the three methods I've outlined above?
Don't store passwords in plain text, don't pass anything sensitive over
the wire unencrypted (preferably nothing at all but sometimes that isn't
feasible). Like I mentioned above, I don't see method one as an
application security method but rather as a way to augment the security
of methods two or three. YMMV and some good planning now might help you
avoid re-implementing your system later.
Thank you for any and all thoughts on this. I appreciate hearing
other's views.

Regards,

Michael
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #2
On Sun, 2004-10-03 at 22:23, Michael Glaesemann wrote:
Hello all,

Recently I've been thinking about different methods of managing users
that log into a PostgreSQL-backed application. The users I'm thinking
of are not necessarily DBAs: they're application users that really
shouldn't even be aware that they are being served by the world's most
advanced open source database server. I appreciate any thoughts or
feedback people may have, as I'm trying to decide which is the most
appropriate way to move forward.


The method I worked with was similar to your method 3, of maintaining
the info in tables, but more complex, and easier to handle for large
numbers of users.

We built an OpenLDAP server and wrote some scripts to maintain that and
allow for group editing. This structure existed completely outside of
the either the database or application. Then, apache handled all the
authentication through ldap authentication. The application was give
standard libs / includes that allowed for pushing a username up against
any group, etc... So that all the yes / no of being allowed somewhere or
allowed to do something was kept in the LDAP database.

This allowed us to allow owners of given groups to edit them by
themselves, i.e. the Director of Marketing could both add other junior
admins to the marketing groups, and could edit members of all the
marketing groups. Note that these groups / authentication are then
accessible to all other applications in the company that are LDAP
aware. And there's a lot of stuff that can work with LDAP and / or
apache/http auth against LDAP authentication.

This allows you to scale your authentication and group management
independently of any scaling issues with your application servers.
Since single master / multi slave OpenLDAP is a pretty easy thing to
implement, the only applications that need to access the master can be
set to the ldap editing applications (group editor, update scripts,
etc...) while standard old authentication can be pointed at one or more
slaves.
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #3

Thank you, both Scott and Jason, for your responses. You both brought
up things I hadn't thought about. I've included snippets of their posts
below.
On Sun, 2004-10-03 at 22:23, Michael Glaesemann wrote:
Recently I've been thinking about different methods of managing users
that log into a PostgreSQL-backed application. The users I'm thinking
of are not necessarily DBAs: they're application users that really
shouldn't even be aware that they are being served by the world's most
advanced open source database server.

On Oct 4, 2004, at 1:48 PM, Scott Marlowe wrote:
We built an OpenLDAP server and wrote some scripts to maintain that and
allow for group editing. This structure existed completely outside of
the either the database or application. Then, apache handled all the
authentication through ldap authentication. <snip /> This allows you to scale your authentication and group management
independently of any scaling issues with your application servers.
Since single master / multi slave OpenLDAP is a pretty easy thing to
implement, the only applications that need to access the master can be
set to the ldap editing applications (group editor, update scripts,
etc...) while standard old authentication can be pointed at one or more
slaves.
Method 2: Store username/password information as data in tables,
using pgcrypto for authentication


On Oct 4, 2004, at 1:53 PM, Jason Sheets wrote:
If you are confident that (a.) you will either run the database server
or (b.) have the authority to require that pgcrypto be installed on
the database for all installations this may be a good solution. Keep
in mind you are limited to the encryption types supported by pgcrypto
and moving to another database solution may be difficult. I also
can't comment on the availability of pgcrypto on Win32 but with
PostgreSQL 8 just around the corner the desire might be there to run
the DB on Windows at some point. libmcrypt is currently available in
win32 but I've occasionally seen behavior differences with it on win32
v.s. Unix.

Also keep in mind that if you are not using encrypted database
connections (using PostgreSQL's built in SSL support or SSH tunneling
or another technique) you may be sending user's passwords across the
network in plain text for the database to use. I would either insure
that all connections will be encrypted or preferably at hash the
password with at least SHA-1 on the application side and pass that as
the password to the back-end, SHA-1 is available in almost all
languages these days; this technique may also remove the requirement
of using pgcrypto on the back-end.


As with many things, there are tradeoffs. As I'm going to be running
the database server, I think I'm going to push the pgcrypto solution as
far as it will go. Thanks again, to both of you, for your comments.
Much appreciated!

Michael
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: | last post by:
Please help. After a number of wrong turns and experiments I need advice on login management system to secure our web pages without inconveniencing our visitors or our internal staff. What I...
1
by: Chris | last post by:
1.) I have a web app that will be primarilary used by internal (internal network resources) users, approx. 40-50 at any one time, then there will be external (external coming into the internal...
1
by: Damien | last post by:
Hey guys, I'm currently developing a reasonably sized application, which is expected to grow in the future. At the centre is the User login facility - everyone using the site must log in....
6
by: B B | last post by:
Okay, here is what's happening: I have a reasonably fast laptop (1.4 GHz Mobile M, so comparable to 2.5GHz P4) doing .net development. Running Windows XP pro, SP2 IIS is installed and running...
9
by: Graham | last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and...
4
by: Preben Zacho | last post by:
Hi there The scenario I got is this: I have created a Windows application in VS and I want to deploy it to another machine running Windows Vista. Since I have no control over this other machine,...
4
by: benjaminkang | last post by:
I'm very new to Coldfusion and action script, but due to job requirements, i got allocated the task of developing a cfm page where the user logs in using the embedded swf file and everything was...
0
by: benjaminkang | last post by:
I'm very new to Coldfusion and action script, but due to job requirements, i got allocated the task of developing a cfm page where the user logs in using the embedded swf file and everything was...
2
by: sangam56 | last post by:
Hi all. I have a web application developed in ASP.NET. I have my data file aspnetdb.mdf kept in App_Data folder. I have also created msi windows installer and I also installed it. It is installed...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.