- 
    Bug 
- 
    Resolution: Low Engagement
- 
    Low 
- 
    None
- 
    3.1, 4.3, 5.4.4, 6.0.6
- 
        1
- 
        Severity 3 - Minor
- 
        
Summary
Running a request against Confluence with Accept header that contains "application/json" returns an authentication error.
Environment
- Confluence running over SSL
Steps to Reproduce
- Set up Confluence to run over SSL
- Run a curl command with application/json header
Expected Results
The application returns the expected JSON.
Actual Results
401 error is returned with an authentication requirement:
$ curl -v -k --insecure https://localhost:8443 --header "Accept: text/html,application/xhtml+xml,application/json;q=0.9" * Rebuilt URL to: https://localhost:8443/ * Trying 127.0.0.1... * Connected to localhost (127.0.0.1) port 8443 (#0) * TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 * Server certificate: bandreeti > GET / HTTP/1.1 > Host: localhost:8443 > User-Agent: curl/7.43.0 > Accept: text/html,application/xhtml+xml,application/json;q=0.9 > < HTTP/1.1 401 Unauthorized < Server: Apache-Coyote/1.1 < X-Confluence-Request-Time: 1489679589469 < Set-Cookie: JSESSIONID=7C92CB07865D341DA3DD8E29B9A8E987; Path=/; Secure; HttpOnly < X-XSS-Protection: 1; mode=block < X-Content-Type-Options: nosniff < X-Frame-Options: SAMEORIGIN < Content-Security-Policy: frame-ancestors 'self' < WWW-Authenticate: OAuth realm="https%3A%2F%2Flocalhost%3A8443" < Content-Type: application/json;charset=UTF-8 < Transfer-Encoding: chunked < Date: Thu, 16 Mar 2017 15:53:09 GMT < * Connection #0 to host localhost left intact {"errorMessage":"You are not logged in. <a href=\"/login.action\">Log in<\/a> here and try again."}
Notes
This is a problem for web developers, who may have plugins installed which modify the browser accept header to accept JSON for various reasons. For now, they have to disable such plugins manually in order to use Confluence effectively.
Workaround
If you pass the -u parameter with an username and password, the request is accepted:
$ curl -v -k --insecure -u <username>:<password> https://localhost:8443 --header "Accept: text/html,application/xhtml+xml,application/json;q=0.9" * Rebuilt URL to: https://localhost:8443/ * Trying 127.0.0.1... * Connected to localhost (127.0.0.1) port 8443 (#0) * TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 * Server certificate: bandreeti * Server auth using Basic with user '<username>' > GET / HTTP/1.1 > Host: localhost:8443 > Authorization: Basic YWRtaW46YWRtaW4= > User-Agent: curl/7.43.0 > Accept: text/html,application/xhtml+xml,application/json;q=0.9 > < HTTP/1.1 200 OK < Server: Apache-Coyote/1.1 < X-Confluence-Request-Time: 1489677615306 < Set-Cookie: JSESSIONID=4CF30D4D1E4F5B335F1D0FE3AE939662; Path=/; Secure; HttpOnly < X-Seraph-LoginReason: OK < X-AUSERNAME: <username> < X-XSS-Protection: 1; mode=block < X-Content-Type-Options: nosniff < X-Frame-Options: SAMEORIGIN < Content-Security-Policy: frame-ancestors 'self' < X-Accel-Buffering: no < Content-Type: text/html;charset=UTF-8 < Transfer-Encoding: chunked < Date: Thu, 16 Mar 2017 15:20:15 GMT < <!DOCTYPE html> <html> <head> <title>Dashboard - Confluence</title> ...
This user credentials are not required in JIRA.
The -k --insecure parameters are just to workaround the self-signed certificate.
- is duplicated by
- 
                    CONFSERVER-22789 When the JSONView Firefox Add-on is loaded, it's impossible to log in to Confluence -         
- Closed
 
-