Merge pull request #31 from acls/rtsp-digest-auth

RTSP Use basic auth or digest auth, not both
This commit is contained in:
nareix 2017-11-02 23:19:52 -05:00 committed by GitHub
commit af80c44445
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -350,16 +350,18 @@ func (self *Client) handle401(res *Response) (err error) {
password, _ = self.url.User.Password() password, _ = self.url.User.Password()
self.authHeaders = func(method string) []string { self.authHeaders = func(method string) []string {
headers := []string{ var headers []string
if nonce == "" {
headers = []string{
fmt.Sprintf(`Authorization: Basic %s`, base64.StdEncoding.EncodeToString([]byte(username+":"+password))), fmt.Sprintf(`Authorization: Basic %s`, base64.StdEncoding.EncodeToString([]byte(username+":"+password))),
} }
if nonce != "" { } else {
hs1 := md5hash(username + ":" + realm + ":" + password) hs1 := md5hash(username + ":" + realm + ":" + password)
hs2 := md5hash(method + ":" + self.requestUri) hs2 := md5hash(method + ":" + self.requestUri)
response := md5hash(hs1 + ":" + nonce + ":" + hs2) response := md5hash(hs1 + ":" + nonce + ":" + hs2)
headers = append(headers, fmt.Sprintf( headers = []string{fmt.Sprintf(
`Authorization: Digest username="%s", realm="%s", nonce="%s", uri="%s", response="%s"`, `Authorization: Digest username="%s", realm="%s", nonce="%s", uri="%s", response="%s"`,
username, realm, nonce, self.requestUri, response)) username, realm, nonce, self.requestUri, response)}
} }
return headers return headers
} }