Coder Social home page Coder Social logo

Comments (5)

alexislg2 avatar alexislg2 commented on June 9, 2024

OK quite easy with your plugin:
Just creat a route /api/get-user that return a JWT from the given user

then curl -H "Authorization: Bearer <backend_name> <access_token>" http://localhost:8000/api/get-user

And that's it! Thanks for this amazing plugin

from django-rest-framework-social-oauth2.

kinesii avatar kinesii commented on June 9, 2024

@alexislg2 Can you please elaborate about how you achieved this?

from django-rest-framework-social-oauth2.

alexislg2 avatar alexislg2 commented on June 9, 2024

@kinesii What exactly do you need?

My api_view.py looks like:

from rest_framework.decorators import api_view, permission_classes


@api_view(['POST'])
@permission_classes((AllowAny, ))
def obtain_jwt_token_from_social_provider(request):
    """ This route must be called by the mobile app """
    # Use a custom function to generate a JWT token from a django user:
    jwt = generateJwtForUser(request.user)
    return JsonResponse({"jwt_token": jwt})

from django-rest-framework-social-oauth2.

assembledadam avatar assembledadam commented on June 9, 2024

@alexislg2 Does the request to /api/get-user contain any authentication in itself, or just the user data?

If just the user data, this is very insecure. An attacker could simply call that endpoint with someone's user and get infinite access to their account.

A better way would be to extend your django-rest-framework-social-oauth2 endpoint to return a JWT instead of the standard access token on the initial authentication request.

from django-rest-framework-social-oauth2.

alexislg2 avatar alexislg2 commented on June 9, 2024

@assembledadam the /api/get-user requests to provide the access_token provided by the OAuth backend. So an attacker would need this access_token so he would need to have the Google/Facebook password of the user he wants to hack

from django-rest-framework-social-oauth2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.