Store database users in custom table

Store database users in custom table

am 20.03.2010 00:19:10 von Antoine POPINEAU

This is a cryptographically signed message in MIME format.

--------------ms070003040605040403050409
Content-Type: multipart/mixed;
boundary="------------040100060804010000050606"

This is a multi-part message in MIME format.
--------------040100060804010000050606
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

Hi,

I am developping a Java application, and using a PostgreSQL backend=20
database. Theorically, there might be lots of users, each with=20
potentially different permissions over the different tables.

I could add those user to the database with a classic CREATE USER, but=20
that doesn't seem efficient to me, since I've already got a custom table =

with users data and, amongst others, password.

So my question is simple (the answer might not be, though): is there a=20
possibility to tell Postgres to fetch user logins and passwords in a=20
custom table (perhaps respecting a certain schema) instead of the=20
default location?

Thank you.

Antoine POPINEAU.

--------------040100060804010000050606
Content-Type: text/x-vcard; charset=utf-8;
name="apognu.vcf"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="apognu.vcf"

begin:vcard
fn:Antoine POPINEAU
n:POPINEAU;Antoine
org:Antoine POPINEAU
adr:;;24 rue du Berry;Chevilly-Larue;;94550;France
email;internet:apognu@akegroup.org
tel;cell:+33 6 84 83 01 34
x-mozilla-html:FALSE
url:http://www.apognu.net
version:2.1
end:vcard


--------------040100060804010000050606--

--------------ms070003040605040403050409
Content-Type: application/pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: S/MIME Cryptographic Signature

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEH AQAAoIIHEDCC
A4QwggJsoAMCAQICAUgwDQYJKoZIhvcNAQEFBQAwVjESMBAGA1UEChMJQUtF IEdyb3VwMQsw
CQYDVQQGEwJGUjESMBAGA1UEAxMJQUtFIEdyb3VwMR8wHQYJKoZIhvcNAQkB FhBha2VAYWtl
Z3JvdXAub3JnMB4XDTEwMDEyOTE4MjUwNVoXDTExMDEyOTE4MjUwNVowgY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Ab8BGmJ1YWPMoTalnPxVPW03F9o6bzBpr7d dAms8slxuk+E
Eci4PH42B+b370hfLB1Ps4ckKP++MFNJU4PdDTmJhpFUc6POVcl8QZnHt9di luRsmIFlg1a1
3rtRAX+TztO4oonHiXM0GgAAAAAAAA==
--------------ms070003040605040403050409--

Re: Store database users in custom table

am 22.03.2010 19:09:20 von Scott Mead

--0016e6d971029f5e6404826798b0
Content-Type: text/plain; charset=ISO-8859-1

2010/3/19 Antoine POPINEAU

> Hi,
>
> I am developping a Java application, and using a PostgreSQL backend
> database. Theorically, there might be lots of users, each with potentially
> different permissions over the different tables.
>
> I could add those user to the database with a classic CREATE USER, but that
> doesn't seem efficient to me, since I've already got a custom table with
> users data and, amongst others, password.
>
> So my question is simple (the answer might not be, though): is there a
> possibility to tell Postgres to fetch user logins and passwords in a custom
> table (perhaps respecting a certain schema) instead of the default location?
>

There isn't, but the question to ask yourself is:

Do you want application level users to be able to login to the database
directly???

If the answer is yes, then you may want to use a centralized authentication
mechanism like LDAP. (postgres can use LDAP authentication).


If the answer is no, then build your own auth scheme in the application
and have the application login to the database as a specific user ... i.e.

user bob.foo logins to web interface
provides password: login123

java app says: Connect to database,
user: app_read
pass: %32sd$s2

Java app says, select user_id, password from users where user_name =
'bob.foo'
java app runs:
if result.password = user_entered_password
then
login allowed
else
denied
end if

Obviously, you'd want to use a hash of the password to avoid sending it
over the wire, but I think you get the idea.


--Scott M



--Scott M

>
> Thank you.
>
> Antoine POPINEAU.
>

--0016e6d971029f5e6404826798b0
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

2010/3/19 Antoine POPINEAU <=
;>
<=
br>
:1px #ccc solid;padding-left:1ex;">
Hi,



I am developping a Java application, and using a PostgreSQL backend databas=
e. Theorically, there might be lots of users, each with potentially differe=
nt permissions over the different tables.



I could add those user to the database with a classic CREATE USER, but that=
doesn't seem efficient to me, since I've already got a custom tabl=
e with users data and, amongst others, password.



So my question is simple (the answer might not be, though): is there a poss=
ibility to tell Postgres to fetch user logins and passwords in a custom tab=
le (perhaps respecting a certain schema) instead of the default location? r>

There isn't, but the question to ask y=
ourself is:

=A0Do you want application level users=
to be able to login to the database directly???


=A0If the answer is yes, then you may want to use a centralized authenticat=
ion mechanism like LDAP. (postgres can use LDAP authentication).
=


  If the answer is no, then build your ow=
n auth scheme in the application and have the application login to the data=
base as a specific user ... i.e.


user bob.foo logins to web interface
pr=
ovides password: login123

  java app says: =A0=
Connect to database,
=A0user: app_read
=A0pass: %32sd$s2
=
=A0

   Java app says, select user_id, password from users where user_n=
ame =3D 'bob.foo'
   =A0java app runs:
=A0i=
f result.password =3D user_entered_password
   =A0then
<=
div>   =A0 =A0 =A0login allowed

   =A0else
   =A0 =A0 =A0 denied
   =
=A0end if

  Obviously, you'd want to use a=
hash of the password to avoid sending it over the wire, but I think you ge=
t the idea.



--Scott M
  =A0
   =
=A0 =A0 =A0   

=A0--Scott M
lass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;=
padding-left:1ex;">


Thank you.



Antoine POPINEAU.




--0016e6d971029f5e6404826798b0--