git.iko.soy/typeable/oauth2-proxy
on master help sign in
Add AlphaOptions struct and ensure that all children have valid JSON tags
commitd353d946315607abf8de158de18e5599b0f6953b authorJoel Speed <joel.speed@hotmail.co.uk> dateWed 11 Nov 2020, 11:53 (6 years ago) parentb6d6f31
4 files changed+47−16
pkg/apis/options/alpha_options.go+31 pkg/apis/options/common.go+3−3 pkg/apis/options/header.go+6−6 pkg/apis/options/upstreams.go+7−7
pkg/apis/options/alpha_options.gonew file+31
@@ -0,0 +1,31 @@
1+package options
2+
3+// AlphaOptions contains alpha structured configuration options.
4+// Usage of these options allows users to access alpha features that are not
5+// available as part of the primary configuration structure for OAuth2 Proxy.
6+//
7+// :::warning
8+// The options within this structure are considered alpha.
9+// They may change between releases without notice.
10+// :::
11+type AlphaOptions struct {
12+ // Upstreams is used to configure upstream servers.
13+ // Once a user is authenticated, requests to the server will be proxied to
14+ // these upstream servers based on the path mappings defined in this list.
15+ Upstreams Upstreams `json:"upstreams,omitempty"`
16+
17+ // InjectRequestHeaders is used to configure headers that should be added
18+ // to requests to upstream servers.
19+ // Headers may source values from either the authenticated user's session
20+ // or from a static secret value.
21+ InjectRequestHeaders []Header `json:"injectRequestHeaders,omitempty"`
22+
23+ // InjectResponseHeaders is used to configure headers that should be added
24+ // to responses from the proxy.
25+ // This is typically used when using the proxy as an external authentication
26+ // provider in conjunction with another proxy such as NGINX and its
27+ // auth_request module.
28+ // Headers may source values from either the authenticated user's session
29+ // or from a static secret value.
30+ InjectResponseHeaders []Header `json:"injectResponseHeaders,omitempty"`
31+}
pkg/apis/options/common.go+3−3
@@ -10,13 +10,13 @@ import (
1010// Only one source within the struct should be defined at any time.
1111type SecretSource struct {
1212 // Value expects a base64 encoded string value.
13− Value []byte
13+ Value []byte `json:"value,omitempty"`
1414
1515 // FromEnv expects the name of an environment variable.
16− FromEnv string
16+ FromEnv string `json:"fromEnv,omitempty"`
1717
1818 // FromFile expects a path to a file containing the secret value.
19− FromFile string
19+ FromFile string `json:"fromFile,omitempty"`
2020}
2121
2222// Duration is an alias for time.Duration so that we can ensure the marshalling
pkg/apis/options/header.go+6−6
@@ -5,26 +5,26 @@ package options
55type Header struct {
66 // Name is the header name to be used for this set of values.
77 // Names should be unique within a list of Headers.
8− Name string `json:"name"`
8+ Name string `json:"name,omitempty"`
99
1010 // PreserveRequestValue determines whether any values for this header
1111 // should be preserved for the request to the upstream server.
1212 // This option only takes effet on injected request headers.
1313 // Defaults to false (headers that match this header will be stripped).
14− PreserveRequestValue bool `json:"preserveRequestValue"`
14+ PreserveRequestValue bool `json:"preserveRequestValue,omitempty"`
1515
1616 // Values contains the desired values for this header
17− Values []HeaderValue `json:"values"`
17+ Values []HeaderValue `json:"values,omitempty"`
1818}
1919
2020// HeaderValue represents a single header value and the sources that can
2121// make up the header value
2222type HeaderValue struct {
2323 // Allow users to load the value from a secret source
24− *SecretSource
24+ *SecretSource `json:",omitempty"`
2525
2626 // Allow users to load the value from a session claim
27− *ClaimSource
27+ *ClaimSource `json:",omitempty"`
2828}
2929
3030// ClaimSource allows loading a header value from a claim within the session
@@ -40,5 +40,5 @@ type ClaimSource struct {
4040 // BasicAuthPassword converts this claim into a basic auth header.
4141 // Note the value of claim will become the basic auth username and the
4242 // basicAuthPassword will be used as the password value.
43− BasicAuthPassword *SecretSource
43+ BasicAuthPassword *SecretSource `json:"basicAuthPassword,omitempty"`
4444}
pkg/apis/options/upstreams.go+7−7
@@ -8,11 +8,11 @@ type Upstreams []Upstream
88type Upstream struct {
99 // ID should be a unique identifier for the upstream.
1010 // This value is required for all upstreams.
11− ID string `json:"id"`
11+ ID string `json:"id,omitempty"`
1212
1313 // Path is used to map requests to the upstream server.
1414 // The closest match will take precedence and all Paths must be unique.
15− Path string `json:"path"`
15+ Path string `json:"path,omitempty"`
1616
1717 // The URI of the upstream server. This may be an HTTP(S) server of a File
1818 // based URL. It may include a path, in which case all requests will be served
@@ -24,19 +24,19 @@ type Upstream struct {
2424 // - file://host/path
2525 // If the URI's path is "/base" and the incoming request was for "/dir",
2626 // the upstream request will be for "/base/dir".
27− URI string `json:"uri"`
27+ URI string `json:"uri,omitempty"`
2828
2929 // InsecureSkipTLSVerify will skip TLS verification of upstream HTTPS hosts.
3030 // This option is insecure and will allow potential Man-In-The-Middle attacks
3131 // betweem OAuth2 Proxy and the usptream server.
3232 // Defaults to false.
33− InsecureSkipTLSVerify bool `json:"insecureSkipTLSVerify"`
33+ InsecureSkipTLSVerify bool `json:"insecureSkipTLSVerify,omitempty"`
3434
3535 // Static will make all requests to this upstream have a static response.
3636 // The response will have a body of "Authenticated" and a response code
3737 // matching StaticCode.
3838 // If StaticCode is not set, the response will return a 200 response.
39− Static bool `json:"static"`
39+ Static bool `json:"static,omitempty"`
4040
4141 // StaticCode determines the response code for the Static response.
4242 // This option can only be used with Static enabled.
@@ -50,9 +50,9 @@ type Upstream struct {
5050 // PassHostHeader determines whether the request host header should be proxied
5151 // to the upstream server.
5252 // Defaults to true.
53− PassHostHeader *bool `json:"passHostHeader"`
53+ PassHostHeader *bool `json:"passHostHeader,omitempty"`
5454
5555 // ProxyWebSockets enables proxying of websockets to upstream servers
5656 // Defaults to true.
57− ProxyWebSockets *bool `json:"proxyWebSockets"`
57+ ProxyWebSockets *bool `json:"proxyWebSockets,omitempty"`
5858}