Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADR] Support setting up custom headers in APIRule requests and responses #894

Closed
Ressetkk opened this issue Feb 22, 2024 · 2 comments
Closed
Labels

Comments

@Ressetkk
Copy link
Contributor

Support setting up custom headers in APIRule

Status

Proposed

Context

Users request feature for APIRule to support setting up custom headers in the CR based on the VirtualService Headers section. Users use application configuration where upstream connectivity requires some values to be passed as headers in a request. See discussion in #808 (comment)

Decision

  1. APIRule definition is extended with headers section.
  2. Headers section lets user manipulate headers on request and response level.
  3. Headers section lets user set additional labels that will be present in request or response.
  4. If user-provided key in APIRule is already present in the request/response, value is overridden with user-provided data.

APIRule extension

kind: APIRule
metadata:
    name: rule
    namespace: default
spec:
    gateway: kyma-system/kyma-gateway
    headers:
        request:
            set:
                X-CLIENT-SSL-CN: "%DOWNSTREAM_PEER_SUBJECT%"
                X-CLIENT-SSL-SAN: "%DOWNSTREAM_PEER_URI_SAN%"
                X-CLIENT-SSL-ISSUER: "%DOWNSTREAM_PEER_ISSUER%"
(...)

The APIRuleSpec struct is extended with a variable of type HeadersConfig:

type APIRuleSpec {
    // Headers contains information about header manipulation in APIRule
    Headers HeadersConfig
}

type HeadersConfig struct {
    // Request defines header manipulation options for all requests passing through an APIRule
    Request HeaderOptions
    // Response defines header manipulation options for all responses passing through an APIRule
    Response HeaderOptions
}

type HeaderOptions {
    // Set contains key/value pair map containing headers that are set in APIRule
    Set map[string]string
}

Consequences

  • User is allowed to set up custom headers in requests and responses that go through APIRule and its managed resources.
@gefersonhess
Copy link

gefersonhess commented Jul 10, 2024

This proposal accepts headers at Spec level, hence I'm assuming it should be set to all routes in the VirtualService created by the APIRule.

However, istio supports headers at route level

Should something like this be supported too:

kind: APIRule
metadata:
  name: rule
spec:
  headers:
    request:
      set:
         MY-HEADER: "header-applied-to-all-request-routes"
  gateway: kyma-gateway
  host: httpbinbeta.local.kyma.dev
  rules:
  - path: /status
    accessStrategies:
      - handler: no_auth
    methods:
    - GET
    service:
      name: service
      port: 8000
    headers:
      request:
        set:
          STATUS-HEADER : "header-applied-only-to-status-route"
 ...

Where in a request to /status both headers should be set (MY-HEADER and STATUS-HEADER).

An request to another route (not showed here), only MY-HEADER will be set?

@strekm
Copy link
Contributor

strekm commented Sep 5, 2024

closing it since it is already supported by mutators in APIRule v1* and request modifiers in APIRule v2*

@strekm strekm closed this as completed Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants