Skip to content

Integrate Uffizzi #29

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 17 commits into
base: ci
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- run: npm run lint
check-circular:
name: Circular Dependencies
timeout-minutes: 5
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
21 changes: 13 additions & 8 deletions Parse-Dashboard/Authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,30 @@ function initialize(app, options) {
});

var cookieSessionSecret = options.cookieSessionSecret || require('crypto').randomBytes(64).toString('hex');
const cookieSessionMaxAge = options.cookieSessionMaxAge;
app.use(require('connect-flash')());
app.use(require('body-parser').urlencoded({ extended: true }));
app.use(require('cookie-session')({
key : 'parse_dash',
secret : cookieSessionSecret,
cookie : {
maxAge: (2 * 7 * 24 * 60 * 60 * 1000) // 2 weeks
}
maxAge : cookieSessionMaxAge
}));
app.use(passport.initialize());
app.use(passport.session());

app.post('/login',
csrf(),
passport.authenticate('local', {
successRedirect: `${self.mountPath}apps`,
failureRedirect: `${self.mountPath}login`,
failureFlash : true
})
(req,res,next) => {
let redirect = 'apps';
if (req.body.redirect) {
redirect = req.body.redirect.charAt(0) === '/' ? req.body.redirect.substring(1) : req.body.redirect
}
return passport.authenticate('local', {
successRedirect: `${self.mountPath}${redirect}`,
failureRedirect: `${self.mountPath}login${req.body.redirect ? `?redirect=${req.body.redirect}` : ''}`,
failureFlash : true
})(req, res, next)
},
);

