Skip to content

Commit

Permalink
Basic auth
Browse files Browse the repository at this point in the history
  • Loading branch information
zaneclaes committed Oct 6, 2020
1 parent 2f3218d commit 2777e97
Show file tree
Hide file tree
Showing 29 changed files with 694 additions and 199 deletions.
5 changes: 3 additions & 2 deletions bin/launch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -eo pipefail
version="0.4"
version="0.5"

MAKERVERSE_HOME=${MAKERVERSE_HOME:-${HOME}}
# Figure out where the git checkout directory lives, if any:
Expand All @@ -16,6 +16,7 @@ fi
MAKERVERSE_GIT_DIR="${MAKERVERSE_SRC_DIR}"
MAKERVERSE_LAUNCH_METHOD=${MAKERVERSE_LAUNCH_METHOD:-docker}
MAKERVERSE_SETTINGS_FILE="${MAKERVERSE_HOME}/.makerverse"
MAKERVERSE_WATCH_DIR="${MAKERVERSE_WATCH_DIR:-${MAKERVERSE_HOME}/gcode}"
MAKERVERSE_PORT="${MAKERVERSE_PORT:-8000}"

# Scan dependency versions
Expand Down Expand Up @@ -167,7 +168,7 @@ launch() {
-p "${MAKERVERSE_PORT}:8000" \
-v /dev:/dev \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$MAKERVERSE_HOME/gcode:/home/node/gcode" \
-v "$MAKERVERSE_WATCH_DIR:/home/node/gcode" \
-v "$MAKERVERSE_SETTINGS_FILE:/home/node/.makerverse" \
-v "$MAKERVERSE_SRC_DIR:/home/node/makerverse" \
"$docker_tagged"
Expand Down
34 changes: 34 additions & 0 deletions docs/features/programs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
layout: default
title: Programs
parent: Features
nav_order: 1
---

# Programs

Makerverse runs gcode (`.nc`) programs.

## Load

### Upload Program

From your workspace, press the "Upload Program" button. You will be able to select a file from your current device.

### Watch Directory

On the right side of the "Upload Program" button is an arrow. Clicking it lets you explore the "Watch Directory." For example, with a Web Server installation, you can instead place the `.nc` file into the folder at `$HOME/gcode` on the computer where Makerverse is installed.

_On the Raspberry Pi image, the watch directory is `/home/pi/gcode`._

_*Note*: Makerverse does not (yet) support folders within the watch directory._

## Run

To run the program, just press the play button (next to "Upload Program").

You can monitor the execution with the `G-code` widget.

### Multiple Devices

With a Web Server installation, you can upload a program from one computer (e.g., desktop) and then run/monitor Makerverse from another (e.g., shopfloor tablet or smartphone).
22 changes: 22 additions & 0 deletions docs/features/security.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
layout: default
title: Security
parent: Features
nav_order: 9
---

# Security

Makerverse protects access to your machine(s) with an account/log-in system.

## Account Creation

When you create (or log in) to your account, it prevents your Makerverse installation from being accessed by malicious parties. The Makerverse account system is powered by OpenWorkShop.

## Offline Usage

When you first install Makerverse and log in to your account, an internet connection is required. After that point, Makerverse will continue to work even if there is no internet available.

## Password Recovery

If at any point you become locked out of your account, you can reset your password using the email address you used to create the account.
7 changes: 7 additions & 0 deletions docs/installation/web-server/raspberry-pi.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ This is the easiest approach.

It does all the work of setting up the Docker environment (and Linux service) for you. If you prefer to set up your Raspberry Pi manually (instead of using a pre-built SD card), see the [Linux Service](/installation/web-server/linux-service/) instructions.

## Requirements

- Raspberry Pi 3B+ (or better)
- 16 GB micro SD card (or bigger)
- Power supply for the RPi
- _Optional: keyboard, mouse, and monitor_

## Choose Release

There are two download options in the [Latest Release](https://github.com/makermadecnc/makerverse/releases/latest/):
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"dependencies": {
"@babel/polyfill": "~7.4.3",
"@babel/runtime": "~7.4.3",
"@reduxjs/toolkit": "^1.4.0",
"@trendmicro/react-anchor": "~0.5.6",
"@trendmicro/react-breadcrumbs": "~0.5.5",
"@trendmicro/react-buttons": "~1.3.1",
Expand Down Expand Up @@ -214,6 +215,7 @@
"mousetrap": "~1.6.3",
"namespace-constants": "~0.5.0",
"normalize.css": "~8.0.1",
"oidc-client": "^1.10.1",
"opencollective": "~1.0.3",
"perfect-scrollbar": "~1.4.0",
"prop-types": "~15.7.2",
Expand Down Expand Up @@ -244,6 +246,7 @@
"react-toggle": "~4.0.2",
"recompose": "~0.30.0",
"redux": "~4.0.1",
"redux-oidc": "^4.0.0-beta1",
"registry-auth-token": "~3.4.0",
"registry-url": "~5.1.0",
"rimraf": "~2.6.3",
Expand Down Expand Up @@ -313,21 +316,22 @@
"json-loader": "~0.5.7",
"mini-css-extract-plugin": "~0.6.0",
"nib": "~1.1.2",
"nodemon": "~2.0.4",
"optimize-css-assets-webpack-plugin": "~5.0.1",
"pre-push": "~0.1.1",
"progress": "~2.0.3",
"react-hot-loader": "~4.8.4",
"redux-devtools": "~3.5.0",
"redux-devtools": "^3.5.0",
"run-sequence": "~2.2.1",
"style-loader": "~0.23.1",
"stylint": "~1.5.9",
"stylint-loader": "~1.0.0",
"stylus": "~0.54.5",
"stylus-loader": "~3.0.2",
"tap": "~12.6.2",
"terser-webpack-plugin": "~1.2.3",
"text-table": "~0.2.0",
"transform-loader": "~0.2.4",
"terser-webpack-plugin": "~1.2.3",
"url-loader": "~1.1.2",
"webpack": "~4.30.0",
"webpack-cli": "~3.3.1",
Expand All @@ -336,8 +340,7 @@
"webpack-hot-middleware": "~2.24.3",
"webpack-manifest-plugin": "~2.0.4",
"webpack-node-externals": "~1.7.2",
"write-file-webpack-plugin": "~4.5.0",
"nodemon": "~2.0.4"
"write-file-webpack-plugin": "~4.5.0"
},
"pre-push": [
"eslint:debug"
Expand Down
42 changes: 29 additions & 13 deletions src/app/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,42 @@ const noCache = (request) => {
}
};

const authrequest = superagentUse(superagent);
export const apirequest = superagentUse(superagent);
apirequest.use(noCache);

export const authrequest = superagentUse(superagent);
authrequest.use(bearer);
authrequest.use(noCache);

//
// Authentication
//
const signin = (options) => new Promise((resolve, reject) => {
const { token, name, password } = { ...options };

authrequest
.post('/api/signin')
.send({ token, name, password })
.end((err, res) => {
if (err) {
reject(res);
} else {
resolve(res);
}
});
// const { token, username, password } = { ...options };

// const requestedUrl = new URLSearchParams(window.location.search).get('ReturnUrl');
// args.returnUrl = requestedUrl || (await ).url;
// const args = { username, password };

// fetch(`${owsApi}/auth/login`, {
// method: 'POST',
// credentials: 'include',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify(args),
// });

// authrequest
// .post('/api/signin')
// .send({ token, name, password })
// .end((err, res) => {
// if (err) {
// reject(res);
// } else {
// resolve(res);
// }
// });
});

//
Expand Down
22 changes: 18 additions & 4 deletions src/app/components/ProtectedRoute/index.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React from 'react';
// import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Route, Redirect, withRouter } from 'react-router-dom';
import * as user from 'app/lib/user';
import log from 'app/lib/log';

const ProtectedRoute = ({ component: Component, ...rest }) => (
<Route
{...rest}
render={props => {
if (user.isAuthenticated()) {
if (props.user) {
log.debug('User is authenticated.', props.user);
return Component ? <Component {...rest} /> : null;
}

Expand All @@ -34,7 +36,19 @@ const ProtectedRoute = ({ component: Component, ...rest }) => (
);

ProtectedRoute.propTypes = {
...withRouter.propTypes
...withRouter.propTypes,
};

export default ProtectedRoute;
function mapStateToProps(state) {
return {
user: state.oidc.user
};
}

function mapDispatchToProps(dispatch) {
return {
dispatch
};
}

export default connect(mapStateToProps, mapDispatchToProps)(ProtectedRoute);
Loading

0 comments on commit 2777e97

Please sign in to comment.