| 
									
										
										
										
											2020-11-11 11:53:59 +00:00
										 |  |  | package options | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // AlphaOptions contains alpha structured configuration options. | 
					
						
							|  |  |  | // Usage of these options allows users to access alpha features that are not | 
					
						
							|  |  |  | // available as part of the primary configuration structure for OAuth2 Proxy. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // :::warning | 
					
						
							|  |  |  | // The options within this structure are considered alpha. | 
					
						
							|  |  |  | // They may change between releases without notice. | 
					
						
							|  |  |  | // ::: | 
					
						
							|  |  |  | type AlphaOptions struct { | 
					
						
							| 
									
										
										
										
											2021-09-17 11:08:18 +00:00
										 |  |  | 	// UpstreamConfig is used to configure upstream servers. | 
					
						
							| 
									
										
										
										
											2020-11-11 11:53:59 +00:00
										 |  |  | 	// Once a user is authenticated, requests to the server will be proxied to | 
					
						
							|  |  |  | 	// these upstream servers based on the path mappings defined in this list. | 
					
						
							| 
									
										
										
										
											2021-09-17 11:08:18 +00:00
										 |  |  | 	UpstreamConfig UpstreamConfig `json:"upstreamConfig,omitempty"` | 
					
						
							| 
									
										
										
										
											2020-11-11 11:53:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// InjectRequestHeaders is used to configure headers that should be added | 
					
						
							|  |  |  | 	// to requests to upstream servers. | 
					
						
							|  |  |  | 	// Headers may source values from either the authenticated user's session | 
					
						
							|  |  |  | 	// or from a static secret value. | 
					
						
							|  |  |  | 	InjectRequestHeaders []Header `json:"injectRequestHeaders,omitempty"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// InjectResponseHeaders is used to configure headers that should be added | 
					
						
							|  |  |  | 	// to responses from the proxy. | 
					
						
							|  |  |  | 	// This is typically used when using the proxy as an external authentication | 
					
						
							|  |  |  | 	// provider in conjunction with another proxy such as NGINX and its | 
					
						
							|  |  |  | 	// auth_request module. | 
					
						
							|  |  |  | 	// Headers may source values from either the authenticated user's session | 
					
						
							|  |  |  | 	// or from a static secret value. | 
					
						
							|  |  |  | 	InjectResponseHeaders []Header `json:"injectResponseHeaders,omitempty"` | 
					
						
							| 
									
										
										
										
											2021-02-14 18:47:15 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Server is used to configure the HTTP(S) server for the proxy application. | 
					
						
							|  |  |  | 	// You may choose to run both HTTP and HTTPS servers simultaneously. | 
					
						
							|  |  |  | 	// This can be done by setting the BindAddress and the SecureBindAddress simultaneously. | 
					
						
							|  |  |  | 	// To use the secure server you must configure a TLS certificate and key. | 
					
						
							|  |  |  | 	Server Server `json:"server,omitempty"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// MetricsServer is used to configure the HTTP(S) server for metrics. | 
					
						
							|  |  |  | 	// You may choose to run both HTTP and HTTPS servers simultaneously. | 
					
						
							|  |  |  | 	// This can be done by setting the BindAddress and the SecureBindAddress simultaneously. | 
					
						
							|  |  |  | 	// To use the secure server you must configure a TLS certificate and key. | 
					
						
							|  |  |  | 	MetricsServer Server `json:"metricsServer,omitempty"` | 
					
						
							| 
									
										
										
										
											2021-04-03 19:06:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Providers is used to configure multiple providers. | 
					
						
							|  |  |  | 	Providers Providers `json:"providers,omitempty"` | 
					
						
							| 
									
										
										
										
											2020-11-11 11:53:59 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-11-09 20:17:43 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | // MergeInto replaces alpha options in the Options struct with the values | 
					
						
							|  |  |  | // from the AlphaOptions | 
					
						
							|  |  |  | func (a *AlphaOptions) MergeInto(opts *Options) { | 
					
						
							| 
									
										
										
										
											2021-09-17 11:08:18 +00:00
										 |  |  | 	opts.UpstreamServers = a.UpstreamConfig | 
					
						
							| 
									
										
										
										
											2020-11-09 20:17:43 +00:00
										 |  |  | 	opts.InjectRequestHeaders = a.InjectRequestHeaders | 
					
						
							|  |  |  | 	opts.InjectResponseHeaders = a.InjectResponseHeaders | 
					
						
							| 
									
										
										
										
											2021-02-14 18:47:15 +00:00
										 |  |  | 	opts.Server = a.Server | 
					
						
							|  |  |  | 	opts.MetricsServer = a.MetricsServer | 
					
						
							| 
									
										
										
										
											2021-04-03 19:06:30 +03:00
										 |  |  | 	opts.Providers = a.Providers | 
					
						
							| 
									
										
										
										
											2020-11-09 20:17:43 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-11-09 20:34:55 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | // ExtractFrom populates the fields in the AlphaOptions with the values from | 
					
						
							|  |  |  | // the Options | 
					
						
							|  |  |  | func (a *AlphaOptions) ExtractFrom(opts *Options) { | 
					
						
							| 
									
										
										
										
											2021-09-17 11:08:18 +00:00
										 |  |  | 	a.UpstreamConfig = opts.UpstreamServers | 
					
						
							| 
									
										
										
										
											2020-11-09 20:34:55 +00:00
										 |  |  | 	a.InjectRequestHeaders = opts.InjectRequestHeaders | 
					
						
							|  |  |  | 	a.InjectResponseHeaders = opts.InjectResponseHeaders | 
					
						
							| 
									
										
										
										
											2021-02-14 18:47:15 +00:00
										 |  |  | 	a.Server = opts.Server | 
					
						
							|  |  |  | 	a.MetricsServer = opts.MetricsServer | 
					
						
							| 
									
										
										
										
											2021-04-03 19:06:30 +03:00
										 |  |  | 	a.Providers = opts.Providers | 
					
						
							| 
									
										
										
										
											2020-11-09 20:34:55 +00:00
										 |  |  | } |