Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON responses globally #32

Open
nic-hartley opened this issue Nov 11, 2018 · 0 comments
Open

JSON responses globally #32

nic-hartley opened this issue Nov 11, 2018 · 0 comments
Labels
code cleanup Removing technical debt discussion wanted We need to talk about this
Milestone

Comments

@nic-hartley
Copy link
Member

Section

The server's responses; specifically, the bodies.

Problem

Many requests -- see specifically unauthorized requests and nonexistent URLs -- return HTML responses instead of JSON like everything else. For example, hitting an endpoint that requires authorization without it gives:

<!doctype html><html lang="en"><head><title>HTTP Status 403 – Forbidden</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 403 – Forbidden</h1></body></html>

That should probably return something more like:

{"error":"Authorization insufficient to hit endpoint","fix":"Authenticate as a user allowed to access this endpoint."}

Solution

I'm fairly sure this can be done with a custom AuthenticationEntryPoint, but this needs to be investigated.

Additional notes

While fixing this, maybe also fix the issue where 401s are reported as 403s?

@nic-hartley nic-hartley added discussion wanted We need to talk about this code cleanup Removing technical debt labels Nov 11, 2018
@nic-hartley nic-hartley added this to the Public Production milestone Nov 11, 2018
@nic-hartley nic-hartley modified the milestones: Public Production, Beta Nov 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code cleanup Removing technical debt discussion wanted We need to talk about this
Projects
None yet
Development

No branches or pull requests

1 participant