Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django REST Framework - OAuth2 Consumer API from external provider

I am trying to authorize users to access some resources from my Django REST framework API using Oauth2.

Most answers about Oauth2 and API deal with making the API a provider.

But I plan to share an Oauth2 provider with many REST APIs, and I can't figure out how to consume it (not how to provide Oauth2).

I have no idea how a user can log in on the provider SSO, and then communicate its token to my consuming API, which must authenticate users against my provider (getting back its information, mainly authorizations).

Does anyone have a clue on how to consume Oauth2 from Django REST framework?

Figure:

[User] -> [My API] <-> [Oauth2 provider (with django-oauth-provider)] <-> [Active Directory / anything ]

like image 835
ArTiSTiX Avatar asked Jun 26 '14 12:06

ArTiSTiX


1 Answers

Looking at the code at https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/authentication.py#L290 it seems just not possible. The django-rest-framework internally accesses provider's database tables to check for tokens and authenticates requests using these data.

Which for me kinda defeats the purpose of OAuth at all, but here we go.

like image 62
zgoda Avatar answered Oct 08 '22 14:10

zgoda