2020-10-14 23:22:58 +00:00
|
|
|
package security
|
|
|
|
|
2020-10-23 19:58:59 +00:00
|
|
|
// Config is the security configuration for Gatus
|
2020-10-14 23:22:58 +00:00
|
|
|
type Config struct {
|
|
|
|
Basic *BasicConfig `yaml:"basic"`
|
|
|
|
}
|
|
|
|
|
2020-10-23 19:58:59 +00:00
|
|
|
// IsValid returns whether the security configuration is valid or not
|
2020-10-14 23:22:58 +00:00
|
|
|
func (c *Config) IsValid() bool {
|
|
|
|
return c.Basic != nil && c.Basic.IsValid()
|
|
|
|
}
|
|
|
|
|
2020-10-23 19:58:59 +00:00
|
|
|
// BasicConfig is the configuration for Basic authentication
|
2020-10-14 23:22:58 +00:00
|
|
|
type BasicConfig struct {
|
2020-10-23 19:58:59 +00:00
|
|
|
// Username is the name which will need to be used for a successful authentication
|
|
|
|
Username string `yaml:"username"`
|
|
|
|
|
|
|
|
// PasswordSha512Hash is the SHA512 hash of the password which will need to be used for a successful authentication
|
2020-10-14 23:22:58 +00:00
|
|
|
PasswordSha512Hash string `yaml:"password-sha512"`
|
|
|
|
}
|
|
|
|
|
2020-10-23 19:58:59 +00:00
|
|
|
// IsValid returns whether the basic security configuration is valid or not
|
2020-10-14 23:22:58 +00:00
|
|
|
func (c *BasicConfig) IsValid() bool {
|
|
|
|
return len(c.Username) > 0 && len(c.PasswordSha512Hash) == 128
|
|
|
|
}
|