| 77 | } |
| 78 | |
| 79 | func unblockIPCmd(cli *cli) *cobra.Command { |
| 80 | var inputs struct { |
| 81 | IP string |
| 82 | } |
| 83 | |
| 84 | cmd := &cobra.Command{ |
| 85 | Use: "unblock", |
| 86 | Args: cobra.MaximumNArgs(1), |
| 87 | Short: "Unblock IP address", |
| 88 | Long: "Unblock an IP address currently blocked by the Suspicious IP Throttling due to " + |
| 89 | "multiple suspicious attempts.", |
| 90 | Example: ` auth0 protection suspicious-ip-throttling ips unblock |
| 91 | auth0 ap sit ips unblock <ip> |
| 92 | auth0 ap sit ips unblock "178.178.178.178"`, |
| 93 | RunE: func(cmd *cobra.Command, args []string) error { |
| 94 | if len(args) == 0 { |
| 95 | if err := ipAddress.Ask(cmd, &inputs.IP); err != nil { |
| 96 | return err |
| 97 | } |
| 98 | } else { |
| 99 | inputs.IP = args[0] |
| 100 | } |
| 101 | |
| 102 | if err := ansi.Waiting(func() error { |
| 103 | return cli.api.Anomaly.UnblockIP(cmd.Context(), inputs.IP) |
| 104 | }); err != nil { |
| 105 | return fmt.Errorf("failed to unblock IP %q: %w", inputs.IP, err) |
| 106 | } |
| 107 | |
| 108 | cli.renderer.Heading("ip") |
| 109 | cli.renderer.Infof("The IP %s was unblocked.", inputs.IP) |
| 110 | |
| 111 | return nil |
| 112 | }, |
| 113 | } |
| 114 | |
| 115 | return cmd |
| 116 | } |