mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-23 08:56:31 +01:00
19 lines
568 B
Go
19 lines
568 B
Go
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,
|
|
Password: promauth.NewSecret(baPass),
|
|
PasswordFile: baFile,
|
|
}
|
|
}
|
|
return promauth.NewConfig(".", nil, baCfg, bearerToken, bearerTokenFile, nil, nil)
|
|
}
|