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
// The client will automatically use the custom header names
152
+
embeddedClient:= proxySrv.GetEmbeddedClient(
153
+
proxy.WithUser("alice"),
154
+
proxy.WithGroups("developers", "admin"),
155
+
proxy.WithExtra("department", "engineering"),
156
+
)
157
+
// Headers will be: Custom-User: alice, Custom-Groups: developers, etc.
166
158
```
167
159
168
-
Then use custom headers in requests:
160
+
This is similar to Kubernetes' request header authentication, but uses a separate dedicated `EmbeddedAuthentication` type for embedded mode and doesn't require client certificate configuration (the requests are trusted because the server is embedded).
161
+
162
+
### Functional Options for GetEmbeddedClient
163
+
164
+
The `GetEmbeddedClient()` method supports functional options that automatically add authentication headers based on your configured header names. This eliminates the need to manually add headers to each request:
The functional options automatically use the header names you've configured in `opts.Authentication.Embedded`. For example, if you've configured custom header names:
This is similar to Kubernetes' request header authentication, but uses a separate dedicated `EmbeddedAuthentication` type for embedded mode and doesn't require client certificate configuration (the requests are trusted because the server is embedded).
210
+
Available functional options:
211
+
-`WithUser(username string)`: Sets the username
212
+
-`WithGroups(groups ...string)`: Sets group memberships
213
+
-`WithExtra(key, value string)`: Sets extra user attributes (can be called multiple times)
214
+
215
+
This approach provides a clean, type-safe way to configure authentication without manually managing headers.
0 commit comments