git.iko.soy/typeable/oauth2-proxy
on master help sign in
Add Header option structure
commiteec7565c52a6b8b0d4f5d3cde43f9e9483002c48 authorJoel Speed <joel.speed@hotmail.co.uk> dateThu 23 Jul 2020, 10:05 (6 years ago) parentd8b0d90
2 files changed+58
pkg/apis/options/common.go+14 pkg/apis/options/header.go+44
pkg/apis/options/common.gonew file+14
@@ -0,0 +1,14 @@
1+package options
2+
3+// SecretSource references an individual secret value.
4+// Only one source within the struct should be defined at any time.
5+type SecretSource struct {
6+ // Value expects a base64 encoded string value.
7+ Value []byte
8+
9+ // FromEnv expects the name of an environment variable.
10+ FromEnv string
11+
12+ // FromFile expects a path to a file containing the secret value.
13+ FromFile string
14+}
pkg/apis/options/header.gonew file+44
@@ -0,0 +1,44 @@
1+package options
2+
3+// Header represents an individual header that will be added to a request or
4+// response header.
5+type Header struct {
6+ // Name is the header name to be used for this set of values.
7+ // Names should be unique within a list of Headers.
8+ Name string `json:"name"`
9+
10+ // PreserveRequestValue determines whether any values for this header
11+ // should be preserved for the request to the upstream server.
12+ // This option only takes effet on injected request headers.
13+ // Defaults to false (headers that match this header will be stripped).
14+ PreserveRequestValue bool `json:"preserveRequestValue"`
15+
16+ // Values contains the desired values for this header
17+ Values []HeaderValue `json:"values"`
18+}
19+
20+// HeaderValue represents a single header value and the sources that can
21+// make up the header value
22+type HeaderValue struct {
23+ // Allow users to load the value from a secret source
24+ *SecretSource
25+
26+ // Allow users to load the value from a session claim
27+ *ClaimSource
28+}
29+
30+// ClaimSource allows loading a header value from a claim within the session
31+type ClaimSource struct {
32+ // Claim is the name of the claim in the session that the value should be
33+ // loaded from.
34+ Claim string `json:"claim,omitempty"`
35+
36+ // Prefix is an optional prefix that will be prepended to the value of the
37+ // claim if it is non-empty.
38+ Prefix string `json:"prefix,omitempty"`
39+
40+ // BasicAuthPassword converts this claim into a basic auth header.
41+ // Note the value of claim will become the basic auth username and the
42+ // basicAuthPassword will be used as the password value.
43+ BasicAuthPassword *SecretSource
44+}