You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auth-Bridge is configured using a YAML file. Here's a basic configuration example:
39
+
Auth-Bridge is configured by ProxyPolicy CRD. Here's a basic configuration example:
21
40
22
41
```yaml
23
-
# Configuration example to be added
42
+
apiVersion: auth-bridge.dev/v1alpha1
43
+
kind: ProxyPolicy
44
+
metadata:
45
+
name: basic-auth
46
+
namespace: default
47
+
spec:
48
+
auth:
49
+
method: basicAuth
50
+
secret:
51
+
reference:
52
+
name: basic-auth
53
+
namespace: <secret namespace>
54
+
rules:
55
+
- name: basic-rule
56
+
validate: |
57
+
package proxy
58
+
59
+
default allow = true
60
+
---
61
+
apiVersion: v1
62
+
kind: Secret
63
+
metadata:
64
+
name: basic-auth
65
+
namespace: default
66
+
type: Opaque
67
+
stringData:
68
+
username: username
69
+
password: password
24
70
```
25
71
72
+
## Configuration
73
+
74
+
Auth-Bridge is configured by ProxyPolicy and Secret. Ensure that your ProxyPolicy and associated Secret are correctly configured based on your chosen authentication method and validation rules.
75
+
76
+
Here's a basic configuration example:
77
+
78
+
```yaml
79
+
apiVersion: auth-bridge.dev/v1alpha1
80
+
kind: ProxyPolicy
81
+
metadata:
82
+
name: basic-auth
83
+
namespace: default
84
+
spec:
85
+
auth:
86
+
method: basicAuth
87
+
secret:
88
+
reference:
89
+
name: basic-auth
90
+
namespace: <secret namespace>
91
+
rules:
92
+
- name: basic-rule
93
+
validate: |
94
+
package proxy
95
+
96
+
default allow = true
97
+
---
98
+
apiVersion: v1
99
+
kind: Secret
100
+
metadata:
101
+
name: basic-auth
102
+
namespace: default
103
+
type: Opaque
104
+
stringData:
105
+
username: username
106
+
password: password
107
+
```
108
+
109
+
### Field Definition
110
+
111
+
* `auth.method`
112
+
This field specifies the authentication method to be used. It can be set to either:
113
+
- `basicAuth`: For basic authentication using a username and password.
114
+
- `bearerToken`: For authentication using a bearer token.
115
+
116
+
* `auth.secret.reference`
117
+
This field refers to the Kubernetes Secret containing the authentication credentials.
118
+
- For `basicAuth`, the referenced Secret data must contain `username` and `password`
119
+
- For `bearerToken`, the referenced Secret data must contain `token`
120
+
121
+
* `rules.validate`:
122
+
This field contains the Open Policy Agent (OPA) validation rule. The OPA script must include a boolean variable
123
+
named `allow`, which determines whether the secret should be injected during proxying based on this rule. For example:
124
+
125
+
```
126
+
package proxy
127
+
128
+
default allow = false
129
+
130
+
allow {
131
+
input.uri == "example.com"
132
+
}
133
+
```
134
+
135
+
### Advanced
136
+
The OPA script also has access to an input object that contains information about the target request and the pod.
137
+
You can use input.<field> in your OPA script to make decisions. The available fields include:
138
+
139
+
- input.uri: The URI of the target request
140
+
- input.query: The query parameters of the target request
141
+
- input.body: The body of the target request
142
+
- input.meta: Metadata of the pod making the request
143
+
144
+
In this example, the secret will only be injected if the request host is "example.com".
145
+
146
+
```
147
+
package proxy
148
+
149
+
default allow = false
150
+
151
+
allow {
152
+
contains(input.uri, "example.com")
153
+
input.meta.namespace == "allowed-namespace"
154
+
input.query.action == "read"
155
+
}
156
+
```
157
+
26
158
## Usage
159
+
Using Auth-Bridge involves several key steps:
27
160
28
-
1. Deploy Auth-Bridge in your Kubernetes cluster
29
-
2. Configure your proxy policies and credentials
30
-
3. Set the appropriate environment variables or annotations in the Pods that require proxy access
161
+
### Configure ProxyPolicy
162
+
Create a ProxyPolicy resource to define your proxy rules:
163
+
```yaml
164
+
apiVersion: auth-bridge.dev/v1alpha1
165
+
kind: ProxyPolicy
166
+
metadata:
167
+
name: proxy-policy
168
+
spec:
169
+
auth:
170
+
method: basicAuth
171
+
secret:
172
+
reference:
173
+
name: <secret name>
174
+
namespace: <secret namespace>
175
+
rules:
176
+
- name: <rule name>
177
+
validate: <rule opa>
178
+
```
179
+
180
+
### Create Secret
181
+
182
+
Create a Secret with correct credentials based on your policy auth method:
183
+
184
+
```yaml
185
+
apiVersion: v1
186
+
kind: Secret
187
+
metadata:
188
+
name: credentials
189
+
namespace: default
190
+
type: Opaque
191
+
stringData:
192
+
username: <username>
193
+
password: <password>
194
+
```
195
+
196
+
### Set proxy
197
+
To enable the Auth-Bridge proxy, set the following environment variables for your application:
0 commit comments