2021-09-14 22:53:31 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promauth"
|
|
|
|
)
|
|
|
|
|
|
|
|
// AuthConfig returns promauth.Config based on the given params
|
|
|
|
func AuthConfig(baUser, baPass, baFile, bearerToken, bearerTokenFile string) (*promauth.Config, error) {
|
|
|
|
var baCfg *promauth.BasicAuthConfig
|
|
|
|
if baUser != "" || baPass != "" || baFile != "" {
|
|
|
|
baCfg = &promauth.BasicAuthConfig{
|
|
|
|
Username: baUser,
|
2021-11-05 12:41:14 +00:00
|
|
|
Password: promauth.NewSecret(baPass),
|
2021-09-14 22:53:31 +00:00
|
|
|
PasswordFile: baFile,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return promauth.NewConfig(".", nil, baCfg, bearerToken, bearerTokenFile, nil, nil)
|
|
|
|
}
|