// UnauthenticatedResponse writes the unauthenticated response
UnauthenticatedResponse writes the unauthenticated response
// UnauthenticatedResponse writes the unauthenticated response
func UnauthenticatedResponse(res http.ResponseWriter, req *http.Request, upstreamPath string) {
	uri := url.URL{
		Scheme: "http",
		Host:   req.Host,
		Path:   "_/v1/auth",
	}
	if req.TLS != nil {
		uri.Scheme = "https"
	}
	if host := req.Header.Get("X-Forwarded-Host"); host != "" {
		uri.Host = host
	}
	if scheme := req.Header.Get("X-Forwarded-Proto"); scheme != "" {
		uri.Scheme = scheme
	}
	realm := uri.String()
	service := req.Host
	scope := GetScope(req, upstreamPath)
	res.Header().Set(
		"Www-Authenticate",
		fmt.Sprintf(
			`Bearer realm="%s",service="%s",scope="%s"`,
			realm,
			service,
			scope,
		),
	)
	res.WriteHeader(http.StatusUnauthorized)
}
func UnauthenticatedResponse ( res http . ResponseWriter , req * http . Request , upstreamPath string ) { uri := url . URL { Scheme : " " , Host : req . Host , Path : " " , } if req . TLS != nil { uri . Scheme = " " } if host := req . Header . Get ( " " ) ; host != " " { uri . Host = host } if scheme := req . Header . Get ( " " ) ; scheme != " " { uri . Scheme = scheme } realm := uri . String ( ) service := req . Host scope := GetScope ( req , upstreamPath ) res . Header ( ) . Set ( " " , fmt . Sprintf ( `Bearer realm="%s",service="%s",scope="%s"` , realm , service , scope , ) , ) res . WriteHeader ( http . StatusUnauthorized ) }
UnauthenticatedResponse writes the unauthenticated response
UnauthenticatedResponse writes the unauthenticated response
// realm := "https://auth.docker.io/token" // service := "registry.docker.io"