parse-community / parse-dashboard

A dashboard for managing Parse Server
https://parseplatform.org
Other
3.75k stars 1.39k forks source link

Parse Dashboard not connecting Parse Server (err: master key is required) #2382

Open sudhishkr opened 1 year ago

sudhishkr commented 1 year ago

New Issue Checklist

Issue Description

Parse Dashboard not connecting Parse Server (err: master key is required)

Steps to reproduce

docker run --name parse-mongo-db -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=password -p 27017:27017 -d mongo

docker run --name parse-server -e PARSE_SERVER_APPLICATION_ID=myapp -e PARSE_SERVER_MASTER_KEY=master_key -e PARSE_SERVER_DATABASE_URI=mongodb://admin:password@mongo/parse_server?authSource=admin --link parse-mongo-db:mongo -p 1337:1337 -d parseplatform/parse-server

cat > /tmp/config.json << EOF
{
  "apps": [
    {
      "serverURL": "http://localhost:1337/parse",
      "appId": "myapp",
      "masterKey": "master_key",
      "appName": "myapp",
      "masterKeyIps": ["127.0.0.1"]
    }
  ],
  "users": [
    {
      "user":"admin",
      "pass":"password",
      "apps": [{"appId": "myapp", "readOnly": false}]
    }
  ]
}
EOF

docker run --name parse-dashboard -e PARSE_DASHBOARD_ALLOW_INSECURE_HTTP=true --link parse-server:parse-server -p 4040:4040 -v /tmp/config.json:/src/Parse-Dashboard/parse-dashboard-config.json -d parseplatform/parse-dashboard

Actual Outcome

Screen Shot 2023-02-05 at 7 45 02 PM

Expected Outcome

Successful Login

Environment

$ docker images
parseplatform/parse-server      latest       7c5539478f9a   6 days ago     262MB
parseplatform/parse-dashboard   latest       ba8bd5083493   3 months ago   361MB
mongo                           latest       a440572ac3c1   3 days ago     639MB

Dashboard

Server

Database

Logs

Failed to load resource: the server responded with a status of 403 (Forbidden)

on browser ^

parse-github-assistant[bot] commented 1 year ago

Thanks for opening this issue!

sudhishkr commented 1 year ago

Similar issue https://github.com/parse-community/parse-dashboard/issues/602

@andrewfelker I know the previous issue is quite old, but do you have any insights here?

sudhishkr commented 1 year ago

Similar issue https://github.com/parse-community/parse-dashboard/issues/2349

@zhangwb1996 do you see any issue with the way I have set up "masterKeyIps": ["127.0.0.1"]

dblythy commented 1 year ago

It would be relating to masterKeyIps, If you have a look at the Parse Server logs, it should tell you the IP that was rejected. Adding that to the masterKeyIps will resolve the issue

sudhishkr commented 1 year ago

It would be relating to masterKeyIps, If you have a look at the Parse Server logs, it should tell you the IP that was rejected. Adding that to the masterKeyIps will resolve the issue

Thanks @dblythy .. I am going to try it on my parse-server. Also looks like this fix is out in the beta release as per this https://github.com/parse-community/parse-server/issues/8316#issuecomment-1409693198

sudhishkr commented 1 year ago

Yay! I got this working .. thanks @dblythy! Going to close this issue.

mtrezza commented 1 year ago

Would you want to add the step to the Parse Dashboard installation instructions in the README?

It should say that for Parse Server 6 the masterKeyIps needs to be configured.

I've reopened this as a docs issue.

ghasempoorm commented 1 year ago

Yay! I got this working .. thanks @dblythy! Going to close this issue.

hello, I have same problem. but it's not worked after adding the rejected IP. why?

matthiasbaldi commented 1 year ago

Is there any documentation to this property masterKeyIps? Because how should we define a IP whitelist when i.e. the dashboard is running in a Kubernetes cluster? Yes, I could define IPs but this is not how you should provision your cluster. Or do I have missed something on this feature? Is it possible at least to set an IP range by CIDR?

mtrezza commented 1 year ago

Yes, you can use CIDR syntax to enable for example all IPs.

The Parse Server docs for that option have been improved but it's not merged into stable release yet hence they are not published.


/* (Optional) Restricts the use of master key permissions to a list of IP addresses.<br><br>This option accepts a list of single IP addresses, for example:<br>`['10.0.0.1', '10.0.0.2']`<br><br>You can also use CIDR notation to specify an IP address range, for example:<br>`['10.0.1.0/24']`<br><br>Special cases:<br>- Setting an empty array `[]` means that `masterKey` cannot be used even in Parse Server Cloud Code.<br>- Setting `['0.0.0.0/0']` means disabling the filter and the master key can be used from any IP address.<br><br>To connect Parse Dashboard from a different server requires to add the IP address of the server that hosts Parse Dashboard because Parse Dashboard uses the master key.<br><br>Defaults to `['127.0.0.1', '::1']` which means that only `localhost`, the server itself, is allowed to use the master key.
  :DEFAULT: ["127.0.0.1","::1"] */
masterKeyIps: ?(string[]);
sudhishkr commented 1 year ago

@mtrezza let me take a stab at fixing the docs. I read somewhere that this issue was fixed in the upcoming new release (not sure if thats still true).

muratdoglu commented 1 year ago

@sudhishkr hi, I have 'unauthorized: master key is required' problem but can't solve this. Can you explain to me? But basic please :D

edson-gaspar commented 1 year ago

I think this info will be important for someone having trouble when trying to run parse-server + parse-dashboard on docker-compose: When listing ips on PARSE_SERVER_MASTER_KEY_IPS, the syntax is not an array like on javascript, this catch errors on server start, you need to list ips splitted by comma on environment variable. Ex: PARSE_SERVER_MASTER_KEY_IPS: 172.0.0.0/1,::1

mtrezza commented 1 year ago

@edson-gaspar Would you want to open a PR to add this to the docs?

edson-gaspar commented 1 year ago

@mtrezza I don't feel quite sure how I should document it.

sudhishkr commented 1 year ago

@mtrezza - if you can assign this to me, I can try to take a stab on Thursday.

mtrezza commented 1 year ago

@sudhishkr We don't "assign" issues, please feel free to open a PR and link this issue so that others can see you're working on it.

fatherofinvention commented 1 year ago

Fix for "Server not reachable: unauthorized: master key is required" Error

I ran up against this today and struggled a bit. Hope this helps someone. If you encounter the error "Server not reachable: unauthorized: master key is required" while setting up Parse Server, you might need to specify the IP addresses allowed to use the master key. To resolve this issue, add the PARSE_SERVER_MASTER_KEY_IPS environment variable to your configuration, using the CIDR notation 0.0.0.0/0 to allow all IPs. In my docker-compose.yml I added:

parse:
    image: parseplatform/parse-server
    environment:
      - # OTHER ENV VARS
      - PARSE_SERVER_MASTER_KEY_IPS=0.0.0.0/0

Be cautious with this setting as it opens up master key access to all IP addresses, which could pose a security risk. If you want to tighten it up, add your own local IP address that you are accessing the dashboard from (e.g. your laptop's IP).