chore: optimize default config
This commit is contained in:
@@ -145,14 +145,14 @@ func initConfig(configFile string) error {
|
||||
Cors: Cors{
|
||||
Origins: []string{"http://localhost:8080", "https://example.com"},
|
||||
Headers: map[string]string{
|
||||
"Access-Control-Allow-Headers": "Origin, Authorization, Accept, Content-Type, Access-Control-Allow-Headers, X-Client-Id, X-Session-Id",
|
||||
"Access-Control-Allow-Headers": "Origin, Authorization, Accept, Content-Type, Access-Control-Allow-Headers",
|
||||
"Access-Control-Allow-Credentials": "true",
|
||||
"Access-Control-Max-Age": "1728000",
|
||||
},
|
||||
},
|
||||
Routes: []Route{
|
||||
{
|
||||
Name: "Public",
|
||||
Name: "Example",
|
||||
Path: "/",
|
||||
Methods: []string{"GET"},
|
||||
Destination: "https://example.com",
|
||||
@@ -163,12 +163,16 @@ func initConfig(configFile string) error {
|
||||
Timeout: "10s",
|
||||
HealthyStatuses: []int{200, 404},
|
||||
},
|
||||
Middlewares: []string{"api-forbidden-paths"},
|
||||
Middlewares: []string{"block-access"},
|
||||
},
|
||||
{
|
||||
Name: "Basic auth",
|
||||
Path: "/protected",
|
||||
Destination: "https://example.com",
|
||||
Name: "Load balancer",
|
||||
Path: "/protected",
|
||||
Backends: []string{
|
||||
"https://example.com",
|
||||
"https://example2.com",
|
||||
"https://example3.com",
|
||||
},
|
||||
Rewrite: "/",
|
||||
HealthCheck: RouteHealthCheck{},
|
||||
Cors: Cors{
|
||||
@@ -179,38 +183,7 @@ func initConfig(configFile string) error {
|
||||
"Access-Control-Max-Age": "1728000",
|
||||
},
|
||||
},
|
||||
Middlewares: []string{"basic-auth", "api-forbidden-paths"},
|
||||
},
|
||||
{
|
||||
Path: "/",
|
||||
Name: "Hostname and load balancing example",
|
||||
Hosts: []string{"example.com", "example.localhost"},
|
||||
InterceptErrors: []int{404, 405, 500},
|
||||
RateLimit: 60,
|
||||
Backends: []string{
|
||||
"https://example.com",
|
||||
"https://example2.com",
|
||||
"https://example4.com",
|
||||
},
|
||||
Rewrite: "/",
|
||||
HealthCheck: RouteHealthCheck{},
|
||||
},
|
||||
{
|
||||
Path: "/",
|
||||
Name: "loadBalancing example",
|
||||
Hosts: []string{"example.com", "example.localhost"},
|
||||
Backends: []string{
|
||||
"https://example.com",
|
||||
"https://example2.com",
|
||||
"https://example4.com",
|
||||
},
|
||||
Rewrite: "/",
|
||||
HealthCheck: RouteHealthCheck{
|
||||
Path: "/health/live",
|
||||
HealthyStatuses: []int{200, 404},
|
||||
Interval: "30s",
|
||||
Timeout: "10s",
|
||||
},
|
||||
Middlewares: []string{"basic-auth", "block-access"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -225,24 +198,9 @@ func initConfig(configFile string) error {
|
||||
Username: "admin",
|
||||
Password: "admin",
|
||||
},
|
||||
}, {
|
||||
Name: "jwt",
|
||||
Type: JWTAuth,
|
||||
Paths: []string{
|
||||
"/protected-access",
|
||||
"/example-of-jwt",
|
||||
},
|
||||
Rule: JWTRuleMiddleware{
|
||||
URL: "https://example.com/auth/userinfo",
|
||||
RequiredHeaders: []string{
|
||||
"Authorization",
|
||||
},
|
||||
Headers: map[string]string{},
|
||||
Params: map[string]string{},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "api-forbidden-paths",
|
||||
Name: "block-access",
|
||||
Type: AccessMiddleware,
|
||||
Paths: []string{
|
||||
"/swagger-ui/*",
|
||||
@@ -251,46 +209,6 @@ func initConfig(configFile string) error {
|
||||
"/actuator/*",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "oauth-google",
|
||||
Type: OAuth,
|
||||
Paths: []string{
|
||||
"/protected",
|
||||
"/example-of-oauth",
|
||||
},
|
||||
Rule: OauthRulerMiddleware{
|
||||
ClientID: "xxx",
|
||||
ClientSecret: "xxx",
|
||||
Provider: "google",
|
||||
JWTSecret: "your-strong-jwt-secret | It's optional",
|
||||
RedirectURL: "http://localhost:8080/callback",
|
||||
Scopes: []string{"https://www.googleapis.com/auth/userinfo.email",
|
||||
"https://www.googleapis.com/auth/userinfo.profile"},
|
||||
Endpoint: OauthEndpoint{},
|
||||
State: "randomStateString",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "oauth-authentik",
|
||||
Type: OAuth,
|
||||
Paths: []string{
|
||||
"/*",
|
||||
},
|
||||
Rule: OauthRulerMiddleware{
|
||||
ClientID: "xxxx",
|
||||
ClientSecret: "xxxx",
|
||||
RedirectURL: "http://localhost:8080/callback",
|
||||
Provider: "custom",
|
||||
Scopes: []string{"email", "openid"},
|
||||
JWTSecret: "your-strong-jwt-secret | It's optional",
|
||||
Endpoint: OauthEndpoint{
|
||||
AuthURL: "https://authentik.example.com/application/o/authorize/",
|
||||
TokenURL: "https://authentik.example.com/application/o/token/",
|
||||
UserInfoURL: "https://authentik.example.com/application/o/userinfo/",
|
||||
},
|
||||
State: "randomStateString",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
yamlData, err := yaml.Marshal(&conf)
|
||||
|
||||
Reference in New Issue
Block a user