mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-20 02:00:05 -08:00
Some checks failed
code_lint / go (push) Has been cancelled
code_lint / go_mod (push) Has been cancelled
code_lint / docs (push) Has been cancelled
code_lint / api_docs (push) Has been cancelled
code_test / test_64 (push) Has been cancelled
code_test / test_32 (push) Has been cancelled
code_test / test_e2e (push) Has been cancelled
23 lines
578 B
Go
23 lines
578 B
Go
package rtsp
|
|
|
|
import (
|
|
"github.com/bluenviron/gortsplib/v5/pkg/base"
|
|
"github.com/bluenviron/gortsplib/v5/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
|
|
}
|