casdoor / casdoor

An open-source UI-first Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML, CAS, LDAP, SCIM, WebAuthn, TOTP, MFA, Face ID, RADIUS, Google Workspace, Active Directory and Kerberos
https://casdoor.org
Apache License 2.0
9.2k stars 1.09k forks source link

Add Host Configuration Option for Enhanced Security with Nginx Reverse Proxy #2962

Closed moemoequte closed 1 month ago

moemoequte commented 1 month ago

I am currently using Casdoor and noticed that it only allows configuration of the listening port, defaulting to listen on 0.0.0.0. This setup makes it challenging to securely configure Casdoor behind an Nginx reverse proxy without exposing additional ports to the outside network.

09eddcaa500616bb2fe0600edfeb6fed

Issue Description:

Proposed Solution: I propose adding a configuration option that allows users to specify the listening host address. For instance, being able to set the host to 127.0.0.1 would enable the application to only listen on the local machine, thus enhancing security when using reverse proxies like Nginx.

Benefits:

I believe this feature would be beneficial for many users who are looking to secure their Casdoor deployments more effectively. Looking forward to your thoughts on this.

Thank you for considering this enhancement.

casbin-bot commented 1 month ago

@tangyang9464 @JalinWang @imp2002

hsluoyz commented 1 month ago

@moemoequte modify this line: https://github.com/casdoor/casdoor/blob/bfcfb56336799ff24068f06e7d1aaa214d75d4ff/main.go#L88

to: beego.Run(fmt.Sprintf("127.0.0.1:%v", port))

No need to add config, there are already too many configs.

It's listening to 8000 by default. But if you don't open that port in your OS, it will not be unsecure. So the root cause is still on YOU!

alfredosola commented 1 week ago

I have to disagree. Security is layered. Unless someone explicitly installs a firewall, casdoor will happily listen on http-alt and respond there. It should be safe by default, not requiring additional steps for hardening. Take a look e.g. at Debian's packaging of Mysql/MariaDB: it only listens on localhost by default.