app.get('/logout', function(req, res){
Expand Down
7 changes: 4 additions & 3 deletions Parse-Dashboard/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = function(config, options) {
const users = config.users;
const useEncryptedPasswords = config.useEncryptedPasswords ? true : false;
const authInstance = new Authentication(users, useEncryptedPasswords, mountPath);
authInstance.initialize(app, { cookieSessionSecret: options.cookieSessionSecret });
authInstance.initialize(app, { cookieSessionSecret: options.cookieSessionSecret, cookieSessionMaxAge: options.cookieSessionMaxAge });

// CSRF error handler
app.use(function (err, req, res, next) {
Expand Down Expand Up @@ -173,8 +173,9 @@ module.exports = function(config, options) {
}

app.get('/login', csrf(), function(req, res) {
const redirectURL = req.url.includes('?redirect=') && req.url.split('?redirect=')[1];
if (!users || (req.user && req.user.isAuthenticated)) {
return res.redirect(`${mountPath}apps`);
return res.redirect(`${mountPath}${redirectURL || 'apps'}`);
}

let errors = req.flash('error');
Expand Down Expand Up @@ -206,7 +207,7 @@ module.exports = function(config, options) {
// For every other request, go to index.html. Let client-side handle the rest.
app.get('/*', function(req, res) {
if (users && (!req.user || !req.user.isAuthenticated)) {
return res.redirect(`${mountPath}login`);
return res.redirect(`${mountPath}login?redirect=${req.url.replace('/login', '')}`);
}
if (users && req.user && req.user.matchingUsername ) {
res.append('username', req.user.matchingUsername);
Expand Down
2 changes: 2 additions & 0 deletions Parse-Dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ program.option('--trustProxy [trustProxy]', 'set this flag when you are behind a
program.option('--cookieSessionSecret [cookieSessionSecret]', 'set the cookie session secret, defaults to a random string. You should set that value if you want sessions to work across multiple server, or across restarts');
program.option('--createUser', 'helper tool to allow you to generate secure user passwords and secrets. Use this on trusted devices only.');
program.option('--createMFA', 'helper tool to allow you to generate multi-factor authentication secrets.');
program.option('--cookieSessionMaxAge [cookieSessionMaxAge]', '(Optional) Sets the time in seconds for when the session cookie will be deleted and the dashboard user has to re-login; if no value is set then the cookie will be deleted when the browser session ends.');

program.action(async (options) => {
for (const key in options) {
const func = CLIHelper[key];
Expand Down
3 changes: 2 additions & 1 deletion Parse-Dashboard/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = (options) => {
const allowInsecureHTTP = options.allowInsecureHTTP || process.env.PARSE_DASHBOARD_ALLOW_INSECURE_HTTP;
const cookieSessionSecret = options.cookieSessionSecret || process.env.PARSE_DASHBOARD_COOKIE_SESSION_SECRET;
const trustProxy = options.trustProxy || process.env.PARSE_DASHBOARD_TRUST_PROXY;
const cookieSessionMaxAge = options.cookieSessionMaxAge || process.env.PARSE_DASHBOARD_COOKIE_SESSION_MAX_AGE;
const dev = options.dev;

if (trustProxy && allowInsecureHTTP) {
Expand Down Expand Up @@ -145,7 +146,7 @@ module.exports = (options) => {
if (allowInsecureHTTP || trustProxy || dev) app.enable('trust proxy');

config.data.trustProxy = trustProxy;
let dashboardOptions = { allowInsecureHTTP, cookieSessionSecret, dev };
let dashboardOptions = { allowInsecureHTTP, cookieSessionSecret, dev, cookieSessionMaxAge };
app.use(mountPath, parseDashboard(config.data, dashboardOptions));
let server;
if(!configSSLKey || !configSSLCert){
Expand Down
35 changes: 35 additions & 0 deletions changelogs/CHANGELOG_alpha.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
# [5.1.0-alpha.6](https://github.com/ParsePlatform/parse-dashboard/compare/5.1.0-alpha.5...5.1.0-alpha.6) (2023-01-25)


### Bug Fixes

* Navigation to page fails if user re-login is required ([#2369](https://github.com/ParsePlatform/parse-dashboard/issues/2369)) ([0db6f55](https://github.com/ParsePlatform/parse-dashboard/commit/0db6f5559f9b7bb1f5a282c6182810ca89945032))

# [5.1.0-alpha.5](https://github.com/ParsePlatform/parse-dashboard/compare/5.1.0-alpha.4...5.1.0-alpha.5) (2023-01-25)


### Features

* Add export all rows of a class and export in JSON format ([#2361](https://github.com/ParsePlatform/parse-dashboard/issues/2361)) ([9eb36a1](https://github.com/ParsePlatform/parse-dashboard/commit/9eb36a183b8b337960f6e8563ad686958001a22b))

# [5.1.0-alpha.4](https://github.com/ParsePlatform/parse-dashboard/compare/5.1.0-alpha.3...5.1.0-alpha.4) (2023-01-25)


### Bug Fixes

* Add dashboard option `cookieSessionMaxAge` to keep user logged in across browser sessions ([#2366](https://github.com/ParsePlatform/parse-dashboard/issues/2366)) ([9ea95fc](https://github.com/ParsePlatform/parse-dashboard/commit/9ea95fc62103b52cf4fac1d1b567334b5298b318))

# [5.1.0-alpha.3](https://github.com/ParsePlatform/parse-dashboard/compare/5.1.0-alpha.2...5.1.0-alpha.3) (2023-01-20)


### Features

* Add schema export ([#2362](https://github.com/ParsePlatform/parse-dashboard/issues/2362)) ([33df049](https://github.com/ParsePlatform/parse-dashboard/commit/33df0495a02c4e77f48b3566032bf5686227cce7))

# [5.1.0-alpha.2](https://github.com/ParsePlatform/parse-dashboard/compare/5.1.0-alpha.1...5.1.0-alpha.2) (2023-01-20)


### Bug Fixes

* Blank screen shown if server is unreachable; unsupported pages are accessible via direct URLs ([#2363](https://github.com/ParsePlatform/parse-dashboard/issues/2363)) ([9855258](https://github.com/ParsePlatform/parse-dashboard/commit/98552584df4d8d75d65d3e394b4acad522117a96))

# [5.1.0-alpha.1](https://github.com/ParsePlatform/parse-dashboard/compare/5.0.0...5.1.0-alpha.1) (2022-11-05)


Expand Down
2 changes: 1 addition & 1 deletion docker-compose.uffizzi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ x-uffizzi:
deploy_preview_when_pull_request_is_opened: true
delete_preview_when_pull_request_is_closed: true
share_to_github: true

services:

postgres:
Expand Down Expand Up @@ -59,7 +60,6 @@ services:
command:
- "-c"
- "PARSE_DASHBOARD_SERVER_URL=$$UFFIZZI_URL/parse node Parse-Dashboard/index.js"
#- PARSE_DASHBOARD_COOKIE_SESSION_SECRET=AB8849B6-D725-4A75-AA73-AB7103F0363F
deploy:
resources:
limits:
Expand Down
1 change: 0 additions & 1 deletion nginx-uffizzi/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ <h1>Endpoint:</h1>

<a href="/dashboard/"><b>Click to Visit Parse Dashboard</b></a>


</body>

</html>
25 changes: 8 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "parse-dashboard",
"version": "5.1.0-alpha.1",
"version": "5.1.0-alpha.6",
"repository": {
"type": "git",
"url": "https://github.com/ParsePlatform/parse-dashboard"
Expand Down
6 changes: 3 additions & 3 deletions src/dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,21 @@ export default class Dashboard extends React.Component {
if (error.code === 100) {
app.serverInfo = {
error: 'unable to connect to server',
enabledFeatures: {},
features: {},
parseServerVersion: 'unknown'
}
return Promise.resolve(app);
} else if (error.code === 107) {
app.serverInfo = {
error: 'server version too low',
enabledFeatures: {},
features: {},
parseServerVersion: 'unknown'
}
return Promise.resolve(app);
} else {
app.serverInfo = {
error: error.message || 'unknown error',
enabledFeatures: {},
features: {},
parseServerVersion: 'unknown'
}
return Promise.resolve(app);
Expand Down
21 changes: 21 additions & 0 deletions src/dashboard/Dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,25 @@ body:global(.expanded) {
.content {
margin-left: $sidebarCollapsedWidth;
}
}

.loadingError {
font-size: 58px;
color: #ffffff;
}

.empty {
position: relative;
background: #1e3b4d;
min-height: 100vh;
text-align: center;
}

.cloud {
width: 170px;
height: 170px;
border-radius: 100%;
padding-top: 30px;
background: #3E5566;
margin: 0 auto 14px auto;
}
Loading