3

There are one project using Python Django, another stand alone project using python cgi. Both has it own user auth. module. What would be a simple way to merge user management together? I mean signin already built in python cgi, i want to use the same signin for python django, how i can pass authenticated user_id and username from python cgi to python django.currently i am using mysql database for both application

usually in django we will passing authenticated user as follows in views.py

user = request.user

But signin is built using python cgi, how can i pass athenticated user from python cgi to python django(views.py)

Thanks

2
  • Perhaps create a custom authentication backend in your Django app, which sends authentication requests to your cgi app? Commented Dec 7, 2018 at 12:19
  • share the code what have you tried Commented Dec 17, 2018 at 14:09

2 Answers 2

1

I think you can use one of the Django authentication middleware like RemoteUserMiddleware or PersistentRemoteUserMiddleware.

They are middlewarer for utilizing Web server provided authentication.

You can see Authentication using REMOTE_USER for usage details.

When the Web server takes care of authentication it typically sets the REMOTE_USER environment variable for use in the underlying application. In Django, REMOTE_USER is made available in the request.META attribute. Django can be configured to make use of the REMOTE_USER value using the RemoteUserMiddleware or PersistentRemoteUserMiddleware, and RemoteUserBackend classes found in django.contrib.auth.

Sign up to request clarification or add additional context in comments.

Comments

0

you need to do a single sign on, take a look at this

https://github.com/namespace-ee/django-rest-framework-sso

personally i use an ldap database to store the users, everytime a user is accessing my app for the first time, a query is sent to a server where i have a rest api set up which verifies if the user logged in before, and didn't log out.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.