mirror of
				https://github.com/steveiliop56/tinyauth.git
				synced 2025-10-31 06:05:43 +00:00 
			
		
		
		
	feat: use decoded headers in proxy controller
This commit is contained in:
		| @@ -9,51 +9,55 @@ import ( | ||||
|  | ||||
| func TestDecodeHeaders(t *testing.T) { | ||||
| 	// Variables | ||||
| 	expected := config.App{ | ||||
| 		Config: config.AppConfig{ | ||||
| 			Domain: "example.com", | ||||
| 		}, | ||||
| 		Users: config.AppUsers{ | ||||
| 			Allow: "user1,user2", | ||||
| 			Block: "user3", | ||||
| 		}, | ||||
| 		OAuth: config.AppOAuth{ | ||||
| 			Whitelist: "somebody@example.com", | ||||
| 			Groups:    "group3", | ||||
| 		}, | ||||
| 		IP: config.AppIP{ | ||||
| 			Allow:  []string{"10.71.0.1/24", "10.71.0.2"}, | ||||
| 			Block:  []string{"10.10.10.10", "10.0.0.0/24"}, | ||||
| 			Bypass: []string{"192.168.1.1"}, | ||||
| 		}, | ||||
| 		Response: config.AppResponse{ | ||||
| 			Headers: []string{"X-Foo=Bar", "X-Baz=Qux"}, | ||||
| 			BasicAuth: config.AppBasicAuth{ | ||||
| 				Username:     "admin", | ||||
| 				Password:     "password", | ||||
| 				PasswordFile: "/path/to/passwordfile", | ||||
| 	expected := config.AppConfigs{ | ||||
| 		Apps: map[string]config.App{ | ||||
| 			"foo": { | ||||
| 				Config: config.AppConfig{ | ||||
| 					Domain: "example.com", | ||||
| 				}, | ||||
| 				Users: config.AppUsers{ | ||||
| 					Allow: "user1,user2", | ||||
| 					Block: "user3", | ||||
| 				}, | ||||
| 				OAuth: config.AppOAuth{ | ||||
| 					Whitelist: "somebody@example.com", | ||||
| 					Groups:    "group3", | ||||
| 				}, | ||||
| 				IP: config.AppIP{ | ||||
| 					Allow:  []string{"10.71.0.1/24", "10.71.0.2"}, | ||||
| 					Block:  []string{"10.10.10.10", "10.0.0.0/24"}, | ||||
| 					Bypass: []string{"192.168.1.1"}, | ||||
| 				}, | ||||
| 				Response: config.AppResponse{ | ||||
| 					Headers: []string{"X-Foo=Bar", "X-Baz=Qux"}, | ||||
| 					BasicAuth: config.AppBasicAuth{ | ||||
| 						Username:     "admin", | ||||
| 						Password:     "password", | ||||
| 						PasswordFile: "/path/to/passwordfile", | ||||
| 					}, | ||||
| 				}, | ||||
| 				Path: config.AppPath{ | ||||
| 					Allow: "/public", | ||||
| 					Block: "/private", | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		Path: config.AppPath{ | ||||
| 			Allow: "/public", | ||||
| 			Block: "/private", | ||||
| 		}, | ||||
| 	} | ||||
| 	test := map[string]string{ | ||||
| 		"Tinyauth-Config-Domain":                   "example.com", | ||||
| 		"Tinyauth-Users-Allow":                     "user1,user2", | ||||
| 		"Tinyauth-Users-Block":                     "user3", | ||||
| 		"Tinyauth-OAuth-Whitelist":                 "somebody@example.com", | ||||
| 		"Tinyauth-OAuth-Groups":                    "group3", | ||||
| 		"Tinyauth-IP-Allow":                        "10.71.0.1/24,10.71.0.2", | ||||
| 		"Tinyauth-IP-Block":                        "10.10.10.10,10.0.0.0/24", | ||||
| 		"Tinyauth-IP-Bypass":                       "192.168.1.1", | ||||
| 		"Tinyauth-Response-Headers":                "X-Foo=Bar,X-Baz=Qux", | ||||
| 		"Tinyauth-Response-BasicAuth-Username":     "admin", | ||||
| 		"Tinyauth-Response-BasicAuth-Password":     "password", | ||||
| 		"Tinyauth-Response-BasicAuth-PasswordFile": "/path/to/passwordfile", | ||||
| 		"Tinyauth-Path-Allow":                      "/public", | ||||
| 		"Tinyauth-Path-Block":                      "/private", | ||||
| 		"Tinyauth-Apps-Foo-Config-Domain":                   "example.com", | ||||
| 		"Tinyauth-Apps-Foo-Users-Allow":                     "user1,user2", | ||||
| 		"Tinyauth-Apps-Foo-Users-Block":                     "user3", | ||||
| 		"Tinyauth-Apps-Foo-OAuth-Whitelist":                 "somebody@example.com", | ||||
| 		"Tinyauth-Apps-Foo-OAuth-Groups":                    "group3", | ||||
| 		"Tinyauth-Apps-Foo-IP-Allow":                        "10.71.0.1/24,10.71.0.2", | ||||
| 		"Tinyauth-Apps-Foo-IP-Block":                        "10.10.10.10,10.0.0.0/24", | ||||
| 		"Tinyauth-Apps-Foo-IP-Bypass":                       "192.168.1.1", | ||||
| 		"Tinyauth-Apps-Foo-Response-Headers":                "X-Foo=Bar,X-Baz=Qux", | ||||
| 		"Tinyauth-Apps-Foo-Response-BasicAuth-Username":     "admin", | ||||
| 		"Tinyauth-Apps-Foo-Response-BasicAuth-Password":     "password", | ||||
| 		"Tinyauth-Apps-Foo-Response-BasicAuth-PasswordFile": "/path/to/passwordfile", | ||||
| 		"Tinyauth-Apps-Foo-Path-Allow":                      "/public", | ||||
| 		"Tinyauth-Apps-Foo-Path-Block":                      "/private", | ||||
| 	} | ||||
|  | ||||
| 	// Test | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Stavros
					Stavros