Skip to content

Commit

Permalink
DXCDT-333: Nest ips under ap sit ips (#618)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught authored Jan 20, 2023
1 parent 0919796 commit 68ce9e6
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 107 deletions.
12 changes: 0 additions & 12 deletions docs/auth0_ips.md

This file was deleted.

39 changes: 0 additions & 39 deletions docs/auth0_ips_check.md

This file was deleted.

39 changes: 0 additions & 39 deletions docs/auth0_ips_unblock.md

This file was deleted.

1 change: 1 addition & 0 deletions docs/auth0_protection_suspicious-ip-throttling.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ When Auth0 detects a high number of signup attempts or failed login attempts fro

## Commands

- [auth0 protection suspicious-ip-throttling ips](auth0_protection_suspicious-ip-throttling_ips.md) - Manage blocked IP addresses
- [auth0 protection suspicious-ip-throttling show](auth0_protection_suspicious-ip-throttling_show.md) - Show suspicious ip throttling settings
- [auth0 protection suspicious-ip-throttling update](auth0_protection_suspicious-ip-throttling_update.md) - Update suspicious ip throttling settings

12 changes: 12 additions & 0 deletions docs/auth0_protection_suspicious-ip-throttling_ips.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
layout: default
---
# auth0 protection suspicious-ip-throttling ips

Manually block or unblock an IP address that was blocked via the Suspicious IP Throttling due to multiple suspicious attempts.

## Commands

- [auth0 protection suspicious-ip-throttling ips check](auth0_protection_suspicious-ip-throttling_ips_check.md) - Check IP address
- [auth0 protection suspicious-ip-throttling ips unblock](auth0_protection_suspicious-ip-throttling_ips_unblock.md) - Unblock IP address

39 changes: 39 additions & 0 deletions docs/auth0_protection_suspicious-ip-throttling_ips_check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
layout: default
---
# auth0 protection suspicious-ip-throttling ips check

Check if a given IP address is blocked via the Suspicious IP Throttling due to multiple suspicious attempts.

## Usage
```
auth0 protection suspicious-ip-throttling ips check [flags]
```

## Examples

```
auth0 protection suspicious-ip-throttling ips check
auth0 ap sit ips check <ip>
auth0 ap sit ips check "178.178.178.178"
```




## InheritedFlags

```
--debug Enable debug mode.
--no-color Disable colors.
--no-input Disable interactivity.
--tenant string Specific tenant to use.
```


## Related Commands

- [auth0 protection suspicious-ip-throttling ips check](auth0_protection_suspicious-ip-throttling_ips_check.md) - Check IP address
- [auth0 protection suspicious-ip-throttling ips unblock](auth0_protection_suspicious-ip-throttling_ips_unblock.md) - Unblock IP address


39 changes: 39 additions & 0 deletions docs/auth0_protection_suspicious-ip-throttling_ips_unblock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
layout: default
---
# auth0 protection suspicious-ip-throttling ips unblock

Unblock an IP address currently blocked by the Suspicious IP Throttling due to multiple suspicious attempts.

## Usage
```
auth0 protection suspicious-ip-throttling ips unblock [flags]
```

## Examples

```
auth0 protection suspicious-ip-throttling ips unblock
auth0 ap sit ips unblock <ip>
auth0 ap sit ips unblock "178.178.178.178"
```




## InheritedFlags

```
--debug Enable debug mode.
--no-color Disable colors.
--no-input Disable interactivity.
--tenant string Specific tenant to use.
```


## Related Commands

- [auth0 protection suspicious-ip-throttling ips check](auth0_protection_suspicious-ip-throttling_ips_check.md) - Check IP address
- [auth0 protection suspicious-ip-throttling ips unblock](auth0_protection_suspicious-ip-throttling_ips_unblock.md) - Unblock IP address


1 change: 1 addition & 0 deletions docs/auth0_protection_suspicious-ip-throttling_show.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ auth0 protection suspicious-ip-throttling show [flags]

## Related Commands

- [auth0 protection suspicious-ip-throttling ips](auth0_protection_suspicious-ip-throttling_ips.md) - Manage blocked IP addresses
- [auth0 protection suspicious-ip-throttling show](auth0_protection_suspicious-ip-throttling_show.md) - Show suspicious ip throttling settings
- [auth0 protection suspicious-ip-throttling update](auth0_protection_suspicious-ip-throttling_update.md) - Update suspicious ip throttling settings

Expand Down
1 change: 1 addition & 0 deletions docs/auth0_protection_suspicious-ip-throttling_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ auth0 protection suspicious-ip-throttling update [flags]

## Related Commands

- [auth0 protection suspicious-ip-throttling ips](auth0_protection_suspicious-ip-throttling_ips.md) - Manage blocked IP addresses
- [auth0 protection suspicious-ip-throttling show](auth0_protection_suspicious-ip-throttling_show.md) - Show suspicious ip throttling settings
- [auth0 protection suspicious-ip-throttling update](auth0_protection_suspicious-ip-throttling_update.md) - Update suspicious ip throttling settings

Expand Down
1 change: 0 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ There are two ways to authenticate:
- [auth0 completion](auth0_completion.md) - Setup autocomplete features for this CLI on your terminal
- [auth0 domains](auth0_domains.md) - Manage custom domains
- [auth0 email](auth0_email.md) - Manage email settings
- [auth0 ips](auth0_ips.md) - Manage blocked IP addresses
- [auth0 login](auth0_login.md) - Authenticate the Auth0 CLI
- [auth0 logout](auth0_logout.md) - Log out of a tenant's session
- [auth0 logs](auth0_logs.md) - View tenant logs
Expand Down
1 change: 1 addition & 0 deletions internal/cli/attack_protection_suspicious_ip_throttling.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func suspiciousIPThrottlingCmd(cli *cli) *cobra.Command {

cmd.AddCommand(showSuspiciousIPThrottlingCmd(cli))
cmd.AddCommand(updateSuspiciousIPThrottlingCmd(cli))
cmd.AddCommand(ipsCmd(cli))

return cmd
}
Expand Down
30 changes: 15 additions & 15 deletions internal/cli/ips.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ func ipsCmd(cli *cli) *cobra.Command {
cmd := &cobra.Command{
Use: "ips",
Short: "Manage blocked IP addresses",
Long: "Manually block or unblock an IP address.",
Long: "Manually block or unblock an IP address that was blocked via the Suspicious IP Throttling " +
"due to multiple suspicious attempts.",
}

cmd.SetUsageTemplate(resourceUsageTemplate())
Expand All @@ -40,9 +41,9 @@ func checkIPCmd(cli *cli) *cobra.Command {
Short: "Check IP address",
Long: "Check if a given IP address is blocked via the Suspicious IP Throttling due to " +
"multiple suspicious attempts.",
Example: ` auth0 ips check
auth0 ips check <ip>
auth0 ips check "178.178.178.178"`,
Example: ` auth0 protection suspicious-ip-throttling ips check
auth0 ap sit ips check <ip>
auth0 ap sit ips check "178.178.178.178"`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
if err := ipAddress.Ask(cmd, &inputs.IP); err != nil {
Expand All @@ -53,23 +54,21 @@ func checkIPCmd(cli *cli) *cobra.Command {
}

var isBlocked bool

if err := ansi.Waiting(func() error {
var err error
if err := ansi.Waiting(func() (err error) {
isBlocked, err = cli.api.Anomaly.CheckIP(inputs.IP)
return err
}); err != nil {
return fmt.Errorf("An unexpected error occurred: %w", err)
return fmt.Errorf("failed to check if IP %q is blocked: %w", inputs.IP, err)
}

cli.renderer.Heading("ip")

if isBlocked {
cli.renderer.Infof("The IP %s is blocked", inputs.IP)
} else {
cli.renderer.Infof("The IP %s is not blocked", inputs.IP)
return nil
}

cli.renderer.Infof("The IP %s is not blocked", inputs.IP)
return nil
},
}
Expand All @@ -88,9 +87,9 @@ func unblockIPCmd(cli *cli) *cobra.Command {
Short: "Unblock IP address",
Long: "Unblock an IP address currently blocked by the Suspicious IP Throttling due to " +
"multiple suspicious attempts.",
Example: ` auth0 ips unblock
auth0 ips unblock <ip>
auth0 ips unblock "178.178.178.178"`,
Example: ` auth0 protection suspicious-ip-throttling ips unblock
auth0 ap sit ips unblock <ip>
auth0 ap sit ips unblock "178.178.178.178"`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
if err := ipAddress.Ask(cmd, &inputs.IP); err != nil {
Expand All @@ -103,11 +102,12 @@ func unblockIPCmd(cli *cli) *cobra.Command {
if err := ansi.Waiting(func() error {
return cli.api.Anomaly.UnblockIP(inputs.IP)
}); err != nil {
return fmt.Errorf("An unexpected error occurred: %w", err)
return fmt.Errorf("failed to unblock IP %q: %w", inputs.IP, err)
}

cli.renderer.Heading("ip")
cli.renderer.Infof("The IP %s was unblocked", inputs.IP)
cli.renderer.Infof("The IP %s was unblocked.", inputs.IP)

return nil
},
}
Expand Down
1 change: 0 additions & 1 deletion internal/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ func addSubCommands(rootCmd *cobra.Command, cli *cli) {
rootCmd.AddCommand(universalLoginCmd(cli))
rootCmd.AddCommand(emailCmd(cli))
rootCmd.AddCommand(customDomainsCmd(cli))
rootCmd.AddCommand(ipsCmd(cli))
rootCmd.AddCommand(quickstartsCmd(cli))
rootCmd.AddCommand(attackProtectionCmd(cli))
rootCmd.AddCommand(testCmd(cli))
Expand Down

0 comments on commit 68ce9e6

Please sign in to comment.