From 00e4ece170c418b02702af8d51e8c697e39a1712 Mon Sep 17 00:00:00 2001 From: ginuerzh Date: Sat, 3 Sep 2022 16:26:52 +0800 Subject: [PATCH] fix panic caused by auth logger --- auth/auth.go | 2 +- config/parsing/parse.go | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/auth/auth.go b/auth/auth.go index 13e84cf..c3f2e00 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -23,7 +23,7 @@ type options struct { type Option func(opts *options) -func AuthsPeriodOption(auths map[string]string) Option { +func AuthsOption(auths map[string]string) Option { return func(opts *options) { opts.auths = auths } diff --git a/config/parsing/parse.go b/config/parsing/parse.go index d22b6f1..7153de1 100644 --- a/config/parsing/parse.go +++ b/config/parsing/parse.go @@ -40,7 +40,7 @@ func ParseAuther(cfg *config.AutherConfig) auth.Authenticator { } opts := []auth_impl.Option{ - auth_impl.AuthsPeriodOption(m), + auth_impl.AuthsOption(m), auth_impl.ReloadPeriodOption(cfg.Reload), auth_impl.LoggerOption(logger.Default().WithFields(map[string]any{ "kind": "auther", @@ -67,11 +67,15 @@ func ParseAutherFromAuth(au *config.AuthConfig) auth.Authenticator { return nil } return auth_impl.NewAuthenticator( - auth_impl.AuthsPeriodOption( + auth_impl.AuthsOption( map[string]string{ au.Username: au.Password, }, - )) + ), + auth_impl.LoggerOption(logger.Default().WithFields(map[string]any{ + "kind": "auther", + })), + ) } func parseAuth(cfg *config.AuthConfig) *url.Userinfo {