fnakstad / angular-client-side-auth

One way to implement authentication/authorization in Angular applications
http://angular-client-side-auth.herokuapp.com/
MIT License
1.63k stars 346 forks source link

Integration with Django #94

Closed pramodk closed 9 years ago

pramodk commented 9 years ago

Hello,

Is it possible to integrate this type of Angular app with Django? I am new to Angular and just started working on porting our Django app to single page app with Angular. Currently I have Django web app with social authentication implemented with python-social auth. Could you provide some hints for integration?

Thanks, Pramod

fnakstad commented 9 years ago

Yep! It should work, but you need to implement the server-side in Python then (So, pretty much replace the Node.js code in the server folder with Django/Python). Most notably you need to set the up a cookie containing a JSON document with the current user in the HTTP response you use to serve the Angular app payload. You can see how this is done here. Let me know how it goes, and good luck with your project!

PS! If you just want to emulate the code in this repo I recommend looking in to Flask as it is more close philosophy to Node/Express than Django, and thus should be easier to port over to.

rebelliard commented 9 years ago

You can also see how it's implemented here: https://github.com/Tivix/angular-django-registration-auth/blob/master/app/scripts/services/djangoAuth.js

fnakstad commented 9 years ago

Thanks for providing an actual example, @rebelliard :) Now I know where to point people with the same question in the future.