Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • D drf_simplejwt_with_oidc
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

  • ITS INF IAM
  • drf_simplejwt_with_oidc
  • Issues
  • #1

Closed
Open
Created Jul 26, 2021 by Kyle Cochrane@kylepcMaintainer

Consider implementing function views as viewsets to allow use with DRF router

Related issue on the DRF repository - doesn't seem like the maintainer has interest in extending routers to handle individual views: https://github.com/encode/django-rest-framework/issues/3931

As is, can't register either of the token endpoints with a DRF router because the router classes only accept viewsets:

# instead of..
urlpatterns = [
    path('api/token/', OIDCTokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
]

# Something like this is not possible
router = routers.DefaultRouter()
router.register(r'api/token/', OIDCTokenObtainPairView.as_view(), basename='token_obtain')
router.register(r'api/token/refresh/', TokenRefreshView.as_view(), basename='token_refresh'),

urlpatterns = [
    path('', include(router.urls)),
]

A benefit we would get out of using a router is the browsable api it provides, potential downside is the odd way we'll have to inherit and route verbs on the viewset: (from: https://github.com/encode/django-rest-framework/issues/3931#issuecomment-538030520)

class AuthTokenViewSet(ObtainAuthToken, ViewSet):
    def create(self, request, *args, **kwargs):
        # note that we need to call super here, so that we call `ObtainAuthToken.post`
        # instead of the `post` method set by `ViewSet.as_view()`
        return super().post(request, *args, **kwargs)
Assignee
Assign to
Time tracking