Skip to content

Commit

Permalink
Merge pull request #43 from RunOnFlux/development
Browse files Browse the repository at this point in the history
adjust authuser
  • Loading branch information
alihm authored Aug 12, 2023
2 parents 2e2997d + 54bb1e9 commit d63b3e6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ClusterOperator/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ function auth(ip) {
/**
* [authUser]
*/
function authUser() {
function authUser(ip) {
const whiteList = config.whiteListedIps.split(',');
if (whiteList.length && whiteList.includes(ip)) return true;
return false;
}
/**
Expand Down Expand Up @@ -274,13 +276,12 @@ function startUI() {

app.get('/', (req, res) => {
let remoteIp = utill.convertIP(req.ip);
const whiteList = config.whiteListedIps.split(',');
if (req.headers['x-forwarded-for']) {
remoteIp = req.headers['x-forwarded-for'];
}
// log.info(JSON.stringify(req.headers));
// log.info(`UI access from ${remoteIp}`);
if (authUser()) {
if (authUser(remoteIp)) {
res.sendFile(path.join(__dirname, '../ui/index.html'));
} else {
res.sendFile(path.join(__dirname, '../ui/login.html'));
Expand Down

0 comments on commit d63b3e6

Please sign in to comment.