mirror of
https://github.com/bluenviron/mediamtx
synced 2024-12-13 10:14:58 +00:00
575d3585fe
when some subfields of authInternalUsers or authHTTPExclude were not set explicitly in the configuration file, default values were used in their place. This is caused by a strange behavior of Go (https://github.com/golang/go/issues/21092)
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package conf
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
// 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"`
|
|
}
|
|
|
|
// 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))
|
|
}
|