Skip to content

feat: add dashboard option allowAnonymousUser #2066

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

Open
wants to merge 31 commits into
base: alpha
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
cbde31a
refactor: upgrade inquirer from 8.2.0 to 8.2.1 (#2079)
snyk-bot Apr 4, 2022
ca34006
chore(release): 4.1.1-alpha.1 [skip ci]
semantic-release-bot Apr 4, 2022
3fff99c
ci: bump environment
mtrezza Feb 8, 2022
394c449
chore(release): 4.0.0-alpha.16 [skip ci]
semantic-release-bot Feb 10, 2022
bf878ef
refactor: upgrade typescript from 4.5.4 to 4.5.5 (#2038)
snyk-bot Feb 12, 2022
1b1a9db
refactor: upgrade otpauth from 7.0.9 to 7.0.10 (#2044)
snyk-bot Feb 17, 2022
1d360ec
refactor: upgrade graphql from 16.2.0 to 16.3.0 (#2043)
snyk-bot Feb 17, 2022
b4651ef
chore(release): 4.0.0-alpha.17 [skip ci]
semantic-release-bot Feb 23, 2022
d4a8233
refactor: upgrade @babel/runtime from 7.16.7 to 7.17.0 (#2048)
snyk-bot Feb 24, 2022
7b11bea
fix: upgrade @babel/runtime from 7.17.0 to 7.17.2 (#2055)
snyk-bot Mar 2, 2022
7a4f230
chore(release): 4.0.0-alpha.18 [skip ci]
semantic-release-bot Mar 2, 2022
24f446f
refactor: upgrade body-parser from 1.19.1 to 1.19.2 (#2057)
snyk-bot Mar 10, 2022
6f645b9
fix: upgrade express from 4.17.2 to 4.17.3 (#2058)
snyk-bot Mar 10, 2022
df0567f
chore(release): 4.0.0-alpha.19 [skip ci]
semantic-release-bot Mar 10, 2022
93dc823
chore(release): 4.0.0-alpha.20 [skip ci]
semantic-release-bot Mar 16, 2022
1a20fab
fix: upgrade otpauth from 7.0.10 to 7.0.11 (#2061)
snyk-bot Mar 18, 2022
6af3f0d
chore(release): 4.0.0-alpha.21 [skip ci]
semantic-release-bot Mar 18, 2022
74e0114
feat: add dashboard option `allowAnonymousUser`
dblythy Mar 23, 2022
43c236c
Update app.js
dblythy Mar 23, 2022
f331d95
Update Dashboard.js
dblythy Mar 23, 2022
acffe6a
review feedback
dblythy Mar 25, 2022
da457b6
ci: refactor lint CI task and fix lint issues (#2004)
RaschidJFR Mar 23, 2022
3913d54
Update app.js
dblythy Mar 28, 2022
b9cc888
Update dashboard.e2e.test.js
dblythy Mar 28, 2022
357d927
alpha
dblythy Apr 4, 2022
504bb2a
revert changelog
dblythy Apr 4, 2022
0117a41
refactor: upgrade commander from 9.0.0 to 9.1.0 (#2089)
snyk-bot Apr 9, 2022
1d33c96
refactor: upgrade @babel/runtime from 7.17.2 to 7.17.7 (#2084)
snyk-bot Apr 9, 2022
03e66a3
refactor: upgrade graphiql from 1.6.0 to 1.7.1 (#2083)
snyk-bot Apr 9, 2022
fcd84d8
refactor: upgrade @babel/runtime from 7.17.7 to 7.17.8 (#2090)
snyk-bot Apr 11, 2022
b7ce426
Merge branch 'alpha' into allowAnonymousUser
mtrezza Apr 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions Parse-Dashboard/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,29 @@ module.exports = function(config, options) {
newFeaturesInLatestVersion: newFeaturesInLatestVersion,
};

//Based on advice from Doug Wilson here:
//https://github.com/expressjs/express/issues/2518
const requestIsLocal =
req.connection.remoteAddress === '127.0.0.1' ||
req.connection.remoteAddress === '::ffff:127.0.0.1' ||
req.connection.remoteAddress === '::1';
if (!options.dev && !requestIsLocal) {
if (!req.secure && !options.allowInsecureHTTP) {
for (const key in options) {
if (options[key] != null && config[key] == null) {
config[key] = options[key];
}
}
if (!config.dev) {
if (!req.secure && !config.allowInsecureHTTP) {
//Disallow HTTP requests except on localhost, to prevent the master key from being transmitted in cleartext
return res.send({ success: false, error: 'Parse Dashboard can only be remotely accessed via HTTPS' });
return res.send({
success: false,
error:
'Parse Dashboard can only be remotely accessed via HTTPS.',
log: 'Parse Dashboard can only be remotely accessed via HTTPS. If you are running locally, use the --dev parameter which will set allowInsecureHTTP to true.',
});
}

if (!users) {
//Accessing the dashboard over the internet can only be done with username and password
return res.send({ success: false, error: 'Configure a user to access Parse Dashboard remotely' });
if (!users && config.allowAnonymousUser) {
//Accessing the dashboard requires users unless allowAnonymousUser is set to `true`
return res.send({
success: false,
error: 'Configure a user to access Parse Dashboard.',
log: 'Configure a user to access Parse Dashboard. If you are running locally, use the --dev parameter which will set allowAnonymousUser to true.',
});
}
}
const authentication = req.user;
Expand Down Expand Up @@ -145,7 +153,7 @@ module.exports = function(config, options) {

//They didn't provide auth, and have configured the dashboard to not need auth
//(ie. didn't supply usernames and passwords)
if (requestIsLocal || options.dev) {
if (config.dev) {
//Allow no-auth access on localhost only, if they have configured the dashboard to not need auth
return res.json(response);
}
Expand Down
4 changes: 3 additions & 1 deletion Parse-Dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ program.option('--host [host]', 'the host to run parse-dashboard');
program.option('--port [port]', 'the port to run parse-dashboard');
program.option('--mountPath [mountPath]', 'the mount path to run parse-dashboard');
program.option('--allowInsecureHTTP [allowInsecureHTTP]', 'set this flag when you are running the dashboard behind an HTTPS load balancer or proxy with early SSL termination.');
program.option('--allowAnonymousUser [allowAnonymousUser]', 'set this to true if you do not require defined users to login. DO NOT ENABLE IN PRODUCTION SERVERS.');
program.option('--sslKey [sslKey]', 'the path to the SSL private key.');
program.option('--sslCert [sslCert]', 'the path to the SSL certificate.');
program.option('--trustProxy [trustProxy]', 'set this flag when you are behind a front-facing proxy, such as when hosting on Heroku. Uses X-Forwarded-* headers to determine the client\'s connection and IP address.');
Expand Down Expand Up @@ -67,6 +68,7 @@ let configUserId = program.userId || process.env.PARSE_DASHBOARD_USER_ID;
let configUserPassword = program.userPassword || process.env.PARSE_DASHBOARD_USER_PASSWORD;
let configSSLKey = program.sslKey || process.env.PARSE_DASHBOARD_SSL_KEY;
let configSSLCert = program.sslCert || process.env.PARSE_DASHBOARD_SSL_CERT;
const allowAnonymousUser = program.allowAnonymousUser || process.env.PARSE_DASHBOARD_ALLOW_ANONYMOUS_USER

function handleSIGs(server) {
const signals = {
Expand Down Expand Up @@ -174,7 +176,7 @@ const app = express();
if (allowInsecureHTTP || trustProxy || dev) app.enable('trust proxy');

config.data.trustProxy = trustProxy;
let dashboardOptions = { allowInsecureHTTP, cookieSessionSecret, dev };
let dashboardOptions = { allowInsecureHTTP, cookieSessionSecret, dev, allowAnonymousUser};
app.use(mountPath, parseDashboard(config.data, dashboardOptions));
let server;
if(!configSSLKey || !configSSLCert){
Expand Down
3 changes: 2 additions & 1 deletion Parse-Dashboard/parse-dashboard-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"secondaryBackgroundColor": ""
}
],
"iconsFolder": "icons"
"iconsFolder": "icons",
"dev": true
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ You may set the host, port and mount path by supplying the `--host`, `--port` an

The `--dev` parameter disables production-ready security features. This parameter is useful when running Parse Dashboard on Docker. Using this parameter will:

- allow insecure http connections from anywhere, bypassing the option `allowInsecureHTTP`
- allow insecure http connections from anywhere, setting the option `allowInsecureHTTP` to true
- allow the Parse Server `masterKey` to be transmitted in cleartext without encryption
- allow dashboard access without user authentication
- allow dashboard access without user authentication, setting the option `allowAnonymousUser` to true

> ⚠️ Do not use this parameter when deploying Parse Dashboard in a production environment.

Expand Down Expand Up @@ -328,7 +328,7 @@ If you have classes with a lot of columns and you filter them often with the sam
{
"name": "email",
"filterSortToTop": true
}
}
]
}
}
Expand Down Expand Up @@ -451,7 +451,7 @@ With MFA enabled, a user must provide a one-time password that is typically boun

The user requires an authenticator app to generate the one-time password. These apps are provided by many 3rd parties and mostly for free.

If you create a new user by running `parse-dashboard --createUser`, you will be asked whether you want to enable MFA for the new user. To enable MFA for an existing user,
If you create a new user by running `parse-dashboard --createUser`, you will be asked whether you want to enable MFA for the new user. To enable MFA for an existing user,
run `parse-dashboard --createMFA` to generate a `mfa` secret that you then add to the existing user configuration, for example:

```json
Expand Down
8 changes: 8 additions & 0 deletions changelogs/CHANGELOG_alpha.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## [4.1.1-alpha.1](https://github.com/ParsePlatform/parse-dashboard/compare/4.1.0...4.1.1-alpha.1) (2022-04-04)


### Bug Fixes

* security upgrade js-beautify from 1.14.0 to 1.14.1 ([#2077](https://github.com/ParsePlatform/parse-dashboard/issues/2077)) ([e4ea787](https://github.com/ParsePlatform/parse-dashboard/commit/e4ea7879d88173b02d66b1339ba98805255ba82c))
* security vulnerability bump minimist from 1.2.5 to 1.2.6 ([#2070](https://github.com/ParsePlatform/parse-dashboard/issues/2070)) ([3d0407e](https://github.com/ParsePlatform/parse-dashboard/commit/3d0407ebd75051bbbe6f0a2aba87b26475e901b9))

# [4.1.0-alpha.3](https://github.com/ParsePlatform/parse-dashboard/compare/4.1.0-alpha.2...4.1.0-alpha.3) (2022-03-30)


Expand Down
Loading