Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

DRS docs break with CSP that blocks inline scripts #434

Closed
groovecoder opened this issue Apr 21, 2016 · 4 comments
Closed

DRS docs break with CSP that blocks inline scripts #434

groovecoder opened this issue Apr 21, 2016 · 4 comments

Comments

@groovecoder
Copy link

(See mozilla-services/push-dev-dashboard#181 for my context)

In my settings.py, I have:

...
ROOT_URLCONF = 'dashboard.urls'
...
INSTALLED_APPS = [
    ...
    'rest_framework',
    'rest_framework_swagger',
    ...
]
...

In my dashboard.urls I have:

urlpatterns = [
    ...
    url(r'^api/docs/', include('rest_framework_swagger.urls')),
    url(r'^api/v1/', include('api.urls')),
    ...
]

urlpatterns += i18n_patterns(
    # our app urls
    url(r'^$', dashboard_views.Home.as_view(), name='home'),
    url(r'^push/', include('push.urls')),
    url(r'^accounts/login/$', dashboard_views.Login.as_view(), name='login'),
)

And in my api.urls I have:

...
router = routers.DefaultRouter()
router.register(r'domains', DomainAuthorizationViewSet)
router.register(r'push-apps', PushApplicationViewSet)

urlpatterns = [
    url(r'^', include(router.urls))
]

But, when I go to my /api/docs/ url I don't see any of the endpoints registered in api.urls?

swagger-ui-empty

And I can't tell where the "example.com" value is coming from? My site domain name and display name are both "127.0.0.1:8000".

@groovecoder
Copy link
Author

I at least found the source of my problem ...

I'm using CSP to prevent inline scripts, and the django-rest-swagger app uses inline scripting to show api endpoints.

@groovecoder groovecoder changed the title DRS docs not showing my registered endpoints DRS docs break with CSP that disallows inline scripts Apr 25, 2016
@groovecoder groovecoder changed the title DRS docs break with CSP that disallows inline scripts DRS docs break with CSP that blocks inline scripts Apr 25, 2016
groovecoder added a commit to groovecoder/django-rest-swagger that referenced this issue Apr 25, 2016
@groovecoder
Copy link
Author

Starting a fix branch here: https://github.com/groovecoder/django-rest-swagger/tree/remove-inlines-434

So far I've removed the inline <script> tags, but I still need to remove the inline styling.

@groovecoder
Copy link
Author

I'm trying to fix the last of the JS to work without inline <script> tags. How do I generate swagger-ui.min.js?

groovecoder added a commit to groovecoder/django-rest-swagger that referenced this issue Apr 26, 2016
groovecoder added a commit to groovecoder/django-rest-swagger that referenced this issue May 5, 2016
groovecoder added a commit to groovecoder/django-rest-swagger that referenced this issue May 5, 2016
@marcgibbons
Copy link
Owner

Inline scripts have been removed in #470

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants