mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-10-13 12:03:52 +08:00
Add support auth for RTSP server
This commit is contained in:
@@ -80,6 +80,24 @@ func (a *Auth) Write(req *Request) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Auth) Validate(req *Request) bool {
|
||||
if a == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
header := req.Header.Get("Authorization")
|
||||
if header == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
if a.Method == AuthUnknown {
|
||||
a.Method = AuthBasic
|
||||
a.header = "Basic " + B64(a.user, a.pass)
|
||||
}
|
||||
|
||||
return header == a.header
|
||||
}
|
||||
|
||||
func Between(s, sub1, sub2 string) string {
|
||||
i := strings.Index(s, sub1)
|
||||
if i < 0 {
|
||||
|
Reference in New Issue
Block a user