func ValidateDCARequest(w http.ResponseWriter, r *http.Request) error {
	var err error
	auth := r.Header.Get("Authorization")
	if auth == "" {
		w.Header().Set("WWW-Authenticate", `Bearer realm="Datadog Agent"`)
		err = fmt.Errorf("no session token provided")
		http.Error(w, err.Error(), 401)
		return err
	}

	tok := strings.Split(auth, " ")
	if tok[0] != "Bearer" {
		w.Header().Set("WWW-Authenticate", `Bearer realm="Datadog Agent"`)
		err = fmt.Errorf("unsupported authorization scheme: %s", tok[0])
		http.Error(w, err.Error(), 401)
		return err
	}

	if len(tok) != 2 || tok[1] != GetDCAAuthToken() {
		err = fmt.Errorf("invalid session token")
		http.Error(w, err.Error(), 403)
	}

	return err
}
// ValidateDCARequest is used for the exposed endpoints of the DCA.
// It is different from Validate as we want to have different validations.
ValidateDCARequest is used for the exposed endpoints of the DCA.
It is different from Validate as we want to have different validations.
// ValidateDCARequest is used for the exposed endpoints of the DCA . // It is different from Validate as we want to have different validations .
func ValidateDCARequest(w http.ResponseWriter, r *http.Request) error {
	var err error
	auth := r.Header.Get("Authorization")
	if auth == "" {
		w.Header().Set("WWW-Authenticate", `Bearer realm="Datadog Agent"`)
		err = fmt.Errorf("no session token provided")
		http.Error(w, err.Error(), 401)
		return err
	}
	tok := strings.Split(auth, " ")
	if tok[0] != "Bearer" {
		w.Header().Set("WWW-Authenticate", `Bearer realm="Datadog Agent"`)
		err = fmt.Errorf("unsupported authorization scheme: %s", tok[0])
		http.Error(w, err.Error(), 401)
		return err
	}
	if len(tok) != 2 || tok[1] != GetDCAAuthToken() {
		err = fmt.Errorf("invalid session token")
		http.Error(w, err.Error(), 403)
	}
	return err
}
func ValidateDCARequest ( w http . ResponseWriter , r * http . Request ) error { var err error auth := r . Header . Get ( " " ) if auth == " " { w . Header ( ) . Set ( " " , `Bearer realm="Datadog Agent"` ) err = fmt . Errorf ( " " ) http . Error ( w , err . Error ( ) , 401 ) return err } tok := strings . Split ( auth , " " ) if tok [ 0 ] != " " { w . Header ( ) . Set ( " " , `Bearer realm="Datadog Agent"` ) err = fmt . Errorf ( " " , tok [ 0 ] ) http . Error ( w , err . Error ( ) , 401 ) return err } if len ( tok ) != 2 || tok [ 1 ] != GetDCAAuthToken ( ) { err = fmt . Errorf ( " " ) http . Error ( w , err . Error ( ) , 403 ) } return err }
ValidateDCARequest is used for the exposed endpoints of the DCA.
ValidateDCARequest is used for the exposed endpoints of the DCA .