2024-03-04 13:20:34 +00:00
|
|
|
package conf
|
|
|
|
|
2024-05-04 08:12:43 +00:00
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
)
|
|
|
|
|
2024-03-04 13:20:34 +00:00
|
|
|
// AuthInternalUserPermission is a permission of a user.
|
|
|
|
type AuthInternalUserPermission struct {
|
|
|
|
Action AuthAction `json:"action"`
|
|
|
|
Path string `json:"path"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// AuthInternalUser is an user.
|
|
|
|
type AuthInternalUser struct {
|
|
|
|
User Credential `json:"user"`
|
|
|
|
Pass Credential `json:"pass"`
|
|
|
|
IPs IPNetworks `json:"ips"`
|
|
|
|
Permissions []AuthInternalUserPermission `json:"permissions"`
|
|
|
|
}
|
2024-05-04 08:12:43 +00:00
|
|
|
|
|
|
|
// AuthInternalUsers is a list of AuthInternalUser
|
|
|
|
type AuthInternalUsers []AuthInternalUser
|
|
|
|
|
|
|
|
// UnmarshalJSON implements json.Unmarshaler.
|
|
|
|
func (s *AuthInternalUsers) UnmarshalJSON(b []byte) error {
|
|
|
|
// remove default value before loading new value
|
|
|
|
// https://github.com/golang/go/issues/21092
|
|
|
|
*s = nil
|
|
|
|
return json.Unmarshal(b, (*[]AuthInternalUser)(s))
|
|
|
|
}
|
|
|
|
|
|
|
|
// AuthInternalUserPermissions is a list of AuthInternalUserPermission
|
|
|
|
type AuthInternalUserPermissions []AuthInternalUserPermission
|
|
|
|
|
|
|
|
// UnmarshalJSON implements json.Unmarshaler.
|
|
|
|
func (s *AuthInternalUserPermissions) UnmarshalJSON(b []byte) error {
|
|
|
|
// remove default value before loading new value
|
|
|
|
// https://github.com/golang/go/issues/21092
|
|
|
|
*s = nil
|
|
|
|
return json.Unmarshal(b, (*[]AuthInternalUserPermission)(s))
|
|
|
|
}
|