Django with DRF and OAUTH2.0 - python

I'm trying development a system with Django and Django Rest Framework, since i started i found out two problem, first for authentication second for permissions, i want use OAuth2.0 to make it possible, and django-oauth-toolkit.
Now, i wanna know how i authenticate a user and give the right for his, if he is admin or normal user?

Related

Can I replace django admin panel login code by Amazon Cognito?

I want to replace admin or superuser login by cognito credentials. Is it possible to do that?
If you are reading this, you probably googled "aws cognito django" xD.
I just want to share what I did in order to get this thing to work:
Django-Warrant. Great aws cognito wrapper package.
Make sure to understand your current User model structure. If you use custom user model, don't forget to map it using COGNITO_ATTR_MAPPING setting.
Change your authentication to support 3rd party connectivity. When you get from the client some Cognito token, convert it into your own token using oAuth/JWT/Session.
Rethink your login/register process. Do you want different registration? The django-warrant package supports it...
At the end of the day, this is a GREAT solution for fast authentication.
AWS Cognito as Django authentication back-end for web site
Also https://pypi.org/project/django-cognito-jwt/ django-cognito-jwt could help make this easier to setup

Django online users with rest framework

I had used django-online-users to get online users and it worked fine. But the problem is that i am not able to get online users in django rest framework i.e. users making api calls from react to backend server.
I am only getting direct logged in users log in admin panel.
Please suggest a way to use it with django rest framework.
Thanks.

Push notification in django rest

I am working on a attendance registration system where a user of an office can make a leave request. When any user makes a leave request, it must be notified to admin. How do I implement it ?
I had seen django-fcm for push notification. But I am using django rest framework . Can I implement django-fcm with django rest ?
If any tutorials link would be more helpful
This is not a very hard, clone the fcm-django-web-demo project and try coding in Django shell...

Is there a way to login into django admin using external 3rd party authentication

I have a requirement to migrate from php to django. I was authentication the user over a rest call's response in php. Where I would pass the user name and password and it would tell me if the user is authenticated or not in a form of JSON response.
I would like to make use of the same concept here with django admin, I have seen the custom-authentication that django provides, in which it creates a new user into django's user tables after checking the authenticity of the user from my existing table. But that is not what i am looking for.
And this rest call is not any of the social websites but a different stand alone system itself. So cant make use of the different plugins available on google search.

What is the right way to use django-allauth with tastypie?

I'm writing a Django app that uses django-allauth for Facebook integration, and uses django-tastypie for a backend for an iOS app. The iOS app will use the native Facebook iOS SDK. I'd like to be able to sign up and verify both Facebook and non-Facebook users from the iOS app, in addition to the website.
The issue is that django-allauth doesn't seem to have an API that can be accessed externally. The only clean way to plugin to allauth's functionality seems to be via Django template tags. Is there a way I can expose this functionality to be used with tastypie?
Django-allauth is all open source, so I've tried to parse through the code. My initial idea is to authenticate users on the iOS side using the native Facebook SDK, and then manually fill in information for SocialAccount, SocialToken, and add the SocialAccount to SocialApp (those are all django-allauth models). However, that seems to be quite a hacky solution. I'd love a way to cleanly create all those models given a Facebook ID, or something similar.
Update:
There's been some discussion concerning this issue on the GitHub. Basically, there's no built-in functionality yet. I'm going to whip up a custom solution that only deals with Facebook (because that's all I'm using in my application). I'll post what I did here later if it works.
Quick look into django-allauth shows that they are using SocialAccount model to hold data on specific method of authentication and type of social account.
You need to create an API endpoint based on SocialAccount model. You need to pass there variables like: account type (facebook, local, twitter etc), additional auth variables needed by social auth providers. Then, in your code you can create SocialAccount model instances, feed with data received from API endpoint call and trigger corresponding auth call via django-allauth. Finally you should return result of your auth call.
I don't see a big reason to use django-allauth for local/facebook auth only, with some small effort you can have whole range of social auth providers.
I used requests library to deal with facebook API and it works great, I think no social login plugin for Django works for others but the author, if you want to do something seriously.
PS. I used django-rest-framework to build the rest backend for mobile apps, also including local account login and social site login.

Categories

Resources