// AddBasicAuth - add basic auth on the request
506827
func (r Request) AddBasicAuth(username string, password string) Request {
	r.BasicAuth.Password = password
	r.BasicAuth.Username = username
	return r
}
136955
func BasicAuth(fn BasicValidateFunc, skipper ...echo.Skipper) echo.MiddlewareFunc {
	var isSkiped echo.Skipper
	if len(skipper) > 0 {
		isSkiped = skipper[0]
	} else {
		isSkiped = echo.DefaultSkipper
	}
	return func(h echo.Handler) echo.Handler {
		return echo.HandlerFunc(func(c echo.Context) error {
			if isSkiped(c) {
				return h.Handle(c)
			}
			auth := c.Request().Header().Get(echo.HeaderAuthorization)
			l := len(basic)

			if len(auth) > l+1 && auth[:l] == basic {
				b, err := base64.StdEncoding.DecodeString(auth[l+1:])
				if err == nil {
					cred := string(b)
					for i := 0; i < len(cred); i++ {
						if cred[i] == ':' {
							// Verify credentials
							if fn(cred[:i], cred[i+1:]) {
								return h.Handle(c)
							}
						}
					}
				}
			}
			c.Response().Header().Set(echo.HeaderWWWAuthenticate, basic+" realm=Restricted")
			return echo.NewHTTPError(http.StatusUnauthorized)
		})
	}
}
364697
func newAuthenticatorFromBasicAuthFile(basicAuthFile string) (authenticator.Request, error) {
	basicAuthenticator, err := passwordfile.NewCSV(basicAuthFile)
	if err != nil {
		return nil, err
	}

	return basicauth.New(basicAuthenticator), nil
}
1206457
func (ba *BasicAuth) AddPrincipal(user, pass string) {
	ba.Lock()
	u, existed := ba.creds[user]
	if !existed {
		u = make([]string, 0, 1)
	}
	ba.creds[user] = append(u, pass)
	ba.Unlock()
}
173383
func BasicAuth(fn BasicAuthValidator) echo.MiddlewareFunc {
	c := DefaultBasicAuthConfig
	c.Validator = fn
	return BasicAuthWithConfig(c)
}
69409
func (ca *CoreAdmin) SetBasicAuth(username, password string) {
	ca.username = username
	ca.password = password
}
257943
func (G *global_data) BasicAuth(user, passwd string) *global_data {
	G.Req.BasicAuth = request.BasicAuth{user, passwd}
	return G
}
629249
func newBasicAuthentication(userName, password string) httpAuthentication {
	auth := fmt.Sprintf("%s:%s", userName, password)
	encoded := base64.StdEncoding.EncodeToString([]byte(auth))
	return &basicAuthentication{
		authorizationValue: "Basic " + encoded,
	}
}
717359
func NewWithBasicAuth(server, username, password string) *Account {
	return New(server).WithAuth(auth.BasicAuth(username, password))
}
808677
func Basic(username string, password string) macaron.Handler {
	var siteAuth = base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
	return func(res http.ResponseWriter, req *http.Request, c *macaron.Context) {
		auth := req.Header.Get("Authorization")
		if !SecureCompare(auth, basicPrefix+siteAuth) {
			basicUnauthorized(res)
			return
		}
		c.Map(User(username))
	}
}
1253746
func BasicAuth(username, password string) ClientOpt {
	return func(c *Client) {
		c.Handlers.Build.Append(request.BasicAuther(username, password))
	}
}
62679
func (r *RequestConfig) BasicAuth(username, password string) *RequestConfig {
	r.User = username
	r.Password = password
	return r
}
860386
func (s *Sling) SetBasicAuth(username, password string) *Sling {
	return s.Set("Authorization", "Basic "+basicAuth(username, password))
}
516517
func newBasicAuthentication(userName, password string) vstAuthentication {
	return &vstAuthenticationImpl{
		encryption: "plain",
		userName:   userName,
		password:   password,
	}
}
765545
func (s *UpdateBranchInput) SetEnableBasicAuth(v bool) *UpdateBranchInput {
	s.EnableBasicAuth = &v
	return s
}
365299
func (s *CreateBranchInput) SetBasicAuthCredentials(v string) *CreateBranchInput {
	s.BasicAuthCredentials = &v
	return s
}
120603
func (s *Branch) SetEnableBasicAuth(v bool) *Branch {
	s.EnableBasicAuth = &v
	return s
}