Skip to content

Commit 7982336

Browse files
committed
📚 Sync docs from alaudadevops/connectors-operator on a87919a042d0dbaa33c7e409178f7935f6dd9777
Source: docs: add docs to explain how to use auth exactor to customize built-in reverse proxy (#315) Author: chengjingtao Ref: refs/heads/main Commit: a87919a042d0dbaa33c7e409178f7935f6dd9777 This commit automatically syncs documentation changes from the source-docs repository. 🔗 View source commit: AlaudaDevops/connectors-operator@a87919a 🤖 Synced on 2025-11-18 11:06:56 UTC
1 parent 6f93356 commit 7982336

File tree

5 files changed

+156
-16
lines changed

5 files changed

+156
-16
lines changed

‎.github/SYNC_INFO.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Documentation Sync Information
22

3-
- **Last synced**: 2025-11-12 10:24:25 UTC
3+
- **Last synced**: 2025-11-18 11:06:56 UTC
44
- **Source repository**: alaudadevops/connectors-operator
5-
- **Source commit**: [00fbb705a0a71e01a0506cbec45c5dfaddc78061](https://github.com/alaudadevops/connectors-operator/commit/00fbb705a0a71e01a0506cbec45c5dfaddc78061)
5+
- **Source commit**: [a87919a042d0dbaa33c7e409178f7935f6dd9777](https://github.com/alaudadevops/connectors-operator/commit/a87919a042d0dbaa33c7e409178f7935f6dd9777)
66
- **Triggered by**: chengjingtao
7-
- **Workflow run**: [#50](https://github.com/alaudadevops/connectors-operator/actions/runs/19294174445)
7+
- **Workflow run**: [#51](https://github.com/alaudadevops/connectors-operator/actions/runs/19463897226)
88

99
## Files synced:
1010
- docs/

‎docs/en/connectors/architecture/index.mdx‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ For example, a `Harbor ConnectorClass` can be defined to support integration wit
3131

3232
## Connectors Proxy
3333

34-
`ConnectorsProxy` is a core component that provides secure, secretless access to integrated tools within Kubernetes clusters. It acts as a proxy server, handling authentication injection and request routing to target tool.
34+
`Connectors Proxy` is a core capability of the Connectors system that provides secure, secretless access to integrated tools. It typically operates as an HTTP service that can function as either a forward proxy or a reverse proxy for client applications.
3535

36-
`ConnectorsProxy` enables clients to access tool resources without direct credential handling. This approach delivers significant security benefits:
36+
When clients access tool resources through `Connectors Proxy`, the proxy automatically injects the necessary authentication credentials into requests, enabling seamless access without requiring clients to handle credentials directly. This approach delivers a significant security benefit:
3737

38-
- **Secretless Access**: Eliminates the need to distribute tool credentials directly to clients by using short-lived tokens issued by ServiceAccount. This prevents credential exposure in clients like logs or environment variables.
39-
- **Centralized Credential Management**: All tool credentials are managed centrally by connectors, and no need to distribute credentials to each client.
38+
- **Secretless Access**: Eliminates the need to distribute tool credentials directly to clients by using short-lived tokens issued by Kubernetes. This prevents credential exposure in client environments such as logs or environment variables.
4039

41-
The platform supports both built-in and custom proxy implementations to accommodate diverse tool authentication requirements.
40+
To accommodate diverse tool authentication requirements, the platform supports both built-in and custom proxy implementations. Each `ConnectorClass` can provide its own proxy service, offering flexibility to meet specific tool authentication needs.
4241

4342
### Built-in Connectors Proxy
4443

‎docs/en/connectors/concepts/connectorclass.mdx‎

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ The above YAML demonstrates basic authentication validation:
357357
- `path`: Uses the `repository` value from the Connector's `auth.params`, constructing the path as `/<repository>/info/refs?service=git-upload-pack`
358358
- `Authorization`: When the Connector is configured with a Secret, the `username` and `password` fields are Base64-encoded and included in the Basic authentication header.
359359

360-
### Rego-based Authentication Logic Configuration
360+
### Rego-based Authentication Logic Configuration \{#rego-based-authentication-logic-configuration}
361361

362362
When tool connectors require more complex authentication logic, you can use Rego-based authentication logic configuration.
363363

@@ -713,11 +713,79 @@ spec:
713713
kind: Service
714714
name: proxy
715715
namespace: default
716-
uri: https://proxy.example.com
716+
# uri: https://proxy.example.com
717717
```
718718

719719
The Connector will use the proxy address to proxy the request to the ConnectorClass. [More information](./connectors_proxy.mdx)
720720

721+
### Using Rego to extract token from request \{#using-rego-to-extract-token-from-request}
722+
723+
When using the built-in reverse proxy, you can configure Rego rules using `spec.proxy.authExtractor` to extract tokens from client requests, enabling the built-in reverse proxy to validate client authentication using the extracted token.
724+
725+
For example:
726+
727+
```yaml
728+
spec:
729+
proxy:
730+
authExtractor:
731+
rego: |
732+
package proxy
733+
auth = {
734+
"token": input.headers["Private-Token"][0]
735+
}
736+
```
737+
738+
Rego rules must follow these requirements:
739+
740+
- Rules must be defined in the `proxy` package
741+
- Use the `auth` variable to return the token, where the token is a string type, for example: `auth = { "token": "abcd1234" }`
742+
- If the token cannot be extracted, return an empty string, for example: `auth = { "token": "" }`
743+
744+
The following variables are available in Rego:
745+
746+
| key | type | description | Example |
747+
| ------- | ------------------- | ------------------------------------------------------------------ | --------------------------- |
748+
| headers | map[string][]string | Headers of the request sent to the built-in reverse proxy | input.headers["X-Token"][0] |
749+
| body | object | Body of the request sent to the built-in reverse proxy | input.body.token |
750+
| query | map[string][]string | Query parameters of the request sent to the built-in reverse proxy | input.query["token"][0] |
751+
| method | string | HTTP method of the request sent to the built-in reverse proxy | input.method |
752+
| path | string | Path of the request sent to the built-in reverse proxy | input.path |
753+
754+
**Notes**:
755+
756+
- Header keys in `headers` use Canonical MIME Header Key format (capitalized first letter)
757+
- When implementing Rego rules, ensure robust logic. For example, return an empty string when `input.headers` is null or empty.
758+
759+
**Example**
760+
761+
``` yaml
762+
spec:
763+
proxy:
764+
authExtractor:
765+
rego: |
766+
package proxy
767+
768+
default auth = {
769+
"token": ""
770+
}
771+
772+
auth = {
773+
"token": input.headers["Private-Token"][0]
774+
} if {
775+
input.headers != null
776+
input.headers["Private-Token"] != null
777+
count(input.headers["Private-Token"]) > 0
778+
}
779+
```
780+
781+
This example demonstrates robust token extraction by:
782+
- Defining a default rule that returns an empty token string
783+
- Checking that headers exist and are not null before accessing them
784+
- Verifying that the specific header key exists and has at least one value
785+
786+
For more advanced Rego rules, see the [Rego Policy Language](https://www.openpolicyagent.org/docs/latest/policy-language) documentation.
787+
For more information about using the built-in reverse proxy, see [Connectors Proxy](./connectors_proxy.mdx).
788+
721789
### Resolver Type
722790

723791
The proxy address of the ConnectorClass will be resolved according to the specified `resolver` type.

‎docs/en/connectors/concepts/connectors_proxy.mdx‎

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ sourceSHA: a3690e0a66ff0d323093db716163521315b340274eb2dbec21ada430d120870d
77

88
# ConnectorsProxy
99

10-
`ConnectorsProxy` is a core component that provides secure, secretless access to integrated tools within Kubernetes clusters. It acts as a proxy server, handling authentication injection and request routing to target tool.
10+
`Connectors Proxy` is a core capability of the Connectors system that provides secure, secretless access to integrated tools. It typically operates as an HTTP service that can function as either a forward proxy or a reverse proxy for client applications.
1111

12-
`ConnectorsProxy` enables clients to access tool resources without direct credential handling. This approach delivers significant security benefits:
12+
When clients access tool resources through `Connectors Proxy`, the proxy automatically injects the necessary authentication credentials into requests, enabling seamless access without requiring clients to handle credentials directly. This approach delivers a significant security benefit:
1313

14-
- **Secretless Access**: Eliminates the need to distribute tool credentials directly to clients by using short-lived tokens issued by ServiceAccount. This prevents credential exposure in clients like logs or environment variables.
15-
- **Centralized Credential Management**: All tool credentials are managed centrally by connectors, and no need to distribute credentials to each client.
14+
- **Secretless Access**: Eliminates the need to distribute tool credentials directly to clients by using short-lived tokens issued by Kubernetes. This prevents credential exposure in client environments such as logs or environment variables.
1615

17-
The platform supports both built-in and custom proxy implementations to accommodate diverse tool authentication requirements.
16+
To accommodate diverse tool authentication requirements, the platform supports both built-in and custom proxy implementations. Each `ConnectorClass` can provide its own proxy service, offering flexibility to meet specific tool authentication needs.
1817

1918
## Built-in Connectors Proxy
2019

@@ -34,7 +33,7 @@ Connectors Proxy does not support the `CONNECT` method for `HTTP tunneling`. Cli
3433

3534
:::
3635

37-
### Reverse Proxy
36+
### Reverse Proxy \{#reverse-proxy}
3837

3938
Clients access tools by connecting directly to the Connector Proxy Address instead of the original tool URL. The proxy:
4039

@@ -190,6 +189,33 @@ Example:
190189
curl -H "Authorization: Bearer sa-token-xxxxxxx" "http://c-github.default.svc.cluster.local/"
191190
```
192191

192+
#### Custom Rego-based Authentication \{#custom-rego-based-authentication}
193+
194+
When using the built-in HTTP reverse proxy with tools that use non-standard authentication methods, clients may be unable to provide tokens using standard Basic Auth or Bearer Token methods. Instead, they must use the tool's original credential format.
195+
196+
To support these custom authentication formats, you can use Rego rules to customize token extraction from client requests. This allows the built-in HTTP reverse proxy to extract and validate tokens regardless of how they are provided by the client.
197+
198+
For example:
199+
200+
```yaml
201+
spec:
202+
proxy:
203+
authExtractor:
204+
rego: |
205+
package proxy
206+
auth = {
207+
"token": input.headers["Private-Token"][0]
208+
}
209+
```
210+
211+
This configuration extracts the token from the `Private-Token` header in client requests, which the proxy then uses to validate client authentication.
212+
213+
This approach provides significant flexibility for non-standard HTTP authentication mechanisms. Client CLIs can provide Kubernetes tokens using the tool's original credential format, and the proxy extracts the token through Rego rules to complete authentication validation.
214+
215+
For more detailed configuration on using Rego rules to extract tokens, see [ConnectorClass](./connectorclass.mdx#using-rego-to-extract-token-from-request).
216+
217+
For more about injecting authentication credentials into backend request, see [Injecting Authentication Credentials into Backend Request when using built-in Reverse Proxy](#injecting-authentication-when-using-built-in-reverse-proxy).
218+
193219
##### Connector Identification
194220

195221
The connector can be identified through different proxy address formats:
@@ -215,6 +241,50 @@ curl -u ":sa-token-xxxxxxx" \
215241

216242
The proxy will validate the authentication token and automatically inject the `default/github` connector's authentication credentials when forwarding requests to GitHub services.
217243

244+
### Injecting Authentication Credentials into Backend Request when using built-in Reverse Proxy \{#injecting-authentication-when-using-built-in-reverse-proxy}
245+
246+
After the built-in reverse proxy validates the client request, it injects authentication credentials into the backend request based on the credential type configured in the Connector. The following injection methods are supported:
247+
248+
- **Basic Auth**
249+
- **Bearer Token**
250+
- **Custom Rego**
251+
252+
#### Basic Auth
253+
254+
When a Connector is configured with the secret type `kubernetes.io/basic-auth`, the proxy injects the credentials into the backend request headers using Basic Authentication.
255+
256+
#### Bearer Token
257+
258+
When a Connector is configured with the secret type `connectors.cpaas.io/bearer-token`, the proxy injects the credentials into the backend request headers using Bearer Token authentication.
259+
260+
#### Custom Rego
261+
262+
In addition to the standard Basic Auth and Bearer Token methods, you can use Rego rules to define custom authentication injection logic. For example:
263+
264+
```yaml
265+
spec:
266+
auth:
267+
types:
268+
- name: rego-auth
269+
secretType: Opaque
270+
generator:
271+
rego: |
272+
package proxy
273+
auth = {
274+
"position": "header",
275+
"auth": {
276+
"Private-Token": input.token
277+
}
278+
}
279+
```
280+
This configuration injects the token value from the connector's secret data into the `Private-Token` header of backend requests.
281+
282+
For more detailed configuration, see [ConnectorClass](./connectorclass.mdx#rego-based-authentication-logic-configuration).
283+
284+
When using custom Rego authentication, you typically need to configure `spec.proxy.authExtractor` to extract tokens from client requests, enabling the built-in HTTP reverse proxy to validate client authentication.
285+
Simultaneously, use `spec.auth.types[].generator.rego` to inject authentication credentials into backend requests.
286+
This combination enables support for custom authentication mechanisms when using the built-in HTTP reverse proxy.
287+
218288
## References
219289

220290
- [Kubernetes Authentication documentation](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#service-account-tokens)

‎docs/en/overview/release_notes.mdx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ The following table shows the compatibility and support matrix between the Alaud
3737
- [NPM Connector Quick Start](../connectors-npm/quick_start.mdx)
3838
- Support accessing tool's original API through the Connector API when the ConnectorClass provides Proxy Service capabilities. The system now supports two ways to access tool resources: using the tool's original API via Proxy Service, or using custom APIs provided for the ConnectorClass. For more details, see
3939
* [Connector API](../connectors/concepts/connector_api.mdx)
40+
- Support using Rego rules to extract tokens from client requests when using the built-in HTTP reverse proxy. Combined with the existing ability to inject authentication credentials into backend requests through Rego rules, you can now extend the built-in reverse proxy's capabilities to support tools with non-standard HTTP authentication mechanisms.
41+
- For token extraction configuration, see [Custom Rego-based Authentication](../connectors/concepts/connectors_proxy.mdx#custom-rego-based-authentication).
42+
- For authentication injection configuration, see [Injecting Authentication Credentials into Backend Request when using built-in Reverse Proxy](../connectors/concepts/connectors_proxy.mdx#injecting-authentication-when-using-built-in-reverse-proxy).
4043

4144
### Breaking Changes
4245

0 commit comments

Comments
 (0)