Skip to content

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

Closed
@gyratorycircus

Description

@gyratorycircus

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions