Files
rtsp-simple-server/internal/protocols/rtsp/credentials.go
Alessandro Ros f97213ae6e support passing JWTs through the password field (#4516)
This is safer than passing JWTs through query parameters, unfortunately support is limited.
2025-05-10 22:54:24 +02:00

24 lines
578 B
Go

package rtsp
import (
"github.com/bluenviron/gortsplib/v4/pkg/base"
"github.com/bluenviron/gortsplib/v4/pkg/headers"
"github.com/bluenviron/mediamtx/internal/auth"
)
// Credentials extracts credentials from a RTSP request.
func Credentials(rt *base.Request) *auth.Credentials {
c := &auth.Credentials{}
var rtspAuthHeader headers.Authorization
err := rtspAuthHeader.Unmarshal(rt.Header["Authorization"])
if err == nil {
c.User = rtspAuthHeader.Username
if rtspAuthHeader.Method == headers.AuthMethodBasic {
c.Pass = rtspAuthHeader.BasicPass
}
}
return c
}