Skip to content

Commit d6e1eaa

Browse files
scaleway-botyfodilremyleone
authored
feat(lb): add redirect acl (#2732)
Co-authored-by: Yacine Fodil <[email protected]> Co-authored-by: Rémy Léone <[email protected]>
1 parent 3cf45a9 commit d6e1eaa

File tree

5 files changed

+93
-9
lines changed

5 files changed

+93
-9
lines changed

cmd/scw/testdata/test-all-usage-lbacl-create-usage.golden

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ USAGE:
88
ARGS:
99
frontend-id ID of your frontend
1010
name=<generated> Name of your ACL ressource
11-
[action.type] The action type (allow | deny)
11+
[action.type] The action type (allow | deny | redirect)
12+
[action.redirect.type] Redirect type (location | scheme)
13+
[action.redirect.target] Redirect target (target URL for `location`, or target `scheme`)
14+
[action.redirect.code] HTTP redirect code to use. Valid values are 301, 302, 303, 307 and 308. Default value is 302
1215
[match.ip-subnet.{index}] A list of IPs or CIDR v4/v6 addresses of the client of the session to match
1316
[match.http-filter] The HTTP filter to match (acl_http_filter_none | path_begin | path_end | regex | http_header_match)
1417
[match.http-filter-value.{index}] A list of possible values to match for the given HTTP filter

cmd/scw/testdata/test-all-usage-lbacl-set-usage.golden

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ USAGE:
77

88
ARGS:
99
acls.{index}.name Name of your ACL resource
10-
[acls.{index}.action.type] The action type (allow | deny)
10+
[acls.{index}.action.type] The action type (allow | deny | redirect)
11+
[acls.{index}.action.redirect.type] Redirect type (location | scheme)
12+
[acls.{index}.action.redirect.target] Redirect target (target URL for `location`, or target `scheme`)
13+
[acls.{index}.action.redirect.code] HTTP redirect code to use. Valid values are 301, 302, 303, 307 and 308. Default value is 302
1114
[acls.{index}.match.ip-subnet.{index}] A list of IPs or CIDR v4/v6 addresses of the client of the session to match
1215
[acls.{index}.match.http-filter] The HTTP filter to match (acl_http_filter_none | path_begin | path_end | regex | http_header_match)
1316
[acls.{index}.match.http-filter-value.{index}] A list of possible values to match for the given HTTP filter

cmd/scw/testdata/test-all-usage-lbacl-update-usage.golden

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ USAGE:
88
ARGS:
99
acl-id ID of your ACL ressource
1010
name Name of your ACL ressource
11-
[action.type] The action type (allow | deny)
11+
[action.type] The action type (allow | deny | redirect)
12+
[action.redirect.type] Redirect type (location | scheme)
13+
[action.redirect.target] Redirect target (target URL for `location`, or target `scheme`)
14+
[action.redirect.code] HTTP redirect code to use. Valid values are 301, 302, 303, 307 and 308. Default value is 302
1215
[match.ip-subnet.{index}] A list of IPs or CIDR v4/v6 addresses of the client of the session to match
1316
[match.http-filter] The HTTP filter to match (acl_http_filter_none | path_begin | path_end | regex | http_header_match)
1417
[match.http-filter-value.{index}] A list of possible values to match for the given HTTP filter

docs/commands/lb.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ scw lb acl create [arg=value ...]
8282
|------|---|-------------|
8383
| frontend-id | Required | ID of your frontend |
8484
| name | Required<br />Default: `<generated>` | Name of your ACL ressource |
85-
| action.type | One of: `allow`, `deny` | The action type |
85+
| action.type | One of: `allow`, `deny`, `redirect` | The action type |
86+
| action.redirect.type | One of: `location`, `scheme` | Redirect type |
87+
| action.redirect.target | | Redirect target (target URL for `location`, or target `scheme`) |
88+
| action.redirect.code | | HTTP redirect code to use. Valid values are 301, 302, 303, 307 and 308. Default value is 302 |
8689
| match.ip-subnet.{index} | | A list of IPs or CIDR v4/v6 addresses of the client of the session to match |
8790
| match.http-filter | One of: `acl_http_filter_none`, `path_begin`, `path_end`, `regex`, `http_header_match` | The HTTP filter to match |
8891
| match.http-filter-value.{index} | | A list of possible values to match for the given HTTP filter |
@@ -172,7 +175,10 @@ scw lb acl set [arg=value ...]
172175
| Name | | Description |
173176
|------|---|-------------|
174177
| acls.{index}.name | Required | Name of your ACL resource |
175-
| acls.{index}.action.type | One of: `allow`, `deny` | The action type |
178+
| acls.{index}.action.type | One of: `allow`, `deny`, `redirect` | The action type |
179+
| acls.{index}.action.redirect.type | One of: `location`, `scheme` | Redirect type |
180+
| acls.{index}.action.redirect.target | | Redirect target (target URL for `location`, or target `scheme`) |
181+
| acls.{index}.action.redirect.code | | HTTP redirect code to use. Valid values are 301, 302, 303, 307 and 308. Default value is 302 |
176182
| acls.{index}.match.ip-subnet.{index} | | A list of IPs or CIDR v4/v6 addresses of the client of the session to match |
177183
| acls.{index}.match.http-filter | One of: `acl_http_filter_none`, `path_begin`, `path_end`, `regex`, `http_header_match` | The HTTP filter to match |
178184
| acls.{index}.match.http-filter-value.{index} | | A list of possible values to match for the given HTTP filter |
@@ -202,7 +208,10 @@ scw lb acl update <acl-id ...> [arg=value ...]
202208
|------|---|-------------|
203209
| acl-id | Required | ID of your ACL ressource |
204210
| name | Required | Name of your ACL ressource |
205-
| action.type | One of: `allow`, `deny` | The action type |
211+
| action.type | One of: `allow`, `deny`, `redirect` | The action type |
212+
| action.redirect.type | One of: `location`, `scheme` | Redirect type |
213+
| action.redirect.target | | Redirect target (target URL for `location`, or target `scheme`) |
214+
| action.redirect.code | | HTTP redirect code to use. Valid values are 301, 302, 303, 307 and 308. Default value is 302 |
206215
| match.ip-subnet.{index} | | A list of IPs or CIDR v4/v6 addresses of the client of the session to match |
207216
| match.http-filter | One of: `acl_http_filter_none`, `path_begin`, `path_end`, `regex`, `http_header_match` | The HTTP filter to match |
208217
| match.http-filter-value.{index} | | A list of possible values to match for the given HTTP filter |

internal/namespaces/lb/v1/lb_cli.go

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,29 @@ func lbACLCreate() *core.Command {
20302030
Required: false,
20312031
Deprecated: false,
20322032
Positional: false,
2033-
EnumValues: []string{"allow", "deny"},
2033+
EnumValues: []string{"allow", "deny", "redirect"},
2034+
},
2035+
{
2036+
Name: "action.redirect.type",
2037+
Short: `Redirect type`,
2038+
Required: false,
2039+
Deprecated: false,
2040+
Positional: false,
2041+
EnumValues: []string{"location", "scheme"},
2042+
},
2043+
{
2044+
Name: "action.redirect.target",
2045+
Short: `Redirect target (target URL for ` + "`" + `location` + "`" + `, or target ` + "`" + `scheme` + "`" + `)`,
2046+
Required: false,
2047+
Deprecated: false,
2048+
Positional: false,
2049+
},
2050+
{
2051+
Name: "action.redirect.code",
2052+
Short: `HTTP redirect code to use. Valid values are 301, 302, 303, 307 and 308. Default value is 302`,
2053+
Required: false,
2054+
Deprecated: false,
2055+
Positional: false,
20342056
},
20352057
{
20362058
Name: "match.ip-subnet.{index}",
@@ -2155,7 +2177,29 @@ func lbACLUpdate() *core.Command {
21552177
Required: false,
21562178
Deprecated: false,
21572179
Positional: false,
2158-
EnumValues: []string{"allow", "deny"},
2180+
EnumValues: []string{"allow", "deny", "redirect"},
2181+
},
2182+
{
2183+
Name: "action.redirect.type",
2184+
Short: `Redirect type`,
2185+
Required: false,
2186+
Deprecated: false,
2187+
Positional: false,
2188+
EnumValues: []string{"location", "scheme"},
2189+
},
2190+
{
2191+
Name: "action.redirect.target",
2192+
Short: `Redirect target (target URL for ` + "`" + `location` + "`" + `, or target ` + "`" + `scheme` + "`" + `)`,
2193+
Required: false,
2194+
Deprecated: false,
2195+
Positional: false,
2196+
},
2197+
{
2198+
Name: "action.redirect.code",
2199+
Short: `HTTP redirect code to use. Valid values are 301, 302, 303, 307 and 308. Default value is 302`,
2200+
Required: false,
2201+
Deprecated: false,
2202+
Positional: false,
21592203
},
21602204
{
21612205
Name: "match.ip-subnet.{index}",
@@ -2279,7 +2323,29 @@ func lbACLSet() *core.Command {
22792323
Required: false,
22802324
Deprecated: false,
22812325
Positional: false,
2282-
EnumValues: []string{"allow", "deny"},
2326+
EnumValues: []string{"allow", "deny", "redirect"},
2327+
},
2328+
{
2329+
Name: "acls.{index}.action.redirect.type",
2330+
Short: `Redirect type`,
2331+
Required: false,
2332+
Deprecated: false,
2333+
Positional: false,
2334+
EnumValues: []string{"location", "scheme"},
2335+
},
2336+
{
2337+
Name: "acls.{index}.action.redirect.target",
2338+
Short: `Redirect target (target URL for ` + "`" + `location` + "`" + `, or target ` + "`" + `scheme` + "`" + `)`,
2339+
Required: false,
2340+
Deprecated: false,
2341+
Positional: false,
2342+
},
2343+
{
2344+
Name: "acls.{index}.action.redirect.code",
2345+
Short: `HTTP redirect code to use. Valid values are 301, 302, 303, 307 and 308. Default value is 302`,
2346+
Required: false,
2347+
Deprecated: false,
2348+
Positional: false,
22832349
},
22842350
{
22852351
Name: "acls.{index}.match.ip-subnet.{index}",

0 commit comments

Comments
 (0)