Add support auth for RTSP server

This commit is contained in:
Alexey Khit
2022-11-27 10:08:37 +03:00
parent 5678121c50
commit 1b518b94fd
3 changed files with 44 additions and 4 deletions

View File

@@ -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 {