mirror of
https://github.com/aler9/gortsplib
synced 2025-10-07 08:01:14 +08:00
support authenticating with SHA-256 digest (#524)
This commit is contained in:
23
pkg/auth/www_authenticate.go
Normal file
23
pkg/auth/www_authenticate.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/base"
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/headers"
|
||||
)
|
||||
|
||||
// GenerateWWWAuthenticate generates a WWW-Authenticate header.
|
||||
func GenerateWWWAuthenticate(methods []headers.AuthMethod, realm string, nonce string) base.HeaderValue {
|
||||
if methods == nil {
|
||||
methods = []headers.AuthMethod{headers.AuthDigestSHA256, headers.AuthDigestMD5, headers.AuthBasic}
|
||||
}
|
||||
|
||||
var ret base.HeaderValue
|
||||
for _, m := range methods {
|
||||
ret = append(ret, headers.Authenticate{
|
||||
Method: m,
|
||||
Realm: realm,
|
||||
Nonce: nonce, // used only by digest
|
||||
}.Marshal()...)
|
||||
}
|
||||
return ret
|
||||
}
|
Reference in New Issue
Block a user