bland-finland-95044
03/13/2024, 6:44 PMchilly-king-10285
03/13/2024, 6:44 PMchilly-king-10285
03/13/2024, 6:44 PMremote_json
authorizer, you can configure the payload to capture the first subpath under the URL using the MatchContext.RegexpCaptureGroups
field. This field captures the subpaths in the URL based on the regular expression defined in the match URL of the access rule. Here is an example of how you can configure it: yaml authorizers: remote_json: enabled: true config: remote: <http://my-remote-authorizer/authorize> headers: Y-Api-Key: '{{ .MatchContext.Header.Get "X-Api-Key" }}' payload: | { "subject": "{{ print .Subject }}", "resource": "{{ printIndex .MatchContext.RegexpCaptureGroups 0 }}" }
In this example, "{{ printIndex .MatchContext.RegexpCaptureGroups 0 }}"
will capture the first subpath under the URL. If the URL is <http://www.my-domain.com/my-app>
, then the resource
will be my-app
. Please note that the regular expression in the match URL of the access rule should be defined in such a way that it captures the required subpaths in the URL. For more details, you can refer to the [Ory documentation](https://www.ory.sh/docs/oathkeeper/pipeline/authz#remote_json-example).bland-finland-95044
03/13/2024, 7:25 PMchilly-king-10285
03/13/2024, 7:25 PMchilly-king-10285
03/13/2024, 7:25 PM<
and >
brackets. Here is an example of how you can define it: yaml match: url: <http://mydomain.com/<.*>> methods: - GET
In this example, the regular expression .*
is used to match any subpath under <http://mydomain.com/>
. The .*
means any character (.) repeated zero or more times (*). If you want to capture the first subpath, you can use a regular expression like this: yaml match: url: <http://mydomain.com/<[^/]*>> methods: - GET
In this example, the regular expression [^/]*
is used to match any character except for a slash (/), repeated zero or more times. This will effectively capture the first subpath under <http://mydomain.com/>
. For more details, you can refer to the [Ory documentation](https://www.ory.sh/docs/oathkeeper/api-access-rules#match-strategy-behavior).bland-finland-95044
03/13/2024, 7:29 PMchilly-king-10285
03/13/2024, 7:29 PMchilly-king-10285
03/13/2024, 7:29 PMmy-app
, you can use a regular expression like this: yaml match: url: <http://mydomain.com/<my-app>> methods: - GET
In this example, the regular expression my-app
is used to match the specific subpath my-app
under <http://mydomain.com/>
. This rule will only match the URL <http://mydomain.com/my-app>
, and the MatchContext.RegexpCaptureGroups
field will capture my-app
. For more details, you can refer to the [Ory documentation](https://www.ory.sh/docs/oathkeeper/api-access-rules#match-strategy-behavior).bland-finland-95044
03/15/2024, 2:41 PMchilly-king-10285
03/15/2024, 2:41 PMchilly-king-10285
03/15/2024, 2:41 PM