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

[BUG] Userpass doesn't work if username contains uppercase letters #1297

Open
haruue opened this issue Jan 9, 2025 · 1 comment
Open

[BUG] Userpass doesn't work if username contains uppercase letters #1297

haruue opened this issue Jan 9, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@haruue
Copy link
Collaborator

haruue commented Jan 9, 2025

reported-by: @codetang-2417
ref: #1174 (comment) #1174 (comment)

Reproduce

Server

listen: :8443

tls:
  cert: /etc/hysteria/server.crt
  key: /etc/hysteria/server.key
  sniGuard: disable

auth:
  type: userpass
  userpass:
    user1: pass
    User2: pass

Client

server: 127.0.0.1:8443

#auth: user1:pass
auth: User2:pass

tls:
  insecure: true

socks5:
  listen: 127.0.0.1:21080

When using auth: user1:pass, the Hysteria connection can be established, but it fails when using auth: User2:pass.

2025-01-09T21:40:54+09:00       FATAL   failed to initialize client     {"error": "authentication error, HTTP status code: 404"}

Why?

Simply add a log here

diff --git a/app/cmd/server.go b/app/cmd/server.go
index 5f2d562..c4bf656 100644
--- a/app/cmd/server.go
+++ b/app/cmd/server.go
@@ -755,6 +755,7 @@ func (c *serverConfig) fillAuthenticator(hyConfig *server.Config) error {
                if len(c.Auth.UserPass) == 0 {
                        return configError{Field: "auth.userpass", Err: errors.New("empty auth userpass")}
                }
+               logger.Info("parsed userpass", zap.Any("userpass", c.Auth.UserPass))
                hyConfig.Authenticator = &auth.UserPassAuthenticator{Users: c.Auth.UserPass}
                return nil
        case "http", "https":

We will get

2025-01-09T21:44:58+09:00       INFO    parsed userpass {"userpass": {"user1":"pass","user2":"pass"}}

This issue is caused by viper, which silently converts all map keys to lower case (spf13/viper#373), and there is still no option to disable this behavior.

@haruue haruue added the bug Something isn't working label Jan 9, 2025
@codetang-2417
Copy link

感谢您的努力!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants