I suggest looking at this from the perspective of the basic principles involved.
What does it mean to be “authenticated” in the context of a web application?
When you authenticate to a Django site, you get a cookie containing a value for a sessionid.
The session associated with that sessionid will have a User object associated with that session. It’s the AuthenticationMiddleware that associates a User object with the HttpRequest being submitted (request.user
).
So, what you need to do from a technical perspective will depend upon your level of integration desired.
In the common / generic case, multiple logins from a single source is handled by one of the “token-passing” or “ticket-passing” protocols such as CAS (which is what we use for an SSO solution), or OAuth.
However, in a situation such as yours, you don’t specifically need as complete or comprehensive solution as one of those. Assuming both projects have access to both project’s cookies, you could create your own middleware that gets the sessionid cookie for the other project, and then issues some type of http request to the other project with that sessionid. (This implies that you’ve also created a special view to use as the authentication endpoint.)
If you don’t want to create or install custom middleware, and you only have one or two views where this is necessary, you could add this test to the view on an as-needed basis.
Or, if both projects can have access to the other project’s database, you don’t need to make it an API call - you could have each project query the other project’s session cache to read the sessionid
to find the associated User
object.
But, all these “simpler” solutions do depend upon the cookies being visible to both projects. If that’s not the case, then you would need to use (or implement) one of the more sophisticated solutions. (I’ll also point out that having cookies visible to multiple domains always creates the possibility of creating an CSRF vulnerability in your system. Whether that’s a concern is only something you can determine.)