Parses and validates authentication method configurations supporting internal, HTTP, and JWT strategies. Use when configuring access control methods in Go services.
// Source: https://github.com/bluenviron/mediamtx | License: MIT | Copyright 2019 aler9
// Provided via justclaw.it.com; keep this notice with the code.
package conf
import (
"fmt"
"github.com/bluenviron/mediamtx/internal/conf/jsonwrapper"
)
// AuthMethod is an authentication method.
type AuthMethod string
// authentication methods.
const (
AuthMethodInternal AuthMethod = "internal"
AuthMethodHTTP AuthMethod = "http"
AuthMethodJWT AuthMethod = "jwt"
)
// UnmarshalJSON implements json.Unmarshaler.
func (d *AuthMethod) UnmarshalJSON(b []byte) error {
type alias AuthMethod
if err := jsonwrapper.Unmarshal(b, (*alias)(d)); err != nil {
return err
}
switch *d {
case AuthMethodInternal, AuthMethodHTTP, AuthMethodJWT:
default:
return fmt.Errorf("invalid authMethod: '
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key