From e61a030decb52320d18a57a890308b2972d748c4 Mon Sep 17 00:00:00 2001 From: Sergiu Ghitea <28300158+sergiught@users.noreply.github.com> Date: Thu, 19 Jan 2023 13:58:57 +0100 Subject: [PATCH 1/2] Nest ips under ap sit ips --- docs/auth0_ips.md | 12 ------------ docs/auth0_protection_suspicious-ip-throttling.md | 1 + .../auth0_protection_suspicious-ip-throttling_ips.md | 12 ++++++++++++ ...protection_suspicious-ip-throttling_ips_check.md} | 8 ++++---- ...otection_suspicious-ip-throttling_ips_unblock.md} | 8 ++++---- ...auth0_protection_suspicious-ip-throttling_show.md | 1 + ...th0_protection_suspicious-ip-throttling_update.md | 1 + docs/index.md | 1 - .../attack_protection_suspicious_ip_throttling.go | 1 + internal/cli/ips.go | 3 ++- internal/cli/root.go | 1 - 11 files changed, 26 insertions(+), 23 deletions(-) delete mode 100644 docs/auth0_ips.md create mode 100644 docs/auth0_protection_suspicious-ip-throttling_ips.md rename docs/{auth0_ips_check.md => auth0_protection_suspicious-ip-throttling_ips_check.md} (55%) rename docs/{auth0_ips_unblock.md => auth0_protection_suspicious-ip-throttling_ips_unblock.md} (55%) diff --git a/docs/auth0_ips.md b/docs/auth0_ips.md deleted file mode 100644 index fd39f38bc..000000000 --- a/docs/auth0_ips.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -layout: default ---- -# auth0 ips - -Manually block or unblock an IP address. - -## Commands - -- [auth0 ips check](auth0_ips_check.md) - Check IP address -- [auth0 ips unblock](auth0_ips_unblock.md) - Unblock IP address - diff --git a/docs/auth0_protection_suspicious-ip-throttling.md b/docs/auth0_protection_suspicious-ip-throttling.md index 6b4b379cb..289b0eb2f 100644 --- a/docs/auth0_protection_suspicious-ip-throttling.md +++ b/docs/auth0_protection_suspicious-ip-throttling.md @@ -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 diff --git a/docs/auth0_protection_suspicious-ip-throttling_ips.md b/docs/auth0_protection_suspicious-ip-throttling_ips.md new file mode 100644 index 000000000..cf52d13f3 --- /dev/null +++ b/docs/auth0_protection_suspicious-ip-throttling_ips.md @@ -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 + diff --git a/docs/auth0_ips_check.md b/docs/auth0_protection_suspicious-ip-throttling_ips_check.md similarity index 55% rename from docs/auth0_ips_check.md rename to docs/auth0_protection_suspicious-ip-throttling_ips_check.md index 6c875871a..47b5a9a0c 100644 --- a/docs/auth0_ips_check.md +++ b/docs/auth0_protection_suspicious-ip-throttling_ips_check.md @@ -1,13 +1,13 @@ --- layout: default --- -# auth0 ips check +# 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 ips check [flags] +auth0 protection suspicious-ip-throttling ips check [flags] ``` ## Examples @@ -33,7 +33,7 @@ auth0 ips check [flags] ## Related Commands -- [auth0 ips check](auth0_ips_check.md) - Check IP address -- [auth0 ips unblock](auth0_ips_unblock.md) - Unblock IP address +- [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 diff --git a/docs/auth0_ips_unblock.md b/docs/auth0_protection_suspicious-ip-throttling_ips_unblock.md similarity index 55% rename from docs/auth0_ips_unblock.md rename to docs/auth0_protection_suspicious-ip-throttling_ips_unblock.md index 13f5c5eb4..e7fbc7c23 100644 --- a/docs/auth0_ips_unblock.md +++ b/docs/auth0_protection_suspicious-ip-throttling_ips_unblock.md @@ -1,13 +1,13 @@ --- layout: default --- -# auth0 ips unblock +# 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 ips unblock [flags] +auth0 protection suspicious-ip-throttling ips unblock [flags] ``` ## Examples @@ -33,7 +33,7 @@ auth0 ips unblock [flags] ## Related Commands -- [auth0 ips check](auth0_ips_check.md) - Check IP address -- [auth0 ips unblock](auth0_ips_unblock.md) - Unblock IP address +- [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 diff --git a/docs/auth0_protection_suspicious-ip-throttling_show.md b/docs/auth0_protection_suspicious-ip-throttling_show.md index df0a36d4f..ad2fc2081 100644 --- a/docs/auth0_protection_suspicious-ip-throttling_show.md +++ b/docs/auth0_protection_suspicious-ip-throttling_show.md @@ -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 diff --git a/docs/auth0_protection_suspicious-ip-throttling_update.md b/docs/auth0_protection_suspicious-ip-throttling_update.md index cedbbc020..28cb1b639 100644 --- a/docs/auth0_protection_suspicious-ip-throttling_update.md +++ b/docs/auth0_protection_suspicious-ip-throttling_update.md @@ -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 diff --git a/docs/index.md b/docs/index.md index 0fbff4ca1..db04b6848 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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 diff --git a/internal/cli/attack_protection_suspicious_ip_throttling.go b/internal/cli/attack_protection_suspicious_ip_throttling.go index 2968752a2..187d7f0a1 100644 --- a/internal/cli/attack_protection_suspicious_ip_throttling.go +++ b/internal/cli/attack_protection_suspicious_ip_throttling.go @@ -104,6 +104,7 @@ func suspiciousIPThrottlingCmd(cli *cli) *cobra.Command { cmd.AddCommand(showSuspiciousIPThrottlingCmd(cli)) cmd.AddCommand(updateSuspiciousIPThrottlingCmd(cli)) + cmd.AddCommand(ipsCmd(cli)) return cmd } diff --git a/internal/cli/ips.go b/internal/cli/ips.go index 4151e9f58..aba9317e7 100644 --- a/internal/cli/ips.go +++ b/internal/cli/ips.go @@ -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()) diff --git a/internal/cli/root.go b/internal/cli/root.go index dd69b9a05..ef685e3bb 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -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)) From 2122ce3d4c551117b86d317d7266dffbc704da3b Mon Sep 17 00:00:00 2001 From: Sergiu Ghitea <28300158+sergiught@users.noreply.github.com> Date: Thu, 19 Jan 2023 15:01:35 +0100 Subject: [PATCH 2/2] Refactor ips --- ...tion_suspicious-ip-throttling_ips_check.md | 6 ++--- ...on_suspicious-ip-throttling_ips_unblock.md | 6 ++--- internal/cli/ips.go | 27 +++++++++---------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/docs/auth0_protection_suspicious-ip-throttling_ips_check.md b/docs/auth0_protection_suspicious-ip-throttling_ips_check.md index 47b5a9a0c..e13a51563 100644 --- a/docs/auth0_protection_suspicious-ip-throttling_ips_check.md +++ b/docs/auth0_protection_suspicious-ip-throttling_ips_check.md @@ -13,9 +13,9 @@ auth0 protection suspicious-ip-throttling ips check [flags] ## Examples ``` - auth0 ips check - auth0 ips check - auth0 ips check "178.178.178.178" + auth0 protection suspicious-ip-throttling ips check + auth0 ap sit ips check + auth0 ap sit ips check "178.178.178.178" ``` diff --git a/docs/auth0_protection_suspicious-ip-throttling_ips_unblock.md b/docs/auth0_protection_suspicious-ip-throttling_ips_unblock.md index e7fbc7c23..f009293cc 100644 --- a/docs/auth0_protection_suspicious-ip-throttling_ips_unblock.md +++ b/docs/auth0_protection_suspicious-ip-throttling_ips_unblock.md @@ -13,9 +13,9 @@ auth0 protection suspicious-ip-throttling ips unblock [flags] ## Examples ``` - auth0 ips unblock - auth0 ips unblock - auth0 ips unblock "178.178.178.178" + auth0 protection suspicious-ip-throttling ips unblock + auth0 ap sit ips unblock + auth0 ap sit ips unblock "178.178.178.178" ``` diff --git a/internal/cli/ips.go b/internal/cli/ips.go index aba9317e7..ad60f6744 100644 --- a/internal/cli/ips.go +++ b/internal/cli/ips.go @@ -41,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 - auth0 ips check "178.178.178.178"`, + Example: ` auth0 protection suspicious-ip-throttling ips check + auth0 ap sit ips check + 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 { @@ -54,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 }, } @@ -89,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 - auth0 ips unblock "178.178.178.178"`, + Example: ` auth0 protection suspicious-ip-throttling ips unblock + auth0 ap sit ips unblock + 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 { @@ -104,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 }, }