Skip to content

Commit 7e2ee21

Browse files
author
Krit
committed
Merge commit '089b2ab99e6211c87d68deb2e10b62d56e39c0ff'
Conflicts: .gitignore
2 parents fb40fe5 + 089b2ab commit 7e2ee21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+911
-548
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ Make sure these boxes are checked before submitting your issue -- thanks for rep
1111

1212

1313
#### Logs/Trace
14+
Note: If you get a browser JS error please run `npm run dev`. This will provide source maps and a much more useful stack trace.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ npm-debug.log
88

99
// vim .swp
1010
*.swp
11+
1112
### Node template
1213
# Logs
1314
logs
@@ -85,3 +86,4 @@ com_crashlytics_export_strings.xml
8586
crashlytics.properties
8687
crashlytics-build.properties
8788

89+
.env

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Parse Dashboard/parse-dashboard-config.json

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Parse Dashboard Changelog
2+
3+
### 1.0.8
4+
5+
* Allow Dashboard to be mounted as Express middleware, thanks to [Florent Vilmart](https://github.com/flovilmart)
6+
* Add an option to specify that your app is in production, thanks to [Dylan Diamond](https://github.com/dcdspace)
7+
* Fix GeoPoints in Parse Config, thanks to [Dylan Diamond](https://github.com/dcdspace)
8+
* Allow specification of the host the dashboard runs on, thanks to [hpello](https://github.com/hpello)
9+
* Miscellaneous look-and-feel improvements
10+
11+
### 1.0.7
12+
13+
* Fix sending pushes with badge increment
14+
15+
### 1.0.6
16+
17+
* Send push notifications from the dashboard
18+
* Add object count to relation browser, thanks to [Sergey Gavrilyuk](https://github.com/gavrix)
19+
20+
### 1.0.5
21+
22+
* Fix new features notification
23+
24+
### 1.0.4
25+
26+
* Class level permissions editor

CONTRIBUTING.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ We want to make contributing to this project as easy and transparent as
33
possible.
44

55
## Our Development Process
6-
The standard installation method also clones the git repository, so you can start making and submitting changes right away.
6+
Get started by cloning this repository and and running `npm install` inside it. Create a file called `parse-dashboad-config.json` in the Parse-Dashboard folder inside the repo, using the format described in the readme.
77

8-
When working on the dashboard, use `npm run dashboard` and visit `localhost:4040` to see your dashboard. The `npm` script will automatically re-build your files when you change them, so after making a change, all you need to do is refresh the page.
8+
When working on the dashboard, use `npm run dashboard` and visit `localhost:4040` to see your dashboard. The `npm run dashboard` script will automatically re-build your files when you change them, so after making a change, all you need to do is refresh the page.
99

1010
When working on React components, use `npm run pig` and visit `localhost:4041` to view our component library and documentation (you can have both Dashboard and PIG running at once). The demos for each component are the primary way we test components, although there are also a small number of automated tests you can run with `npm test`. If you would like to create a new component that does not exist in the component library, use `npm run generate yourComponentName` to generate boilerplate code and quickly get started.
1111

@@ -33,8 +33,6 @@ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
3333
disclosure of security bugs. In those cases, please go through the process
3434
outlined on that page and do not file a public issue.
3535

36-
3736
## License
3837
By contributing to Parse Dashboard, you agree that your contributions will be licensed
3938
under its license.
40-

LICENSE

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ For Parse Dashboard software
44

55
Copyright (c) 2015-Present, Parse, LLC. All rights reserved.
66

7-
Parse, LLC. ("Parse") owns all right, title and interest, including all intellectual property and other proprietary rights, in and to the Parse Dashboard software (the "Software"). Subject to your compliance with these terms, you are hereby granted a non-exclusive, worldwide, royalty-free copyright license to (1) use and copy the Software; and (2) reproduce and distribute the Software as part of your own software ("Your Software"). Parse reserves all rights not expressly granted to you in this license agreement.
7+
Parse, LLC. ("Parse") owns all right, title and interest, including all
8+
intellectual property and other proprietary rights, in and to the Parse Dashboard
9+
software (the "Software"). Subject to your compliance with these terms, you are
10+
hereby granted a non-exclusive, worldwide, royalty-free copyright license to
11+
(1) use and copy the Software; and (2) reproduce and distribute the Software as part
12+
of your own software ("Your Software"), provided Your Software does not consist
13+
solely of the Software; and (3) modify the Software for your own internal use.
14+
Parse reserves all rights not expressly granted to you in this license agreement.
815

9-
THE SOFTWARE AND DOCUMENTATION, IF ANY, ARE PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED. IN NO EVENT SHALL Parse OR ITS AFFILIATES, OFFICERS, DIRECTORS OR EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16+
THE SOFTWARE AND DOCUMENTATION, IF ANY, ARE PROVIDED "AS IS" AND ANY EXPRESS OR
17+
IMPLIED WARRANTIES (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED.
19+
IN NO EVENT SHALL FACEBOOK OR ITS AFFILIATES, OFFICERS, DIRECTORS OR EMPLOYEES
20+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25+
IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
26+
OF SUCH DAMAGE.

Parse-Dashboard/app.js

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
'use strict';
2+
const express = require('express');
3+
const basicAuth = require('basic-auth');
4+
const path = require('path');
5+
const packageJson = require('package-json');
6+
7+
const currentVersionFeatures = require('../package.json').parseDashboardFeatures;
8+
9+
var newFeaturesInLatestVersion = [];
10+
packageJson('parse-dashboard', 'latest').then(latestPackage => {
11+
if (latestPackage.parseDashboardFeatures instanceof Array) {
12+
newFeaturesInLatestVersion = latestPackage.parseDashboardFeatures.filter(feature => {
13+
return currentVersionFeatures.indexOf(feature) === -1;
14+
});
15+
}
16+
});
17+
18+
function getMount(req) {
19+
let url = req.url;
20+
let originalUrl = req.originalUrl;
21+
var mountPathLength = req.originalUrl.length - req.url.length;
22+
var mountPath = req.originalUrl.slice(0, mountPathLength);
23+
if (!mountPath.endsWith('/')) {
24+
mountPath += '/';
25+
}
26+
return mountPath;
27+
}
28+
29+
module.exports = function(config, allowInsecureHTTP) {
30+
var app = express();
31+
// Serve public files.
32+
app.use(express.static(path.join(__dirname,'public')));
33+
34+
// Serve the configuration.
35+
app.get('/parse-dashboard-config.json', function(req, res) {
36+
const response = {
37+
apps: config.apps,
38+
newFeaturesInLatestVersion: newFeaturesInLatestVersion,
39+
};
40+
const users = config.users;
41+
42+
let auth = null;
43+
//If they provide auth when their config has no users, ignore the auth
44+
if (users) {
45+
auth = basicAuth(req);
46+
}
47+
48+
//Based on advice from Doug Wilson here:
49+
//https://github.com/expressjs/express/issues/2518
50+
const requestIsLocal =
51+
req.connection.remoteAddress === '127.0.0.1' ||
52+
req.connection.remoteAddress === '::ffff:127.0.0.1' ||
53+
req.connection.remoteAddress === '::1';
54+
if (!requestIsLocal && !req.secure && !allowInsecureHTTP) {
55+
//Disallow HTTP requests except on localhost, to prevent the master key from being transmitted in cleartext
56+
return res.send({ success: false, error: 'Parse Dashboard can only be remotely accessed via HTTPS' });
57+
}
58+
59+
if (!requestIsLocal && !users) {
60+
//Accessing the dashboard over the internet can only be done with username and password
61+
return res.send({ success: false, error: 'Configure a user to access Parse Dashboard remotely' });
62+
}
63+
64+
const successfulAuth =
65+
//they provided auth
66+
auth &&
67+
//there are configured users
68+
users &&
69+
//the provided auth matches one of the users
70+
users.find(user => {
71+
return user.user == auth.name &&
72+
user.pass == auth.pass
73+
});
74+
if (successfulAuth) {
75+
//They provided correct auth
76+
return res.json(response);
77+
}
78+
79+
if (users || auth) {
80+
//They provided incorrect auth
81+
res.set('WWW-Authenticate', 'Basic realm=Authorization Required');
82+
return res.sendStatus(401);
83+
}
84+
85+
//They didn't provide auth, and have configured the dashboard to not need auth
86+
//(ie. didn't supply usernames and passwords)
87+
if (requestIsLocal) {
88+
//Allow no-auth access on localhost only, if they have configured the dashboard to not need auth
89+
return res.json(response);
90+
}
91+
//We shouldn't get here. Fail closed.
92+
res.send({ success: false, error: 'Something went wrong.' });
93+
});
94+
95+
// For every other request, go to index.html. Let client-side handle the rest.
96+
app.get('/*', function(req, res) {
97+
let mountPath = getMount(req);
98+
res.send(`<!DOCTYPE html>
99+
<head>
100+
<link rel="shortcut icon" type="image/x-icon" href="${mountPath}favicon.ico" />
101+
<base href="${mountPath}"/>
102+
<script>
103+
PARSE_DASHBOARD_PATH = "${mountPath}";
104+
</script>
105+
</head>
106+
<html>
107+
<title>Parse Dashboard</title>
108+
<body>
109+
<div id="browser_mount"></div>
110+
<script src="${mountPath}bundles/dashboard.bundle.js"></script>
111+
</body>
112+
</html>
113+
`);
114+
});
115+
116+
return app;
117+
}

Parse-Dashboard/index.html

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)