简体   繁体   中英

django-allauth with multiple domains

I am creating a web application that will support several domains. For example, if my app were named www.webapp.com , I'd also have numerous customers mapping their domains to my site via DNS CNAME mappings, ie webapp.yourdomain.com CNAME www.webapp.com and foo.anotherdomain.com CNAME www.webapp.com , etc...

I want users to authenticate against my app via Google or Facebook (OAuth 2.0) - without me (or the domain owners) having to create a separate Google/Facebook app per mapped domain. Ideally, I would have the base domain act as a broker and redirect to the appropriate mapped domain when responding to the callback url. For example, a user visiting webapp.yourdomain.com/accounts/facebook/login would authenticate against Facebook with a callback url going to www.webapp.com/accounts/facebook/login/callback . When processing the request, I could find the appropriate context, and redirect to webapp.yourdomain.com/accounts/facebook/login/callback where the real authentication would take place (and domain-specific auth cookies would be set).

So, is this doable in django-allauth? How much hacking would it require? Or, is there another social authentication solution for Django that would be easier to implement this in?

You should use Django sites framework together with django-allauth.

Consumer keys, tokens make use of the Django sites framework. This is especially helpful for larger multi-domain projects, but also allows for for easy switching between a development (localhost) and production setup without messing with your settings and database.

Just configure each social app in the admin backend.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM