// ToAuthenticationRequestHeaderConfig returns a RequestHeaderConfig config object for these options
// if necessary, nil otherwise.
334698
func (s *RequestHeaderAuthenticationOptions) ToAuthenticationRequestHeaderConfig() *authenticatorfactory.RequestHeaderConfig {
	if len(s.ClientCAFile) == 0 {
		return nil
	}

	return &authenticatorfactory.RequestHeaderConfig{
		UsernameHeaders:     s.UsernameHeaders,
		GroupHeaders:        s.GroupHeaders,
		ExtraHeaderPrefixes: s.ExtraHeaderPrefixes,
		ClientCA:            s.ClientCAFile,
		AllowedClientNames:  s.AllowedNames,
	}
}
709247
func (c *Context) RequestHeader(key string) string {
	return c.Request.Header.Get(key)
}
171305
func (i *Image) AuthorizationHeader() string {
	if i.token == "" {
		return ""
	}
	return fmt.Sprintf("Token %s", i.token)
}
1220170
func (s *User) SetAuthenticationType(v string) *User {
	s.AuthenticationType = &v
	return s
}
148761
func Convert_v1_HTPasswdPasswordIdentityProvider_To_config_HTPasswdPasswordIdentityProvider(in *v1.HTPasswdPasswordIdentityProvider, out *config.HTPasswdPasswordIdentityProvider, s conversion.Scope) error {
	return autoConvert_v1_HTPasswdPasswordIdentityProvider_To_config_HTPasswdPasswordIdentityProvider(in, out, s)
}
1022568
func (auth *Auth) RequestHeader() string {
	auth.MAC = auth.mac(AuthHeader)

	h := `Hawk id="` + auth.Credentials.ID +
		`", mac="` + base64.StdEncoding.EncodeToString(auth.MAC) +
		`", ts="` + strconv.FormatInt(auth.Timestamp.Unix(), 10) +
		`", nonce="` + auth.Nonce + `"`

	if len(auth.Hash) > 0 {
		h += `, hash="` + base64.StdEncoding.EncodeToString(auth.Hash) + `"`
	}
	if auth.Ext != "" {
		h += `, ext="` + auth.Ext + `"`
	}
	if auth.Credentials.App != "" {
		h += `, app="` + auth.Credentials.App + `"`
	}
	if auth.Credentials.Delegate != "" {
		h += `, dlg="` + auth.Credentials.Delegate + `"`
	}

	return h
}
16891
func RequestHeaderFieldsTooLarge(w http.ResponseWriter, response interface{}) {
	Respond(w, http.StatusRequestHeaderFieldsTooLarge, response)
}
1219719
func validateRequestHeaders(requestHeaders string, config Config) bool {
	if !config.ValidateHeaders {
		return true
	}

	headers := strings.Split(requestHeaders, ",")

	for _, header := range headers {
		match := false
		header = strings.ToLower(strings.Trim(header, " \t\r\n"))

		for _, value := range config.requestHeaders {
			if value == header {
				match = true
				break
			}
		}

		if !match {
			return false
		}
	}

	return true
}
1174438
func (a TokenAuth) ApplyAuthentication(r *http.Request) {
	token := fmt.Sprintf("Token %s", a.Token)
	r.Header.Add("Authorization", token)

	r.URL.Host = a.Host
	r.Host = a.Host
}
8143
func (pta *PassThroughAuth) AddAuthHeaders(req *http.Request) {
	req.Header.Set("Authorization", pta.AuthHeader)
}
1158289
func Convert_config_RequestHeaderAuthenticationOptions_To_v1_RequestHeaderAuthenticationOptions(in *config.RequestHeaderAuthenticationOptions, out *v1.RequestHeaderAuthenticationOptions, s conversion.Scope) error {
	return autoConvert_config_RequestHeaderAuthenticationOptions_To_v1_RequestHeaderAuthenticationOptions(in, out, s)
}
145433
func Convert_v1_WebhookTokenAuthenticator_To_config_WebhookTokenAuthenticator(in *v1.WebhookTokenAuthenticator, out *config.WebhookTokenAuthenticator, s conversion.Scope) error {
	return autoConvert_v1_WebhookTokenAuthenticator_To_config_WebhookTokenAuthenticator(in, out, s)
}
531757
func Convert_v1_RequestHeaderIdentityProvider_To_config_RequestHeaderIdentityProvider(in *v1.RequestHeaderIdentityProvider, out *config.RequestHeaderIdentityProvider, s conversion.Scope) error {
	return autoConvert_v1_RequestHeaderIdentityProvider_To_config_RequestHeaderIdentityProvider(in, out, s)
}
240225
func (s *Service) ReplaceAuthConfig(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()

	var authConfig chronograf.AuthConfig
	if err := json.NewDecoder(r.Body).Decode(&authConfig); err != nil {
		invalidJSON(w, s.Logger)
		return
	}

	config, err := s.Store.Config(ctx).Get(ctx)
	if err != nil {
		Error(w, http.StatusBadRequest, err.Error(), s.Logger)
		return
	}
	if config == nil {
		Error(w, http.StatusBadRequest, "Configuration object was nil", s.Logger)
		return
	}
	config.Auth = authConfig

	res := newAuthConfigResponse(*config)
	if err := s.Store.Config(ctx).Update(ctx, config); err != nil {
		unknownErrorWithMessage(w, err, s.Logger)
		return
	}

	encodeJSON(w, http.StatusOK, res, s.Logger)
}
807360
func (s *GetFolderInput) SetAuthenticationToken(v string) *GetFolderInput {
	s.AuthenticationToken = &v
	return s
}
1364916
func AuthorizationHeader(creds *common.Credentials) (key, value string) {
	return "Authorization", "Bearer " + creds.Get(OAuth2KeyAccessToken).Str("Invalid")
}
1320931
func (m *middleware) validateHeader(r *http.Request, auth string) (context.Context, *Error) {
	var f = strings.Fields(auth)
	if len(f) != 2 {
		return nil, ErrBadAuthorizationHeader
	}

	var scheme = strings.ToLower(f[0])
	var token = f[1]

	switch scheme {
	case schemeBasic:
		return m.validateBasicAuth(r)
	case schemeBearer:
		return m.validateJWT(r, token)
	default:
		return nil, ErrUnsupportedAuthScheme
	}
}