diff --git a/README.md b/README.md index b7c8ccf..b54de4d 100755 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ Advanced manual setups are also supported. Check the following environment varia | ZU_DEFAULT_USERNAME | unset (`docker-compose.yml`: admin) | Default username that will be set on the first run | | ZU_DEFAULT_PASSWORD | unset (`docker-compose.yml`: zero-ui) | Default password that will be set on the first run | | ZU_DATAPATH | `data/db.json` | ZeroUI data storage path | -| ZU_DISABLE_AUTH | unset | If set to true, automatically log in all users. This is useful if ZeroUI is protected by an authentication proxy | +| ZU_DISABLE_AUTH | unset | If set to true, automatically log in all users. This is useful if ZeroUI is protected by an authentication proxy. Note that when this value is changed, the localStorage of instances of logged-in panels should be cleared | ZeroUI could be deployed as a regular nodejs web application, but it requires ZeroTier controller that is installed with `zerotier-one` package. More info about the network controller you could read [here](https://github.com/zerotier/ZeroTierOne/tree/master/controller/#readme). diff --git a/backend/app.js b/backend/app.js index b2a9eff..263a965 100644 --- a/backend/app.js +++ b/backend/app.js @@ -18,11 +18,13 @@ const app = express(); app.use(logger("dev")); app.use(express.json()); app.use(express.urlencoded({ extended: false })); -app.use( - bearerToken({ - headerKey: "Bearer", - }) -); +if (process.env.ZU_DISABLE_AUTH !== "true") { + app.use( + bearerToken({ + headerKey: "Bearer", + }) + ); +} if ( process.env.NODE_ENV === "production" && diff --git a/frontend/src/components/Bar/Bar.jsx b/frontend/src/components/Bar/Bar.jsx index 444a06f..7f24969 100644 --- a/frontend/src/components/Bar/Bar.jsx +++ b/frontend/src/components/Bar/Bar.jsx @@ -21,6 +21,7 @@ import LogIn from "components/LogIn"; function Bar() { const [loggedIn, setLoggedIn] = useLocalStorage("loggedIn", false); + const [disabledAuth] = useLocalStorage("disableAuth", false); const [anchorEl, setAnchorEl] = useState(null); const history = useHistory(); @@ -46,11 +47,15 @@ function Bar() { // name: "Settings", // to: "/settings", // }, - { - name: "Log out", - divide: true, - onClick: onLogOutClick, - }, + ...(!disabledAuth + ? [ + { + name: "Log out", + divide: true, + onClick: onLogOutClick, + }, + ] + : []), ]; return ( @@ -72,8 +77,7 @@ function Bar() { - - {loggedIn && ( + {loggedIn && menuItems.length > 0 && ( <>