mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-30 01:49:50 +03:00
feature(Secure API docs): added new flag to switch on/off the authentication needed to view the documentation of the APIs
This commit is contained in:
parent
7c6e34c14f
commit
3799a8b23a
|
@ -1,4 +1,5 @@
|
|||
from django.conf.urls import include, url
|
||||
from django.contrib.auth.decorators import login_required
|
||||
|
||||
from rest_framework.renderers import (
|
||||
CoreJSONRenderer, DocumentationRenderer, SchemaJSRenderer
|
||||
|
@ -77,8 +78,14 @@ def include_docs_urls(
|
|||
authentication_classes=authentication_classes,
|
||||
permission_classes=permission_classes,
|
||||
)
|
||||
urls = [
|
||||
url(r'^$', docs_view, name='docs-index'),
|
||||
url(r'^schema.js$', schema_js_view, name='schema-js')
|
||||
]
|
||||
if api_settings.SECURE_DOCS is False:
|
||||
urls = [
|
||||
url(r'^$', docs_view, name='docs-index'),
|
||||
url(r'^schema.js$', schema_js_view, name='schema-js')
|
||||
]
|
||||
else:
|
||||
urls = [
|
||||
url(r'^$', login_required(docs_view), name='docs-index'),
|
||||
url(r'^schema.js$', login_required(schema_js_view), name='schema-js')
|
||||
]
|
||||
return include((urls, 'api-docs'), namespace='api-docs')
|
||||
|
|
|
@ -128,6 +128,9 @@ DEFAULTS = {
|
|||
'retrieve': 'read',
|
||||
'destroy': 'delete'
|
||||
},
|
||||
|
||||
# Documentation
|
||||
'SECURE_DOCS': False
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user