Skip to content

Commit db4564e

Browse files
TUN-6773: Add access based configuration to ingress.OriginRequestConfig
This PR adds some access related configurations to OriginRequestConfig. This will eventually get validated to be part of Ingress.Rule.
1 parent 3d345d3 commit db4564e

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

config/configuration.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,19 @@ type OriginRequestConfig struct {
229229
IPRules []IngressIPRule `yaml:"ipRules" json:"ipRules,omitempty"`
230230
// Attempt to connect to origin with HTTP/2
231231
Http2Origin *bool `yaml:"http2Origin" json:"http2Origin,omitempty"`
232+
// Access holds all access related configs
233+
Access *AccessConfig `yaml:"access" json:"access,omitempty"`
234+
}
235+
236+
type AccessConfig struct {
237+
// Enabled when set to true will fail every request that does not arrive through an access authenticated endpoint.
238+
Enabled bool
239+
240+
// TeamName is the organization team name to get the public key certificates for.
241+
TeamName string `yaml:"teamName" json:"teamName,omitempty"`
242+
243+
// AudTag is the AudTag to verify access JWT against.
244+
AudTag []string `yaml:"audTag" json:"audTag,omitempty"`
232245
}
233246

234247
type IngressIPRule struct {

ingress/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ func originRequestFromConfig(c config.OriginRequestConfig) OriginRequestConfig {
265265
if c.Http2Origin != nil {
266266
out.Http2Origin = *c.Http2Origin
267267
}
268+
if c.Access != nil {
269+
out.Access = *c.Access
270+
}
268271
return out
269272
}
270273

@@ -310,6 +313,9 @@ type OriginRequestConfig struct {
310313
IPRules []ipaccess.Rule `yaml:"ipRules" json:"ipRules"`
311314
// Attempt to connect to origin with HTTP/2
312315
Http2Origin bool `yaml:"http2Origin" json:"http2Origin"`
316+
317+
// Access holds all access related configs
318+
Access config.AccessConfig `yaml:"access" json:"access,omitempty"`
313319
}
314320

315321
func (defaults *OriginRequestConfig) setConnectTimeout(overrides config.OriginRequestConfig) {

ingress/rule_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,25 +182,25 @@ func TestMarshalJSON(t *testing.T) {
182182
{
183183
name: "Nil",
184184
path: nil,
185-
expected: `{"hostname":"example.com","path":null,"service":"https://localhost:8000","originRequest":{"connectTimeout":30,"tlsTimeout":10,"tcpKeepAlive":30,"noHappyEyeballs":false,"keepAliveTimeout":90,"keepAliveConnections":100,"httpHostHeader":"","originServerName":"","caPool":"","noTLSVerify":false,"disableChunkedEncoding":false,"bastionMode":false,"proxyAddress":"127.0.0.1","proxyPort":0,"proxyType":"","ipRules":null,"http2Origin":false}}`,
185+
expected: `{"hostname":"example.com","path":null,"service":"https://localhost:8000","originRequest":{"connectTimeout":30,"tlsTimeout":10,"tcpKeepAlive":30,"noHappyEyeballs":false,"keepAliveTimeout":90,"keepAliveConnections":100,"httpHostHeader":"","originServerName":"","caPool":"","noTLSVerify":false,"disableChunkedEncoding":false,"bastionMode":false,"proxyAddress":"127.0.0.1","proxyPort":0,"proxyType":"","ipRules":null,"http2Origin":false,"access":{"Enabled":false}}}`,
186186
want: true,
187187
},
188188
{
189189
name: "Nil regex",
190190
path: &Regexp{Regexp: nil},
191-
expected: `{"hostname":"example.com","path":null,"service":"https://localhost:8000","originRequest":{"connectTimeout":30,"tlsTimeout":10,"tcpKeepAlive":30,"noHappyEyeballs":false,"keepAliveTimeout":90,"keepAliveConnections":100,"httpHostHeader":"","originServerName":"","caPool":"","noTLSVerify":false,"disableChunkedEncoding":false,"bastionMode":false,"proxyAddress":"127.0.0.1","proxyPort":0,"proxyType":"","ipRules":null,"http2Origin":false}}`,
191+
expected: `{"hostname":"example.com","path":null,"service":"https://localhost:8000","originRequest":{"connectTimeout":30,"tlsTimeout":10,"tcpKeepAlive":30,"noHappyEyeballs":false,"keepAliveTimeout":90,"keepAliveConnections":100,"httpHostHeader":"","originServerName":"","caPool":"","noTLSVerify":false,"disableChunkedEncoding":false,"bastionMode":false,"proxyAddress":"127.0.0.1","proxyPort":0,"proxyType":"","ipRules":null,"http2Origin":false,"access":{"Enabled":false}}}`,
192192
want: true,
193193
},
194194
{
195195
name: "Empty",
196196
path: &Regexp{Regexp: regexp.MustCompile("")},
197-
expected: `{"hostname":"example.com","path":"","service":"https://localhost:8000","originRequest":{"connectTimeout":30,"tlsTimeout":10,"tcpKeepAlive":30,"noHappyEyeballs":false,"keepAliveTimeout":90,"keepAliveConnections":100,"httpHostHeader":"","originServerName":"","caPool":"","noTLSVerify":false,"disableChunkedEncoding":false,"bastionMode":false,"proxyAddress":"127.0.0.1","proxyPort":0,"proxyType":"","ipRules":null,"http2Origin":false}}`,
197+
expected: `{"hostname":"example.com","path":"","service":"https://localhost:8000","originRequest":{"connectTimeout":30,"tlsTimeout":10,"tcpKeepAlive":30,"noHappyEyeballs":false,"keepAliveTimeout":90,"keepAliveConnections":100,"httpHostHeader":"","originServerName":"","caPool":"","noTLSVerify":false,"disableChunkedEncoding":false,"bastionMode":false,"proxyAddress":"127.0.0.1","proxyPort":0,"proxyType":"","ipRules":null,"http2Origin":false,"access":{"Enabled":false}}}`,
198198
want: true,
199199
},
200200
{
201201
name: "Basic",
202202
path: &Regexp{Regexp: regexp.MustCompile("/echo")},
203-
expected: `{"hostname":"example.com","path":"/echo","service":"https://localhost:8000","originRequest":{"connectTimeout":30,"tlsTimeout":10,"tcpKeepAlive":30,"noHappyEyeballs":false,"keepAliveTimeout":90,"keepAliveConnections":100,"httpHostHeader":"","originServerName":"","caPool":"","noTLSVerify":false,"disableChunkedEncoding":false,"bastionMode":false,"proxyAddress":"127.0.0.1","proxyPort":0,"proxyType":"","ipRules":null,"http2Origin":false}}`,
203+
expected: `{"hostname":"example.com","path":"/echo","service":"https://localhost:8000","originRequest":{"connectTimeout":30,"tlsTimeout":10,"tcpKeepAlive":30,"noHappyEyeballs":false,"keepAliveTimeout":90,"keepAliveConnections":100,"httpHostHeader":"","originServerName":"","caPool":"","noTLSVerify":false,"disableChunkedEncoding":false,"bastionMode":false,"proxyAddress":"127.0.0.1","proxyPort":0,"proxyType":"","ipRules":null,"http2Origin":false,"access":{"Enabled":false}}}`,
204204
want: true,
205205
},
206206
}

0 commit comments

Comments
 (0)