Files
mediamtx/internal/defs/path_access_request.go
T
Alessandro RosandGitHub 58c6099e50 ask for credentials only in case of protocols that support it (#5966)
When clients connect with some protocols (SRT, RTMP), they are unable
to provide credentials even if they are asked to. In this case, it's
useless to wait for credentials, and it's better to immediately log
authentication errors and apply the anti-brute force algorithm.
2026-07-19 16:52:14 +02:00

48 lines
1.2 KiB
Go

package defs
import (
"net"
"github.com/bluenviron/mediamtx/internal/auth"
"github.com/bluenviron/mediamtx/internal/conf"
"github.com/google/uuid"
)
// PathAccessRequest is a path access request.
type PathAccessRequest struct {
Name string
Query string
UserAgent string
Publish bool
SkipAuth bool
// only if skipAuth = false
Proto auth.Protocol
ID *uuid.UUID
Credentials *auth.Credentials
IP net.IP
CustomVerifyFunc func(expectedUser string, expectedPass string) bool
EnableAskCredentials bool
}
// ToAuthRequest converts a path access request into an authentication request.
func (r *PathAccessRequest) ToAuthRequest() *auth.Request {
return &auth.Request{
Action: func() conf.AuthAction {
if r.Publish {
return conf.AuthActionPublish
}
return conf.AuthActionRead
}(),
Path: r.Name,
Query: r.Query,
Protocol: r.Proto,
ID: r.ID,
UserAgent: r.UserAgent,
Credentials: r.Credentials,
IP: r.IP,
CustomVerifyFunc: r.CustomVerifyFunc,
EnableAskCredentials: r.EnableAskCredentials,
}
}