|
|
@ -34,11 +34,17 @@ type Auth struct {
|
|
|
|
Algorithm string
|
|
|
|
Algorithm string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (a *Auth) FeedWwwAuthenticate(s string, username, password string) {
|
|
|
|
func (a *Auth) FeedWwwAuthenticate(auths []string, username, password string) {
|
|
|
|
a.Username = username
|
|
|
|
a.Username = username
|
|
|
|
a.Password = password
|
|
|
|
a.Password = password
|
|
|
|
|
|
|
|
//目前只处理第一个
|
|
|
|
s = strings.TrimPrefix(s, HeaderWwwAuthenticate)
|
|
|
|
var s string
|
|
|
|
|
|
|
|
if len(auths)>0{
|
|
|
|
|
|
|
|
s = auths[0]
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
s = strings.TrimPrefix(s, HeaderWwwAuthenticate)
|
|
|
|
s = strings.TrimSpace(s)
|
|
|
|
s = strings.TrimSpace(s)
|
|
|
|
if strings.HasPrefix(s, AuthTypeBasic) {
|
|
|
|
if strings.HasPrefix(s, AuthTypeBasic) {
|
|
|
|
a.Typ = AuthTypeBasic
|
|
|
|
a.Typ = AuthTypeBasic
|
|
|
|