for simplicity and security, remove redirect to HTTP and keep everything on HTTPS
This commit is contained in:
parent
1493d3e5ae
commit
d44027c58e
7 changed files with 23 additions and 99 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.env
|
.env
|
||||||
|
.env.production
|
||||||
.vscode/
|
.vscode/
|
||||||
node_modules/
|
node_modules/
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
|
|
@ -28,7 +28,6 @@ export const AUTH_ERROR = 'AUTH_ERROR';
|
||||||
export const SETTINGS_UPDATED = 'SETTINGS_UPDATED';
|
export const SETTINGS_UPDATED = 'SETTINGS_UPDATED';
|
||||||
|
|
||||||
export const SET_PROJECT_NAME = 'SET_PROJECT_NAME';
|
export const SET_PROJECT_NAME = 'SET_PROJECT_NAME';
|
||||||
export const SET_SERVE_SECURE = 'SET_SERVE_SECURE';
|
|
||||||
|
|
||||||
export const PROJECT_SAVE_SUCCESS = 'PROJECT_SAVE_SUCCESS';
|
export const PROJECT_SAVE_SUCCESS = 'PROJECT_SAVE_SUCCESS';
|
||||||
export const PROJECT_SAVE_FAIL = 'PROJECT_SAVE_FAIL';
|
export const PROJECT_SAVE_FAIL = 'PROJECT_SAVE_FAIL';
|
||||||
|
|
|
@ -16,13 +16,6 @@ const __process = (typeof global !== 'undefined' ? global : window).process;
|
||||||
const ROOT_URL = __process.env.API_URL;
|
const ROOT_URL = __process.env.API_URL;
|
||||||
|
|
||||||
export function setProject(project) {
|
export function setProject(project) {
|
||||||
const targetProtocol = project.serveSecure === true ?
|
|
||||||
protocols.https :
|
|
||||||
protocols.http;
|
|
||||||
|
|
||||||
// This will not reload if on same protocol
|
|
||||||
redirectToProtocol(targetProtocol);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: ActionTypes.SET_PROJECT,
|
type: ActionTypes.SET_PROJECT,
|
||||||
project,
|
project,
|
||||||
|
@ -265,22 +258,6 @@ export function cloneProject() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setServeSecure(serveSecure, { redirect = true } = {}) {
|
|
||||||
return (dispatch, getState) => {
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.SET_SERVE_SECURE,
|
|
||||||
serveSecure
|
|
||||||
});
|
|
||||||
|
|
||||||
if (redirect === true) {
|
|
||||||
dispatch(saveProject(false /* autosave */))
|
|
||||||
.then(() => redirectToProtocol(serveSecure === true ? protocols.https : protocols.http));
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function showEditProjectName() {
|
export function showEditProjectName() {
|
||||||
return {
|
return {
|
||||||
type: ActionTypes.SHOW_EDIT_PROJECT_NAME
|
type: ActionTypes.SHOW_EDIT_PROJECT_NAME
|
||||||
|
|
|
@ -59,7 +59,6 @@ class Preferences extends React.Component {
|
||||||
<TabList>
|
<TabList>
|
||||||
<div className="preference__subheadings">
|
<div className="preference__subheadings">
|
||||||
<Tab><h4 className="preference__subheading">General Settings</h4></Tab>
|
<Tab><h4 className="preference__subheading">General Settings</h4></Tab>
|
||||||
<Tab><h4 className="preference__subheading">Sketch Settings</h4></Tab>
|
|
||||||
<Tab><h4 className="preference__subheading">Accessibility</h4></Tab>
|
<Tab><h4 className="preference__subheading">Accessibility</h4></Tab>
|
||||||
</div>
|
</div>
|
||||||
</TabList>
|
</TabList>
|
||||||
|
@ -217,34 +216,6 @@ class Preferences extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel>
|
|
||||||
{/* <div className="preference">
|
|
||||||
<h4 className="preference__title">Add a p5.js or an external library</h4>
|
|
||||||
</div> */}
|
|
||||||
<div className="preference">
|
|
||||||
<h4 className="preference__title">Security Protocol</h4>
|
|
||||||
<div className="preference__serve-secure">
|
|
||||||
<input
|
|
||||||
id="serve-secure"
|
|
||||||
type="checkbox"
|
|
||||||
checked={this.props.serveSecure || false}
|
|
||||||
onChange={(event) => {
|
|
||||||
this.props.setServeSecure(event.target.checked);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<label htmlFor="serve-secure">Serve over HTTPS</label>
|
|
||||||
<span
|
|
||||||
className="serve-secture__tooltip tooltipped tooltipped-n tooltipped-no-delay tooltipped-multiline"
|
|
||||||
aria-label={'Choose HTTPS if you need to \n • access a microphone or webcam \n'
|
|
||||||
+ '• access an API served over HTTPS \n\n'
|
|
||||||
+ 'Choose HTTP if you need to \n'
|
|
||||||
+ '• access an API served over HTTP'}
|
|
||||||
>
|
|
||||||
<InlineSVG src={infoUrl} className="serve-secure__icon" />
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</TabPanel>
|
|
||||||
<TabPanel>
|
<TabPanel>
|
||||||
<div className="preference">
|
<div className="preference">
|
||||||
<h4 className="preference__title">Lint warning sound</h4>
|
<h4 className="preference__title">Lint warning sound</h4>
|
||||||
|
@ -349,8 +320,6 @@ Preferences.propTypes = {
|
||||||
lintWarning: PropTypes.bool.isRequired,
|
lintWarning: PropTypes.bool.isRequired,
|
||||||
setLintWarning: PropTypes.func.isRequired,
|
setLintWarning: PropTypes.func.isRequired,
|
||||||
theme: PropTypes.string.isRequired,
|
theme: PropTypes.string.isRequired,
|
||||||
serveSecure: PropTypes.bool.isRequired,
|
|
||||||
setServeSecure: PropTypes.func.isRequired,
|
|
||||||
setTheme: PropTypes.func.isRequired,
|
setTheme: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -277,8 +277,6 @@ class IDEView extends React.Component {
|
||||||
setSoundOutput={this.props.setSoundOutput}
|
setSoundOutput={this.props.setSoundOutput}
|
||||||
theme={this.props.preferences.theme}
|
theme={this.props.preferences.theme}
|
||||||
setTheme={this.props.setTheme}
|
setTheme={this.props.setTheme}
|
||||||
serveSecure={this.props.project.serveSecure}
|
|
||||||
setServeSecure={this.props.setServeSecure}
|
|
||||||
/>
|
/>
|
||||||
</Overlay>
|
</Overlay>
|
||||||
}
|
}
|
||||||
|
@ -560,7 +558,6 @@ IDEView.propTypes = {
|
||||||
project: PropTypes.shape({
|
project: PropTypes.shape({
|
||||||
id: PropTypes.string,
|
id: PropTypes.string,
|
||||||
name: PropTypes.string.isRequired,
|
name: PropTypes.string.isRequired,
|
||||||
serveSecure: PropTypes.bool,
|
|
||||||
owner: PropTypes.shape({
|
owner: PropTypes.shape({
|
||||||
username: PropTypes.string,
|
username: PropTypes.string,
|
||||||
id: PropTypes.string
|
id: PropTypes.string
|
||||||
|
@ -568,7 +565,6 @@ IDEView.propTypes = {
|
||||||
updatedAt: PropTypes.string
|
updatedAt: PropTypes.string
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
setProjectName: PropTypes.func.isRequired,
|
setProjectName: PropTypes.func.isRequired,
|
||||||
setServeSecure: PropTypes.func.isRequired,
|
|
||||||
openPreferences: PropTypes.func.isRequired,
|
openPreferences: PropTypes.func.isRequired,
|
||||||
editorAccessibility: PropTypes.shape({
|
editorAccessibility: PropTypes.shape({
|
||||||
lintMessages: PropTypes.array.isRequired,
|
lintMessages: PropTypes.array.isRequired,
|
||||||
|
|
|
@ -7,7 +7,6 @@ const initialState = () => {
|
||||||
const generatedName = generatedString.charAt(0).toUpperCase() + generatedString.slice(1);
|
const generatedName = generatedString.charAt(0).toUpperCase() + generatedString.slice(1);
|
||||||
return {
|
return {
|
||||||
name: generatedName,
|
name: generatedName,
|
||||||
serveSecure: isSecurePage(),
|
|
||||||
updatedAt: ''
|
updatedAt: ''
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -17,8 +16,6 @@ const project = (state, action) => {
|
||||||
state = initialState(); // eslint-disable-line
|
state = initialState(); // eslint-disable-line
|
||||||
}
|
}
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case ActionTypes.SET_SERVE_SECURE:
|
|
||||||
return Object.assign({}, { ...state }, { serveSecure: action.serveSecure });
|
|
||||||
case ActionTypes.SET_PROJECT_NAME:
|
case ActionTypes.SET_PROJECT_NAME:
|
||||||
return Object.assign({}, { ...state }, { name: action.name });
|
return Object.assign({}, { ...state }, { name: action.name });
|
||||||
case ActionTypes.NEW_PROJECT:
|
case ActionTypes.NEW_PROJECT:
|
||||||
|
@ -26,7 +23,6 @@ const project = (state, action) => {
|
||||||
id: action.project.id,
|
id: action.project.id,
|
||||||
name: action.project.name,
|
name: action.project.name,
|
||||||
updatedAt: action.project.updatedAt,
|
updatedAt: action.project.updatedAt,
|
||||||
serveSecure: action.project.serveSecure,
|
|
||||||
owner: action.owner
|
owner: action.owner
|
||||||
};
|
};
|
||||||
case ActionTypes.SET_PROJECT:
|
case ActionTypes.SET_PROJECT:
|
||||||
|
@ -34,7 +30,6 @@ const project = (state, action) => {
|
||||||
id: action.project.id,
|
id: action.project.id,
|
||||||
name: action.project.name,
|
name: action.project.name,
|
||||||
updatedAt: action.project.updatedAt,
|
updatedAt: action.project.updatedAt,
|
||||||
serveSecure: action.project.serveSecure,
|
|
||||||
owner: action.owner
|
owner: action.owner
|
||||||
};
|
};
|
||||||
case ActionTypes.RESET_PROJECT:
|
case ActionTypes.RESET_PROJECT:
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { Route, IndexRoute } from 'react-router';
|
import { Route, IndexRoute } from 'react-router';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import forceProtocol, { protocols, findSourceProtocol } from './components/forceProtocol';
|
|
||||||
import App from './modules/App/App';
|
import App from './modules/App/App';
|
||||||
import IDEView from './modules/IDE/pages/IDEView';
|
import IDEView from './modules/IDE/pages/IDEView';
|
||||||
import FullView from './modules/IDE/pages/FullView';
|
import FullView from './modules/IDE/pages/FullView';
|
||||||
|
@ -24,39 +23,27 @@ const onRouteChange = (store) => {
|
||||||
store.dispatch(stopSketch());
|
store.dispatch(stopSketch());
|
||||||
};
|
};
|
||||||
|
|
||||||
const routes = (store) => {
|
const routes = store => (
|
||||||
const sourceProtocol = findSourceProtocol(store.getState());
|
<Route path="/" component={App} onChange={() => { onRouteChange(store); }}>
|
||||||
|
<IndexRoute component={IDEView} onEnter={checkAuth(store)} />
|
||||||
// If the flag is false, we stay on HTTP
|
<Route path="/login" component={LoginView} />
|
||||||
const forceToHttps = forceProtocol({
|
<Route path="/signup" component={SignupView} />
|
||||||
targetProtocol: protocols.https,
|
<Route path="/reset-password" component={ResetPasswordView} />
|
||||||
sourceProtocol,
|
<Route path="/verify" component={EmailVerificationView} />
|
||||||
// prints debugging but does not reload page
|
<Route
|
||||||
disable: __process.env.FORCE_TO_HTTPS === false,
|
path="/reset-password/:reset_password_token"
|
||||||
});
|
component={NewPasswordView}
|
||||||
|
/>
|
||||||
return (
|
<Route path="/projects/:project_id" component={IDEView} />
|
||||||
<Route path="/" component={App} onChange={() => { onRouteChange(store); }}>
|
<Route path="/full/:project_id" component={FullView} />
|
||||||
<IndexRoute component={IDEView} onEnter={checkAuth(store)} />
|
<Route path="/sketches" component={IDEView} />
|
||||||
<Route path="/login" component={forceToHttps(LoginView)} />
|
<Route path="/assets" component={IDEView} />
|
||||||
<Route path="/signup" component={forceToHttps(SignupView)} />
|
<Route path="/account" component={AccountView} />
|
||||||
<Route path="/reset-password" component={forceToHttps(ResetPasswordView)} />
|
<Route path="/:username/sketches/:project_id" component={IDEView} />
|
||||||
<Route path="/verify" component={forceToHttps(EmailVerificationView)} />
|
<Route path="/:username/sketches" component={IDEView} />
|
||||||
<Route
|
<Route path="/about" component={IDEView} />
|
||||||
path="/reset-password/:reset_password_token"
|
<Route path="/feedback" component={IDEView} />
|
||||||
component={forceToHttps(NewPasswordView)}
|
</Route>
|
||||||
/>
|
);
|
||||||
<Route path="/projects/:project_id" component={IDEView} />
|
|
||||||
<Route path="/full/:project_id" component={FullView} />
|
|
||||||
<Route path="/sketches" component={IDEView} />
|
|
||||||
<Route path="/assets" component={IDEView} />
|
|
||||||
<Route path="/account" component={forceToHttps(AccountView)} />
|
|
||||||
<Route path="/:username/sketches/:project_id" component={IDEView} />
|
|
||||||
<Route path="/:username/sketches" component={IDEView} />
|
|
||||||
<Route path="/about" component={IDEView} />
|
|
||||||
<Route path="/feedback" component={IDEView} />
|
|
||||||
</Route>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default routes;
|
export default routes;
|
||||||
|
|
Loading…
Reference in a new issue