只向公众公开/token/endpoint:Djangooauth工具包



我使用的这个插件不需要任何用户创建应用程序,任何OAuth应用程序只能由超级用户添加。

我已将其包含在urlpatterns

path('auth/', include('oauth2_provider.urls', namespace='oauth2_provider')),

这将向公共公开所有urls,包括用于管理应用程序的要点

auth/ ^authorize/$ [name='authorize']
auth/ ^token/$ [name='token']
auth/ ^revoke_token/$ [name='revoke-token']
auth/ ^introspect/$ [name='introspect']
auth/ ^applications/$ [name='list']
auth/ ^applications/register/$ [name='register']
auth/ ^applications/(?P<pk>[w-]+)/$ [name='detail']
auth/ ^applications/(?P<pk>[w-]+)/delete/$ [name='delete']
auth/ ^applications/(?P<pk>[w-]+)/update/$ [name='update']
auth/ ^authorized_tokens/$ [name='authorized-token-list']
auth/ ^authorized_tokens/(?P<pk>[w-]+)/delete/$ [name='authorized-token-delete'] 

我只想让公众使用/token/端点来生成访问令牌和刷新令牌。

如何防止其他端点公开,并仅允许来自管理面板

从您的urls.py中删除包url patterns,并明确提到url为,

from oauth2_provider.views import TokenView
urlpatterns = [
path('auth/', include('oauth2_provider.urls', namespace='oauth2_provider')),# remove this line
path('auth/token/', TokenView.as_view(), name="token"),
]

最新更新