mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-20 10:10:03 -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.
43 lines
1 KiB
Go
43 lines
1 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
|
|
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
|
|
}
|
|
|
|
// 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,
|
|
Credentials: r.Credentials,
|
|
IP: r.IP,
|
|
CustomVerifyFunc: r.CustomVerifyFunc,
|
|
}
|
|
}
|