urbanplatform / django-keycloak-auth

Middleware to allow authorization using Keycloak and Django for django-rest-framework (DRF). This package should only be used in projects starting from scratch, since it overrides the users' management.
MIT License
32 stars 14 forks source link

[docs] how to register new user from Django to keyCloak and sign-in - JWT #45

Closed yalattas closed 1 year ago

yalattas commented 1 year ago

Is your feature request related to a problem? Please describe. I am still new to Django and KeyCloak, I integrated Django with KeyCloak container thanks to your repo. Now I am trying to implement signing up, sign in, sign out and token verification from Django to KeyCloak as KeyCloak is the source of truth when it comes to IAM but I am not finding a clear documentation of how to do so.

Describe the solution you'd like I used to extend AUTH_USER_MODEL to my AUTH MODEL before( ex: AUTH_USER_MODEL='app.CustomUser')

Now it's set to AUTH_USER_MODEL = "django_keycloak.KeycloakUserAutoId"

Currently if any user sign up in KeyCloak will grant access to django via REST endpoints, but I don't how can I make Django verify their identity via REST. it's done via GUI and I saw the users and synced it to KeyCloak container. But now I want to build up a full IAM flow.

I am expecting KeyCloak to generate JWT token to be provided to frontend to use it, then as a backend I need to verify the TOKEN and authorization. Not only authentication

Describe alternatives you've considered Going back to Auth model with no keyCloak but I am still studying how can I implement my requirements

Additional context I am stuck in here, I don't know how can I login or verify against keyCloak with dynamic way. So, if I changed keyCload later on. I should be modifying service layer and not REST layer

from rest_framework.parsers import JSONParser
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
# Create your views here.
class LoginView(APIView):

    def post(self, request):
        # serializer = LoginSerializer(data=request.data)
        # serializer.is_valid(raise_exception=True)
        # user = UserService.login(username=data.username, password=data.password)
        return Response({'message':'validate'}, status=status.HTTP_202_ACCEPTED)
moritz89 commented 1 year ago
  1. Your use-case of changing the AUTH_USER_MODEL is not supported, but might work. YMMV
  2. If you find a way to solve your problem, feel free to raise an MR with improvements to the docs or a link to a more thorough tutorial

I do not use the REST API, so won't be able to help you in that aspect

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 7 days with no activity.