Skip to content
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

Add way to filter IP addresses to be allowed to access #3981

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

inverse
Copy link

@inverse inverse commented Nov 5, 2023

⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules:
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma

Tick the checkbox if you understand [x]:

  • I have read and understand the pull request rules.

Description

Provides a flag to restrict IPs that should be able to access the server by providing a comma seperated arg or env var that can be used to provide an allow list of IP addresses. e.g

node server/server.js --ips-to-allow=::1,::ffff:192.168.1.67

A requirement for Home Assistant Ingress is to restrict access.

See: https://developers.home-assistant.io/docs/add-ons/presentation/#ingress

Fixes #(issue)

Type of change

Please delete any options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas
    (including JSDoc for methods)
  • My changes generate no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

Please do not use any external image service. Instead, just paste in or drag and drop the image here, and it will be uploaded automatically.

@Zaid-maker
Copy link
Contributor

Zaid-maker commented Nov 5, 2023

We suport multiple node version so i dont think its good to add .nvmrc. we support 14/ 16/ 18/ 20.4.

@freiit
Copy link

freiit commented Nov 10, 2023

Can you replace your typeof ipsToAllow !== "string" with something like this ipsToAllow?.split(',').every(ip => net.isIP(ip))?

@Zaid-maker
Copy link
Contributor

Can you replace your typeof ipsToAllow !== "string" with something like this ipsToAllow?.split(',').every(ip => net.isIP(ip))?

You can review the code and tell that there by going to Commits tab.

Copy link

@freiit freiit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace your typeof ipsToAllow !== "string" with something like this ipsToAllow?.split(',').every(ip => net.isIP(ip))

@inverse
Copy link
Author

inverse commented Nov 11, 2023

@freiit Adding IP validation sounds like a good idea!

But don't I also need to have the type validation first? For example if I pass --ips-to-allow=1 it gets treats as a number.

2023-11-11T11:31:50+01:00 [SERVER] ERROR: IPs to allow must be a string, number provided

@inverse
Copy link
Author

inverse commented Nov 11, 2023

One open question - where should I document the flag/env var?

I see there is https://github.com/louislam/uptime-kuma/wiki/Environment-Variables but I guess you need to have elevated permissions to modify.

@louislam louislam added this to the 2.2.0 milestone Nov 16, 2023
@louislam
Copy link
Owner

The wiki is in another repo: https://github.com/louislam/uptime-kuma-wiki

Also want to remind that Uptime Kuma is mainly a Socket.io application, express is just part of it. Not sure if express-ipfilter handle Socket.io connection too.

Will come back and review in the milestone 2.2.0.

@CommanderStorm CommanderStorm added the pr:needs review this PR needs a review by maintainers or other community members label May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:needs review this PR needs a review by maintainers or other community members security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants