func GetIgnoredQueryParamsFromOPConfig()

in src/go/configgenerator/filtergen/grpc_transcoder.go [295:355]


func GetIgnoredQueryParamsFromOPConfig(serviceConfig *confpb.Service, opts options.ConfigGeneratorOptions) (map[string]bool, error) {
	ignoredQueryParams := make(map[string]bool)

	// Process ignored query params from jwt locations
	authn := serviceConfig.GetAuthentication()
	for _, provider := range authn.GetProviders() {
		// no custom JwtLocation so use default ones and set the one in query
		// parameter for transcoder to ignore.
		if len(provider.JwtLocations) == 0 {
			ignoredQueryParams[util.DefaultJwtQueryParamAccessToken] = true
			continue
		}

		for _, jwtLocation := range provider.JwtLocations {
			switch jwtLocation.In.(type) {
			case *confpb.JwtLocation_Query:
				if jwtLocation.ValuePrefix != "" {
					return nil, fmt.Errorf("error processing authentication provider (%v): JwtLocation type [Query] should be set without valuePrefix, but it was set to [%v]", provider.Id, jwtLocation.ValuePrefix)
				}
				// set the custom JwtLocation in query parameter for transcoder to ignore.
				ignoredQueryParams[jwtLocation.GetQuery()] = true
			default:
				continue
			}
		}
	}

	// Process ignored query params from flag --transcoding_ignore_query_params
	if opts.TranscodingIgnoreQueryParameters != "" {
		ignoredQueryParametersFlag := strings.Split(opts.TranscodingIgnoreQueryParameters, ",")
		for _, ignoredQueryParameter := range ignoredQueryParametersFlag {
			ignoredQueryParams[ignoredQueryParameter] = true
		}
	}

	// Process ignored query params from API Key system parameters.
	apiKeySystemParametersBySelector := GetAPIKeySystemParametersBySelectorFromOPConfig(serviceConfig, opts)
	for _, api := range serviceConfig.GetApis() {
		for _, method := range api.GetMethods() {
			selector := MethodToSelector(api, method)

			systemParameters, ok := apiKeySystemParametersBySelector[selector]
			if !ok {
				// If any of method is not set with custom ApiKeyLocations, use the default
				// one and set the custom ApiKeyLocations in query parameter for transcoder
				// to ignore.
				ignoredQueryParams[util.DefaultApiKeyQueryParamKey] = true
				ignoredQueryParams[util.DefaultApiKeyQueryParamApiKey] = true
				continue
			}

			for _, systemParameter := range systemParameters {
				if systemParameter.GetUrlQueryParameter() != "" {
					ignoredQueryParams[systemParameter.GetUrlQueryParameter()] = true
				}
			}
		}
	}

	return ignoredQueryParams, nil
}