Ah, OK, so you want: (1) To authenticate as a PostgreSQL user; (2) To connect to
the database as that user.

As I said, (1) is probably possible with Apache+mod_auth_pgsql plus
RemoteUserBackend. For (2), you need to create a custom database backend.

Antonis Christofides
http://djangodeployment.com

On 2016-11-23 12:28, Danny Remmerswaal wrote:
> I indeed want to authenticate against my PostgreSQL users instead of the
> "default" table-based login, so I don't have to re-write my user-bound
> procedures and triggers. But I also want the admin interface implemented in my
> web application. Ideally, the "user" and "password" in my database connection
> string in settings.py would change based on the user credentials supplied when
> logging in, but I'm not sure if that's possible. Another option I thought of
> was having two database definitions, one of which I use when I login as an
> admin and the other when I login as an "analyst". If this is not possible
> within the timeframe I have, I'd have to go with the second option, but it
> wouldn't be my preferred choice.
>
> Hopefully this explains it a bit more! If there's anything else you need to
> know, please ask.
>
> With kind regards,
>
> Danny
>
> Op dinsdag 22 november 2016 16:14:50 UTC+1 schreef Antonis Christofides:
>
>     What you want is not entirely clear. Do you want to authenticate against
>     your PostgreSQL users instead of the django.contrib.auth users? If yes,
>     you need to customize your authentication [1]. One solution would be to
>     write a custom authentication backend, but you might also be able to use
>     RemoteUserBackend [2] together with Apache and mod_auth_pgsql.
>
>     Or do you want to import PostgreSQL users and groups into the
>     django.contrib.auth tables and use those from now on? This should be
>     possible with some SQL (INSERT INTO auth_user (id, first_name, last_name,
>     email, ...) SELECT ... FROM [wherever PostgreSQL keeps its users]), but
>     the "password" field might be tricky to transfer.
>
>     I know these don't answer all your questions, but you need to explain a
>     bit more.
>
>     Regards,
>
>     Antonis
>
>     [1] https://docs.djangoproject.com/en/1.10/topics/auth/customizing/
>     <https://docs.djangoproject.com/en/1.10/topics/auth/customizing/>
>     [2]
>     
> https://docs.djangoproject.com/en/1.10/ref/contrib/auth/#django.contrib.auth.backends.RemoteUserBackend
>     
> <https://docs.djangoproject.com/en/1.10/ref/contrib/auth/#django.contrib.auth.backends.RemoteUserBackend>
>
>     Antonis Christofides
>     http://djangodeployment.com
>
>     On 2016-11-22 14:52, Danny Remmerswaal wrote:
>>     Hey guys,
>>
>>     I'm working on a Django project which has a native PostgreSQL database,
>>     filled with schemes that contain both read-only and normal tables and
>>     with it's own user- and group roles.
>>
>>     After manually changing the search_path variable, I have managed to
>>     import my current models by running the migrate.inspectdb command and
>>     improved the generated models by sorting, changing primary keys etc.
>>     Django's automatic admin interface added new tables which can contain
>>     users, but ideally that's not what I want for my project. I'd rather have
>>     my current login- and group roles defined in PostgreSQL implemented in
>>     Django, because there are some already defined restrictions and triggers
>>     implemented in my PostgreSQL database that use these user- and group 
>> roles. 
>>
>>
>>     Is there any convenient way to import the already defined user- and group
>>     roles in PostgreSQL so they work with Django? 
>>     As a start I'd like a login page that based on supplied credentials
>>     grants access to my database with defined users that are part of the
>>     group "analyse" (I.E cevoo).
>>     I've included an image that shows my database schemes and user/groups.
>>     Hopefully you guys can help me out!
>>
>>     With kind regards,
>>
>>     Danny
>>     -- 
>>     You received this message because you are subscribed to the Google Groups
>>     "Django users" group.
>>     To unsubscribe from this group and stop receiving emails from it, send an
>>     email to django-users...@googlegroups.com <javascript:>.
>>     To post to this group, send email to django...@googlegroups.com
>>     <javascript:>.
>>     Visit this group at https://groups.google.com/group/django-users
>>     <https://groups.google.com/group/django-users>.
>>     To view this discussion on the web visit
>>     
>> https://groups.google.com/d/msgid/django-users/ddbd5a11-91fa-4411-b084-306b59b39e95%40googlegroups.com
>>     
>> <https://groups.google.com/d/msgid/django-users/ddbd5a11-91fa-4411-b084-306b59b39e95%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>     For more options, visit https://groups.google.com/d/optout
>>     <https://groups.google.com/d/optout>.
>
> -- 
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com
> <mailto:django-users+unsubscr...@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3681775d-f0d1-43d3-bd2d-f480f323be5a%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/3681775d-f0d1-43d3-bd2d-f480f323be5a%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0e477c2d-1a1c-04f9-735a-98d9c27c86c4%40djangodeployment.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to