mirror of
https://github.com/bluenviron/mediamtx.git
synced 2026-01-25 21:09:15 -08:00
Some checks are pending
code_lint / golangci_lint (push) Waiting to run
code_lint / mod_tidy (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_e2e (push) Waiting to run
This is safer than passing JWTs through query parameters, unfortunately support is limited.
23 lines
578 B
Go
23 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
|
|
}
|