feat: command auth

This commit is contained in:
Toby
2023-08-12 13:12:36 -07:00
parent d3db1e4a1d
commit 25b8eef959
4 changed files with 37 additions and 0 deletions

View File

@@ -98,6 +98,7 @@ type serverConfigAuth struct {
Password string `mapstructure:"password"`
UserPass map[string]string `mapstructure:"userpass"`
HTTP serverConfigAuthHTTP `mapstructure:"http"`
Command string `mapstructure:"command"`
}
type serverConfigResolverTCP struct {
@@ -405,6 +406,12 @@ func (c *serverConfig) fillAuthenticator(hyConfig *server.Config) error {
}
hyConfig.Authenticator = auth.NewHTTPAuthenticator(c.Auth.HTTP.URL, c.Auth.HTTP.Insecure)
return nil
case "command", "cmd":
if c.Auth.Command == "" {
return configError{Field: "auth.command", Err: errors.New("empty auth command")}
}
hyConfig.Authenticator = &auth.CommandAuthenticator{Cmd: c.Auth.Command}
return nil
default:
return configError{Field: "auth.type", Err: errors.New("unsupported auth type")}
}