Skip to content

Unexpected basic auth credentials take precedence over credentials in header or body params #2573

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

Closed
4 tasks done
gyratorycircus opened this issue Aug 24, 2016 · 1 comment

Comments

@gyratorycircus
Copy link
Contributor

Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Server!

Issue Description

This issue came up when investigating of #394 on ParseDashboard, which describes problems when running both ParseDashboard and ParseServer, and requiring basic auth for ParseDashboard.

The overall dashboard basic auth credentials configured in ParseDashboard are being sent via basic auth as one would expect, but the ParseServer middleware is parsing out user as appId and password as masterKey from the basic auth. Subsequently, these credentials are used instead of likely valid appId and masterKey which are in the request body or headers. In this situation, ParseDashboard is not intentionally sending the basic auth credentials to ParseServer, but they're being included by a cookie since both are running on the same server.

As @theill discovered in the above issue discussion, the behavior came about in this commit: ParsePlatform/parse-server@01318e6. Starting at line 34 of middleware.js in this commit, the desired app ID and keys from the headers could have been set on info, but since httpAuth(req) was able to properly parse out user and password from the request, info.appId, info.masterKey, and info.javascriptKey are overwritten. Further down at line 67, the existence of ainfo.masterKey (even non-matching) prevented all parameters from being parsed from the body.

The basic auth support was added to support backwards compatibility in the REST API (#1059) which is great, but since its available as an alternative, the basic auth creds should not taking precedence over valid credentials being sent via the header or body parameters. I’d be inclined to address this in ParseServer to ensure it stays flexible and won't use unknown basic auth.

Steps to reproduce

  1. Setup ParseServer and ParseDashboard as express middleware as described here: Run both Server and Dashboard
  2. Configured dashboard with user authentication:
var dashboard = new ParseDashboard({
    // Parse Dashboard settings...
    apps: [{
      // App configuration...
    }],
    users: [{
      user: 'admin',
      pass: 'password',
    }]
}, allowInsecureHTTP);

Expected Results

Dashboard is able to connect to Parse Server when run.

Actual Outcome

Dashboard cannot connect due to 403 Forbidden errors.

POST http://localhost:1337/parse/serverInfo 403 (Forbidden)
POST http://localhost:1337/parse/classes/_Installation 403 (Forbidden)
POST http://localhost:1337/parse/classes/_User 403 (Forbidden)

Environment Setup

  • Server
    • parse-server version (Be specific! Don't say 'latest'.) : 2.2.17
    • Operating System: OS X 10.11.5
    • Hardware: Retina Macbook Pro
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Localhost
@hramos
Copy link
Contributor

hramos commented Aug 25, 2016

Looks like we can close this now that #2574 has landed.

@hramos hramos closed this as completed Aug 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants