ancient-judge-84558
04/08/2024, 8:23 PMchilly-king-10285
04/08/2024, 8:42 PMchilly-king-10285
04/08/2024, 8:42 PMheader
mutator. The header
mutator allows you to pass the credentials to the upstream application via the headers. Here is an example of how you can configure the header
mutator to add a session id as a request header: yaml # Global configuration file oathkeeper.yml mutators: header: # Set enabled to true if the authenticator should be enabled and false to disable the authenticator. Defaults to false. enabled: true config: headers: X-Session-ID: "{{ print .Extra.session_id }}"
In this example, X-Session-ID
is the name of the header, and {{ print .Extra.session_id }}
is the value of the header. The value is a string which will be parsed by the Go text/template
package for value substitution, receiving the AuthenticationSession
struct. Please note that the session id must be available in the extra
field of the AuthenticationSession
struct. If it's not, you might need to use the hydrator
mutator to fetch additional data from external APIs before the header
mutator. For more details, please check the [Ory Oathkeeper documentation](https://www.ory.sh/docs/oathkeeper/pipeline/mutator#header).ancient-judge-84558
04/08/2024, 8:55 PMchilly-king-10285
04/08/2024, 8:55 PMchilly-king-10285
04/08/2024, 8:56 PMAuthenticationSession
struct does not directly contain a field for the session id. Here is the structure as per the provided knowledge source: go type AuthenticationSession struct { Subject string Extra map[string]interface{} Header http.Header MatchContext MatchContext } type MatchContext struct { RegexpCaptureGroups []string URL *url.URL Method string Header http.Header }
As you can see, the AuthenticationSession
struct contains Subject
, Extra
, Header
, and MatchContext
fields. The Extra
field is a map that can contain additional data. If the session id is available, it would likely be stored in this Extra
field. However, the session id is not automatically included in the AuthenticationSession
struct. You might need to use a custom authenticator or the hydrator
mutator to fetch the session id and add it to the Extra
field. For more details, please check the [Ory Oathkeeper documentation](https://www.ory.sh/docs/oathkeeper/pipeline#session).ancient-judge-84558
04/08/2024, 9:13 PMchilly-king-10285
04/08/2024, 9:13 PMchilly-king-10285
04/08/2024, 9:13 PM.Extra.id
field of the AuthenticationSession
struct, you can configure the header
mutator to add this session id as a request header. Here's how you can do it: yaml # Global configuration file oathkeeper.yml mutators: header: # Set enabled to true if the authenticator should be enabled and false to disable the authenticator. Defaults to false. enabled: true config: headers: X-Session-ID: "{{ print .Extra.id }}"
In this configuration, X-Session-ID
is the name of the header, and {{ print .Extra.id }}
is the value of the header. The value is a string which will be parsed by the Go text/template
package for value substitution, receiving the AuthenticationSession
struct. For more details, please check the [Ory Oathkeeper documentation](https://www.ory.sh/docs/oathkeeper/pipeline/mutator#header).