diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 000000000..936c65761
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,97 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## [Unreleased]
+
+## [1.0.0-beta.1](https://github.com/auth0/auth0-cli/tree/1.0.0-beta.1) (Jan 20, 2023)
+
+### Added
+
+- Ability to view user's assigned roles via `auth0 users roles show` [#604]
+- Assign role(s) to user via `auth0 users roles assign` [#605]
+- Remove user role(s) via `auth0 users roles remove` [#606]
+- `perms` alias for `auth0 roles permissions` command [#534]
+- Authenticating via client credentials with `auth0 login` [#546]
+- Graceful access token regeneration [#547]
+- Storing client secret in operating system keyring [#578]
+- Supporting additional scopes through `--scopes` flag when authenticating as user [#538]
+- Argument to specify log stream type for `auth0 logs streams create` and `auth0 logs streams update` [#599]
+- Better guidance on authenticating in the `auth0 login` help text [#565]
+- Confirmation prompts before applying editor updates [#603]
+
+### Changed
+
+- `--format json` flag/value pair consolidated to `--json` [#533]
+- Flattened the `auth0 branding` commands into the root-level [#540], [#541]
+- Moved `auth0 ips` command to `auth0 ap sit ips` [#618]
+- Moved `auth0 users unblock` to `auth0 users blocks unblock` [#617]
+- `--reveal` flag for reveal client secret renamed to `--reveal-secrets` [#591]
+- Editorializing code "hints" throughout project [#570]
+
+### Fixed
+
+- "something went wrong" error during `auth0 branding texts update` [#584]
+- Help text descriptions for most instances of `--number` flag [#610]
+- Allow updating a non-existent email template with `auth0 email templates update` [#611]
+- `--no-input` flag works for `auth0 test token` and `auth0 test login` commands [#613]
+- `--no-color` flag works for all commands [#594]
+- All available triggers present when running `auth0 actions create` [#597]
+- Extraneous payload property when running `auth0 orgs update` [#583]
+- Users search command enables pagination through `--number` flag [#588]
+- Tenant commands now respect `--tenant` flag [#612]
+- Log tail output now displays absolute time instead of relative [#590]
+- Adding missing headers for `auth0 logs list` [#589]
+- Output new action data when running `auth0 actions update` [#596]
+- Log streams "no roles" errors message [#598]
+- Removed erroneous `auth0 apis show --json` truncation message [#607]
+- Skip interactive elements when `--json` and `--force` flags are passed [#616]
+
+### Removed
+
+- `--force` and `--json` flags relegated from global context, now applied only where appropriate [#536], [#595]
+- Undocumented `auth0 config init` command [#532]
+- `auth0 tenants add` command in favor of `auth0 login` [#546]
+- Updating of action triggers which inevitably results in error [#597]
+
+[#604]: https://github.com/auth0/auth0-cli/issues/604
+[#605]: https://github.com/auth0/auth0-cli/issues/605
+[#606]: https://github.com/auth0/auth0-cli/issues/606
+[#534]: https://github.com/auth0/auth0-cli/issues/534
+[#546]: https://github.com/auth0/auth0-cli/issues/546
+[#547]: https://github.com/auth0/auth0-cli/issues/547
+[#578]: https://github.com/auth0/auth0-cli/issues/578
+[#538]: https://github.com/auth0/auth0-cli/issues/538
+[#599]: https://github.com/auth0/auth0-cli/issues/599
+[#565]: https://github.com/auth0/auth0-cli/issues/565
+[#603]: https://github.com/auth0/auth0-cli/issues/603
+[#533]: https://github.com/auth0/auth0-cli/issues/533
+[#540]: https://github.com/auth0/auth0-cli/issues/540
+[#541]: https://github.com/auth0/auth0-cli/issues/541
+[#591]: https://github.com/auth0/auth0-cli/issues/591
+[#570]: https://github.com/auth0/auth0-cli/issues/570
+[#584]: https://github.com/auth0/auth0-cli/issues/584
+[#610]: https://github.com/auth0/auth0-cli/issues/610
+[#611]: https://github.com/auth0/auth0-cli/issues/611
+[#613]: https://github.com/auth0/auth0-cli/issues/613
+[#594]: https://github.com/auth0/auth0-cli/issues/594
+[#597]: https://github.com/auth0/auth0-cli/issues/597
+[#583]: https://github.com/auth0/auth0-cli/issues/583
+[#588]: https://github.com/auth0/auth0-cli/issues/588
+[#590]: https://github.com/auth0/auth0-cli/issues/590
+[#589]: https://github.com/auth0/auth0-cli/issues/589
+[#596]: https://github.com/auth0/auth0-cli/issues/596
+[#598]: https://github.com/auth0/auth0-cli/issues/598
+[#607]: https://github.com/auth0/auth0-cli/issues/607
+[#616]: https://github.com/auth0/auth0-cli/issues/616
+[#536]: https://github.com/auth0/auth0-cli/issues/536
+[#532]: https://github.com/auth0/auth0-cli/issues/532
+[#546]: https://github.com/auth0/auth0-cli/issues/546
+[#597]: https://github.com/auth0/auth0-cli/issues/597
+[#617]: https://github.com/auth0/auth0-cli/issues/617
+[#618]: https://github.com/auth0/auth0-cli/issues/618
+[#612]: https://github.com/auth0/auth0-cli/issues/612
+[#595]: https://github.com/auth0/auth0-cli/issues/595
diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md
new file mode 100644
index 000000000..d6c0ebc21
--- /dev/null
+++ b/MIGRATION_GUIDE.md
@@ -0,0 +1,153 @@
+# Migration Guide
+
+## Upgrading from v0.x โ v1.0
+
+As is to be expected with a major release, there are breaking changes in this update. Please ensure you read this guide
+thoroughly and prepare your potential automated workflows before upgrading to the Auth0 CLI v1.
+
+### Breaking Changes
+
+- [Commands Reorganization](#commands-reorganization)
+- [Authenticating With Client Credentials](#authenticating-with-client-credentials)
+- [JSON Output Flag](#json-output-flag)
+- [Reveal Client Secrets Flag](#reveal-client-secrets-flag)
+- [Config Command Removal](#config-command-removal)
+
+#### Commands Reorganization
+
+Some commands have been reorganized to establish a more systematic hierarchy.
+All other facets of the commands (arguments, flags, etc.) remain the same.
+
+| **Before (v0)** | **After (v1)** |
+|----------------------------|-------------------------------------------------|
+| `auth0 ips` | `auth0 protection suspicious-ip-throttling ips` |
+| `auth0 users unblock` | `auth0 users blocks unblock` |
+| `auth0 branding domains` | `auth0 domains` |
+| `auth0 branding emails` | `auth0 email templates` |
+| `auth0 branding show` | `auth0 universal-login show` |
+| `auth0 branding update` | `auth0 universal-login update` |
+| `auth0 branding templates` | `auth0 universal-login templates` |
+| `auth0 branding texts` | `auth0 universal-login prompts` |
+
+#### Authenticating With Client Credentials
+
+The `auth0 tenants add` command which enabled authenticating to a tenant via client credentials has been consolidated
+into the `auth0 login` command. It can be interfaced interactively through the terminal or non-interactively by passing
+in the client credentials through the flags.
+
+
+
+
+Before (v0) |
+After (v1) |
+
+
+
+
+```sh
+# Example:
+auth0 tenants add travel0.us.auth0.com \
+--client-id tUIvAH7g2ykVM4lGriYEQ6BKV3je24Ka \
+--client-secret XXXXXXXXXXXXXXXXXXXXXXXXXXXX
+```
+ |
+
+
+```sh
+# Example:
+auth0 login --domain travel0.us.auth0.com \
+--client-id tUIvAH7g2ykVM4lGriYEQ6BKV3je24Ka \
+--client-secret XXXXXXXXXXXXXXXXXXXXXXXXXXXX
+```
+ |
+
+
+
+#### JSON Output Flag
+
+The `--format json` flag-value pair has been condensed into the `--json` flag.
+
+| **Before (v0)** | **After (v1)** |
+|---------------------------------|--------------------------|
+| `auth0 apps list --format json` | `auth0 apps list --json` |
+
+#### Log Streams
+
+In `v0.x`, the creation and updating of log streams through the `auth0 logs streams create` and
+`auth0 log streams update` commands facilitated the management of all log stream types with a mass of
+type-specific flags. For `v1.x`, the type of log stream is now required as an argument.
+This change facilitates more ergonomic flags and type-specific validations.
+
+
+
+Before (v0) |
+After (v1) |
+
+
+
+
+```sh
+# Example:
+auth0 logs streams create \
+--type datadog \
+--name "My Datadog Log Stream" \
+--datadog-id us \
+--datadog-key 3c0c4965368b6b10f8640dbda46abfdc
+```
+ |
+
+
+```sh
+# Example:
+auth0 logs streams create datadog \
+--name "My Datadog Log Stream" \
+--region us \
+--api-key 3c0c4965368b6b10f8640dbda46abfdc
+```
+ |
+
+
+
+#### Reveal Client Secrets Flag
+
+In `v0.x`, the `auth0 apps create` command has a `--reveal` flag that would reveal the client secrets in the output.
+This flag has changed to `--reveal-secrets` to clarify what is being revealed.
+
+| **Before (v0)** | **After (v1)** |
+|------------------------------|--------------------------------------|
+| `auth0 apps create --reveal` | `auth0 apps create --reveal-secrets` |
+
+
+#### Config Command Removal
+
+In `v0.x`, the undocumented `auth0 config init` command existed to authenticate with a tenant for E2E testing.
+It authenticated with tenants via client credentials which were sourced from environment variables.
+This command has been removed in favor of the `auth0 login` command.
+
+
+
+Before (v0) |
+After (v1) |
+
+
+
+
+```sh
+# Example:
+AUTH0_CLI_CLIENT_DOMAIN="travel0.us.auth0.com" \
+AUTH0_CLI_CLIENT_ID="tUIvPH7g2ykVm4lGriYEQ6BKV3je24Ka" \
+AUTH0_CLI_CLIENT_SECRET="XXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
+auth0 config init
+```
+ |
+
+
+```sh
+# Example:
+auth0 login --domain travel0.us.auth0.com \
+--client-id tUIvPH7g2ykVm4lGriYEQ6BKV3je24Ka \
+--client-secret XXXXXXXXXXXXXXXXXXXXXXXXXXXX
+```
+ |
+
+
diff --git a/README.md b/README.md
index 961a29561..cdacf51db 100644
--- a/README.md
+++ b/README.md
@@ -1,21 +1,27 @@
Auth0 CLI
-[![Release](https://img.shields.io/github/v/release/auth0/auth0-cli?include_prereleases&style=flat-square)](https://github.com/auth0/auth0-cli/releases) [![Build Status](https://img.shields.io/github/actions/workflow/status/auth0/auth0-cli/go.yml?branch=main)](https://github.com/auth0/auth0-cli/actions?query=branch%3Amain) [![Go Report Card](https://goreportcard.com/badge/github.com/auth0/auth0-cli?style=flat-square)](https://goreportcard.com/report/github.com/auth0/auth0-cli) [![License](https://img.shields.io/github/license/auth0/auth0-cli.svg?style=flat-square)](https://github.com/auth0/auth0-cli/blob/main/LICENSE)
+[![GoDoc](https://pkg.go.dev/badge/github.com/auth0/auth0-cli.svg)](https://pkg.go.dev/github.com/auth0/auth0-cli)
+[![Go Report Card](https://goreportcard.com/badge/github.com/auth0/auth0-cli?style=flat-square)](https://goreportcard.com/report/github.com/auth0/auth0-cli)
+[![Release](https://img.shields.io/github/v/release/auth0/auth0-cli?logo=auth0&include_prereleases&style=flat-square)](https://github.com/auth0/auth0-cli/releases)
+[![License](https://img.shields.io/github/license/auth0/auth0-cli.svg?logo=fossa&style=flat-square)](https://github.com/auth0/auth0-cli/blob/main/LICENSE)
+[![Build Status](https://img.shields.io/github/actions/workflow/status/auth0/auth0-cli/go.yml?branch=main)](https://github.com/auth0/auth0-cli/actions?query=branch%3Amain)
+---
+
Build, manage and test your [Auth0](https://auth0.com/) integrations from the command line.
![demo](./demo.gif)
-## Highlights
+## ๐ข Highlights
- **๐งช Test your universal login flow:** Emulate your end users' login experience by running `auth0 test login`.
- **๐ Troubleshoot in real-time:** Inspect the events of your Auth0 integration as they happen with the `auth0 logs tail` command.
- **๐ Simplify repetitive tasks:** Create, update, list and delete your Auth0 resources directly from the terminal.
-## Table of Contents
+## ๐ Table of Contents
- [Installation](#installation)
- [Authenticating to Your Tenant](#authenticating-to-your-tenant)
@@ -23,7 +29,7 @@ Build, manage and test your [Auth0](https://auth0.com/) integrations from the co
- [Customization](#customization)
- [Anonymous Analytics](#anonymous-analytics)
-## Installation
+## ๐ช Installation
### macOS
@@ -49,6 +55,20 @@ Install via [cURL](https://curl.se/):
```bash
# Binary will be downloaded to "./auth0".
curl -sSfL https://raw.githubusercontent.com/auth0/auth0-cli/main/install.sh | sh -s -- -b .
+
+# To be able to run the binary from any directory
+# make sure you move it to a place in your $PATH
+# sudo mv ./auth0 /usr/local/bin
+```
+
+### Go
+
+Install via [Go](https://go.dev/):
+
+```bash
+# Make sure your $GOPATH/bin is exported on your $PATH
+# to be able to run the binary from any directory.
+go install github.com/auth0/auth0-cli/cmd/auth0@latest
```
### Manual
@@ -63,15 +83,7 @@ curl -sSfL https://raw.githubusercontent.com/auth0/auth0-cli/main/install.sh | s
> **Note**
> Autocompletion instructions for supported platforms available by running `auth0 completion -h`
-### Go
-
-Install via [Go](https://go.dev/):
-
-```bash
-go install github.com/auth0/auth0-cli/cmd/auth0@latest
-```
-
-## Authenticating to Your Tenant
+## ๐ Authenticating to Your Tenant
Authenticating to your Auth0 tenant is required for most functions of the CLI. It can be initiated by running:
@@ -87,7 +99,7 @@ There are two ways to authenticate:
> **Warning**
> Authenticating as a user is not supported for **private cloud** tenants. Instead, those users should authenticate with client credentials.
-## Available Commands
+## ๐ป Available Commands
- [auth0 actions](https://auth0.github.io/auth0-cli/auth0_actions.html) - Manage resources for actions
- [auth0 api](https://auth0.github.io/auth0-cli/auth0_api.html) - Makes an authenticated HTTP request to the Auth0 Management API
@@ -96,7 +108,6 @@ There are two ways to authenticate:
- [auth0 completion](https://auth0.github.io/auth0-cli/auth0_completion.html) - Setup autocomplete features for this CLI on your terminal
- [auth0 domains](https://auth0.github.io/auth0-cli/auth0_domains.html) - Manage custom domains
- [auth0 email](https://auth0.github.io/auth0-cli/auth0_email.html) - Manage email settings
-- [auth0 ips](https://auth0.github.io/auth0-cli/auth0_ips.html) - Manage blocked IP addresses
- [auth0 login](https://auth0.github.io/auth0-cli/auth0_login.html) - Authenticate the Auth0 CLI
- [auth0 logout](https://auth0.github.io/auth0-cli/auth0_logout.html) - Log out of a tenant's session
- [auth0 logs](https://auth0.github.io/auth0-cli/auth0_logs.html) - View tenant logs
@@ -110,7 +121,7 @@ There are two ways to authenticate:
- [auth0 universal-login](https://auth0.github.io/auth0-cli/auth0_universal-login.html) - Manage the Universal Login experience
- [auth0 users](https://auth0.github.io/auth0-cli/auth0_users.html) - Manage resources for users
-## Customization
+## ๐๏ธ Customization
To change the text editor used for editing templates, rules, and actions,
set the environment variable `EDITOR` to your preferred editor. Example:
@@ -121,7 +132,7 @@ export EDITOR="code -w"
export EDITOR="nano"
```
-## Anonymized Analytics Disclosure
+## ๐ Anonymized Analytics Disclosure
Anonymized data points are collected during the use of this CLI. This data includes the CLI version, operating system, timestamp, and other technical details that do not personally identify you.
@@ -129,7 +140,7 @@ Auth0 uses this data to better understand the usage of this tool to prioritize t
To **opt-out** of this collection, set the `AUTH0_CLI_ANALYTICS` environment variable to `false`.
-## Feedback
+## ๐ Feedback
### Contributing
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_ips_check.md b/docs/auth0_ips_check.md
deleted file mode 100644
index 6c875871a..000000000
--- a/docs/auth0_ips_check.md
+++ /dev/null
@@ -1,39 +0,0 @@
----
-layout: default
----
-# auth0 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]
-```
-
-## Examples
-
-```
- auth0 ips check
- auth0 ips check
- auth0 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 ips check](auth0_ips_check.md) - Check IP address
-- [auth0 ips unblock](auth0_ips_unblock.md) - Unblock IP address
-
-
diff --git a/docs/auth0_ips_unblock.md b/docs/auth0_ips_unblock.md
deleted file mode 100644
index 13f5c5eb4..000000000
--- a/docs/auth0_ips_unblock.md
+++ /dev/null
@@ -1,39 +0,0 @@
----
-layout: default
----
-# auth0 ips unblock
-
-Unblock an IP address currently blocked by the Suspicious IP Throttling due to multiple suspicious attempts.
-
-## Usage
-```
-auth0 ips unblock [flags]
-```
-
-## Examples
-
-```
- auth0 ips unblock
- auth0 ips unblock
- auth0 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 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_protection_suspicious-ip-throttling_ips_check.md b/docs/auth0_protection_suspicious-ip-throttling_ips_check.md
new file mode 100644
index 000000000..e13a51563
--- /dev/null
+++ b/docs/auth0_protection_suspicious-ip-throttling_ips_check.md
@@ -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
+ 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
+
+
diff --git a/docs/auth0_protection_suspicious-ip-throttling_ips_unblock.md b/docs/auth0_protection_suspicious-ip-throttling_ips_unblock.md
new file mode 100644
index 000000000..f009293cc
--- /dev/null
+++ b/docs/auth0_protection_suspicious-ip-throttling_ips_unblock.md
@@ -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
+ 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
+
+
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/auth0_users.md b/docs/auth0_users.md
index c86055516..695761429 100644
--- a/docs/auth0_users.md
+++ b/docs/auth0_users.md
@@ -15,6 +15,5 @@ Manage resources for users.
- [auth0 users roles](auth0_users_roles.md) - Manage a user's roles
- [auth0 users search](auth0_users_search.md) - Search for users
- [auth0 users show](auth0_users_show.md) - Show an existing user
-- [auth0 users unblock](auth0_users_unblock.md) - Remove brute-force protection blocks for a given user
- [auth0 users update](auth0_users_update.md) - Update a user
diff --git a/docs/auth0_users_blocks.md b/docs/auth0_users_blocks.md
index 38ce725ea..d652cf667 100644
--- a/docs/auth0_users_blocks.md
+++ b/docs/auth0_users_blocks.md
@@ -8,4 +8,5 @@ Manage brute-force protection user blocks.
## Commands
- [auth0 users blocks list](auth0_users_blocks_list.md) - List brute-force protection blocks for a given user
+- [auth0 users blocks unblock](auth0_users_blocks_unblock.md) - Remove brute-force protection blocks for a given user
diff --git a/docs/auth0_users_blocks_list.md b/docs/auth0_users_blocks_list.md
index a02ece2b8..17fe1eb8f 100644
--- a/docs/auth0_users_blocks_list.md
+++ b/docs/auth0_users_blocks_list.md
@@ -38,5 +38,6 @@ auth0 users blocks list [flags]
## Related Commands
- [auth0 users blocks list](auth0_users_blocks_list.md) - List brute-force protection blocks for a given user
+- [auth0 users blocks unblock](auth0_users_blocks_unblock.md) - Remove brute-force protection blocks for a given user
diff --git a/docs/auth0_users_blocks_unblock.md b/docs/auth0_users_blocks_unblock.md
new file mode 100644
index 000000000..38276b934
--- /dev/null
+++ b/docs/auth0_users_blocks_unblock.md
@@ -0,0 +1,37 @@
+---
+layout: default
+---
+# auth0 users blocks unblock
+
+Remove brute-force protection blocks for a given user.
+
+## Usage
+```
+auth0 users blocks unblock [flags]
+```
+
+## Examples
+
+```
+ auth0 users blocks unblock
+```
+
+
+
+
+## InheritedFlags
+
+```
+ --debug Enable debug mode.
+ --no-color Disable colors.
+ --no-input Disable interactivity.
+ --tenant string Specific tenant to use.
+```
+
+
+## Related Commands
+
+- [auth0 users blocks list](auth0_users_blocks_list.md) - List brute-force protection blocks for a given user
+- [auth0 users blocks unblock](auth0_users_blocks_unblock.md) - Remove brute-force protection blocks for a given user
+
+
diff --git a/docs/auth0_users_create.md b/docs/auth0_users_create.md
index da83f238c..3bb48df10 100644
--- a/docs/auth0_users_create.md
+++ b/docs/auth0_users_create.md
@@ -57,7 +57,6 @@ auth0 users create [flags]
- [auth0 users roles](auth0_users_roles.md) - Manage a user's roles
- [auth0 users search](auth0_users_search.md) - Search for users
- [auth0 users show](auth0_users_show.md) - Show an existing user
-- [auth0 users unblock](auth0_users_unblock.md) - Remove brute-force protection blocks for a given user
- [auth0 users update](auth0_users_update.md) - Update a user
diff --git a/docs/auth0_users_delete.md b/docs/auth0_users_delete.md
index 77c8a0235..f78707bf7 100644
--- a/docs/auth0_users_delete.md
+++ b/docs/auth0_users_delete.md
@@ -51,7 +51,6 @@ auth0 users delete [flags]
- [auth0 users roles](auth0_users_roles.md) - Manage a user's roles
- [auth0 users search](auth0_users_search.md) - Search for users
- [auth0 users show](auth0_users_show.md) - Show an existing user
-- [auth0 users unblock](auth0_users_unblock.md) - Remove brute-force protection blocks for a given user
- [auth0 users update](auth0_users_update.md) - Update a user
diff --git a/docs/auth0_users_import.md b/docs/auth0_users_import.md
index ffac67f59..513264647 100644
--- a/docs/auth0_users_import.md
+++ b/docs/auth0_users_import.md
@@ -52,7 +52,6 @@ auth0 users import [flags]
- [auth0 users roles](auth0_users_roles.md) - Manage a user's roles
- [auth0 users search](auth0_users_search.md) - Search for users
- [auth0 users show](auth0_users_show.md) - Show an existing user
-- [auth0 users unblock](auth0_users_unblock.md) - Remove brute-force protection blocks for a given user
- [auth0 users update](auth0_users_update.md) - Update a user
diff --git a/docs/auth0_users_open.md b/docs/auth0_users_open.md
index 8417ea860..4fde0b9f8 100644
--- a/docs/auth0_users_open.md
+++ b/docs/auth0_users_open.md
@@ -40,7 +40,6 @@ auth0 users open [flags]
- [auth0 users roles](auth0_users_roles.md) - Manage a user's roles
- [auth0 users search](auth0_users_search.md) - Search for users
- [auth0 users show](auth0_users_show.md) - Show an existing user
-- [auth0 users unblock](auth0_users_unblock.md) - Remove brute-force protection blocks for a given user
- [auth0 users update](auth0_users_update.md) - Update a user
diff --git a/docs/auth0_users_search.md b/docs/auth0_users_search.md
index 0654dddb3..695786b0b 100644
--- a/docs/auth0_users_search.md
+++ b/docs/auth0_users_search.md
@@ -51,7 +51,6 @@ auth0 users search [flags]
- [auth0 users roles](auth0_users_roles.md) - Manage a user's roles
- [auth0 users search](auth0_users_search.md) - Search for users
- [auth0 users show](auth0_users_show.md) - Show an existing user
-- [auth0 users unblock](auth0_users_unblock.md) - Remove brute-force protection blocks for a given user
- [auth0 users update](auth0_users_update.md) - Update a user
diff --git a/docs/auth0_users_show.md b/docs/auth0_users_show.md
index 2e040d1cb..8724aa078 100644
--- a/docs/auth0_users_show.md
+++ b/docs/auth0_users_show.md
@@ -46,7 +46,6 @@ auth0 users show [flags]
- [auth0 users roles](auth0_users_roles.md) - Manage a user's roles
- [auth0 users search](auth0_users_search.md) - Search for users
- [auth0 users show](auth0_users_show.md) - Show an existing user
-- [auth0 users unblock](auth0_users_unblock.md) - Remove brute-force protection blocks for a given user
- [auth0 users update](auth0_users_update.md) - Update a user
diff --git a/docs/auth0_users_unblock.md b/docs/auth0_users_unblock.md
deleted file mode 100644
index f836a8c94..000000000
--- a/docs/auth0_users_unblock.md
+++ /dev/null
@@ -1,45 +0,0 @@
----
-layout: default
----
-# auth0 users unblock
-
-Remove brute-force protection blocks for a given user.
-
-## Usage
-```
-auth0 users unblock [flags]
-```
-
-## Examples
-
-```
- auth0 users unblock
-```
-
-
-
-
-## InheritedFlags
-
-```
- --debug Enable debug mode.
- --no-color Disable colors.
- --no-input Disable interactivity.
- --tenant string Specific tenant to use.
-```
-
-
-## Related Commands
-
-- [auth0 users blocks](auth0_users_blocks.md) - Manage brute-force protection user blocks
-- [auth0 users create](auth0_users_create.md) - Create a new user
-- [auth0 users delete](auth0_users_delete.md) - Delete a user
-- [auth0 users import](auth0_users_import.md) - Import users from schema
-- [auth0 users open](auth0_users_open.md) - Open the user's settings page
-- [auth0 users roles](auth0_users_roles.md) - Manage a user's roles
-- [auth0 users search](auth0_users_search.md) - Search for users
-- [auth0 users show](auth0_users_show.md) - Show an existing user
-- [auth0 users unblock](auth0_users_unblock.md) - Remove brute-force protection blocks for a given user
-- [auth0 users update](auth0_users_update.md) - Update a user
-
-
diff --git a/docs/auth0_users_update.md b/docs/auth0_users_update.md
index bb8861b10..74d4fe212 100644
--- a/docs/auth0_users_update.md
+++ b/docs/auth0_users_update.md
@@ -55,7 +55,6 @@ auth0 users update [flags]
- [auth0 users roles](auth0_users_roles.md) - Manage a user's roles
- [auth0 users search](auth0_users_search.md) - Search for users
- [auth0 users show](auth0_users_show.md) - Show an existing user
-- [auth0 users unblock](auth0_users_unblock.md) - Remove brute-force protection blocks for a given user
- [auth0 users update](auth0_users_update.md) - Update a user
diff --git a/docs/index.md b/docs/index.md
index 0fbff4ca1..4c0cbf375 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -30,6 +30,14 @@ Install via [cURL](https://curl.se/):
curl -sSfL https://raw.githubusercontent.com/auth0/auth0-cli/main/install.sh | sh -s -- -b .
```
+### Go
+
+Install via [Go](https://go.dev/):
+
+```
+go install github.com/auth0/auth0-cli/cmd/auth0@latest
+```
+
### Manual
1. Download the appropriate binary for your environment from the [latest release](https://github.com/auth0/auth0-cli/releases/latest/)
@@ -62,7 +70,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/cli.go b/internal/cli/cli.go
index 944584d3c..cd819bc4e 100644
--- a/internal/cli/cli.go
+++ b/internal/cli/cli.go
@@ -296,7 +296,7 @@ func (c *cli) getTenant() (Tenant, error) {
return t, nil
}
-// listTenants fetches all of the configured tenants.
+// listTenants fetches all the configured tenants.
func (c *cli) listTenants() ([]Tenant, error) {
if err := c.init(); err != nil {
return []Tenant{}, err
@@ -536,16 +536,15 @@ func shouldPrompt(cmd *cobra.Command, flag *Flag) bool {
return canPrompt(cmd) && !flag.IsSet(cmd)
}
-func shouldPromptWhenFlagless(cmd *cobra.Command, flag string) bool {
- isSet := false
-
+func shouldPromptWhenNoLocalFlagsSet(cmd *cobra.Command) bool {
+ localFlagIsSet := false
cmd.LocalFlags().VisitAll(func(f *pflag.Flag) {
- if f.Changed {
- isSet = true
+ if f.Name != "json" && f.Name != "force" && f.Changed {
+ localFlagIsSet = true
}
})
- return canPrompt(cmd) && !isSet
+ return canPrompt(cmd) && !localFlagIsSet
}
func prepareInteractivity(cmd *cobra.Command) {
diff --git a/internal/cli/doc-gen.go b/internal/cli/doc-gen.go
index 5caa42810..ea5af905d 100644
--- a/internal/cli/doc-gen.go
+++ b/internal/cli/doc-gen.go
@@ -56,6 +56,12 @@ Install via [cURL](https://curl.se/):
{{ wrapWithBackticks "curl -sSfL https://raw.githubusercontent.com/auth0/auth0-cli/main/install.sh | sh -s -- -b ." }}
+### Go
+
+Install via [Go](https://go.dev/):
+
+{{ wrapWithBackticks "go install github.com/auth0/auth0-cli/cmd/auth0@latest" }}
+
### Manual
1. Download the appropriate binary for your environment from the [latest release](https://github.com/auth0/auth0-cli/releases/latest/)
diff --git a/internal/cli/flags.go b/internal/cli/flags.go
index 08837f1c9..dff59a540 100644
--- a/internal/cli/flags.go
+++ b/internal/cli/flags.go
@@ -285,7 +285,7 @@ func shouldAsk(cmd *cobra.Command, f *Flag, isUpdate bool) bool {
if !f.IsRequired && !f.AlwaysPrompt {
return false
}
- return shouldPromptWhenFlagless(cmd, f.LongForm)
+ return shouldPromptWhenNoLocalFlagsSet(cmd)
}
return shouldPrompt(cmd, f)
diff --git a/internal/cli/ips.go b/internal/cli/ips.go
index 4151e9f58..ad60f6744 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())
@@ -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
- 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 {
@@ -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
},
}
@@ -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
- 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 {
@@ -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
},
}
diff --git a/internal/cli/logout.go b/internal/cli/logout.go
index a9699f25b..3c63fc141 100644
--- a/internal/cli/logout.go
+++ b/internal/cli/logout.go
@@ -1,12 +1,9 @@
package cli
import (
- "errors"
"fmt"
"github.com/spf13/cobra"
-
- "github.com/auth0/auth0-cli/internal/prompt"
)
func logoutCmd(cli *cli) *cobra.Command {
@@ -19,42 +16,16 @@ func logoutCmd(cli *cli) *cobra.Command {
auth0 logout
auth0 logout "example.us.auth0.com"`,
RunE: func(cmd *cobra.Command, args []string) error {
- // NOTE(cyx): This was mostly copy/pasted from tenants
- // use command. Consider refactoring.
- var selectedTenant string
- if len(args) == 0 {
- tens, err := cli.listTenants()
- if err != nil {
- return err // This error is already formatted for display
- }
-
- if len(tens) == 0 {
- return errors.New("there are no tenants available to perform the logout")
- }
-
- tenNames := make([]string, len(tens))
- for i, t := range tens {
- tenNames[i] = t.Domain
- }
-
- input := prompt.SelectInput("tenant", "Tenant:", "Tenant to logout", tenNames, tenNames[0], true)
- if err := prompt.AskOne(input, &selectedTenant); err != nil {
- return handleInputError(err)
- }
- } else {
- requestedTenant := args[0]
- t, ok := cli.config.Tenants[requestedTenant]
- if !ok {
- return fmt.Errorf("Unable to find tenant %s; run 'auth0 tenants use' to see your configured tenants or run 'auth0 login' to configure a new tenant", requestedTenant)
- }
- selectedTenant = t.Domain
+ selectedTenant, err := selectValidTenantFromConfig(cli, cmd, args)
+ if err != nil {
+ return err
}
if err := cli.removeTenant(selectedTenant); err != nil {
- return err
+ return fmt.Errorf("failed to log out from the tenant %s: %w", selectedTenant, err)
}
- cli.renderer.Infof("Successfully logged out tenant: %s", selectedTenant)
+ cli.renderer.Infof("Successfully logged out from tenant: %s", selectedTenant)
return nil
},
}
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))
diff --git a/internal/cli/tenants.go b/internal/cli/tenants.go
index 44f7a404c..1862188a9 100644
--- a/internal/cli/tenants.go
+++ b/internal/cli/tenants.go
@@ -4,10 +4,13 @@ import (
"fmt"
"github.com/spf13/cobra"
-
- "github.com/auth0/auth0-cli/internal/prompt"
)
+var tenantDomain = Argument{
+ Name: "Tenant",
+ Help: "Tenant to select",
+}
+
func tenantsCmd(cli *cli) *cobra.Command {
cmd := &cobra.Command{
Use: "tenants",
@@ -32,20 +35,21 @@ func listTenantCmd(cli *cli) *cobra.Command {
Example: ` auth0 tenants list
auth0 tenants ls`,
RunE: func(cmd *cobra.Command, args []string) error {
- tens, err := cli.listTenants()
+ tenants, err := cli.listTenants()
if err != nil {
- return fmt.Errorf("Unable to load tenants due to an unexpected error: %w", err)
+ return fmt.Errorf("failed to load tenants: %w", err)
}
- tenNames := make([]string, len(tens))
- for i, t := range tens {
- tenNames[i] = t.Domain
+ tenantNames := make([]string, len(tenants))
+ for i, t := range tenants {
+ tenantNames[i] = t.Domain
}
- cli.renderer.TenantList(tenNames)
+ cli.renderer.TenantList(tenantNames)
return nil
},
}
+
return cmd
}
@@ -59,35 +63,16 @@ func useTenantCmd(cli *cli) *cobra.Command {
auth0 tenants use
auth0 tenants use "example.us.auth0.com"`,
RunE: func(cmd *cobra.Command, args []string) error {
- var selectedTenant string
- if len(args) == 0 {
- tens, err := cli.listTenants()
- if err != nil {
- return fmt.Errorf("Unable to load tenants due to an unexpected error: %w", err)
- }
-
- tenNames := make([]string, len(tens))
- for i, t := range tens {
- tenNames[i] = t.Domain
- }
-
- input := prompt.SelectInput("tenant", "Tenant:", "Tenant to activate", tenNames, tenNames[0], true)
- if err := prompt.AskOne(input, &selectedTenant); err != nil {
- return handleInputError(err)
- }
- } else {
- requestedTenant := args[0]
- t, ok := cli.config.Tenants[requestedTenant]
- if !ok {
- return fmt.Errorf("Unable to find tenant %s; run 'auth0 tenants use' to see your configured tenants or run 'auth0 login' to configure a new tenant", requestedTenant)
- }
- selectedTenant = t.Domain
+ selectedTenant, err := selectValidTenantFromConfig(cli, cmd, args)
+ if err != nil {
+ return err
}
cli.config.DefaultTenant = selectedTenant
if err := cli.persistConfig(); err != nil {
- return fmt.Errorf("An error occurred while setting the default tenant: %w", err)
+ return fmt.Errorf("failed to set the default tenant: %w", err)
}
+
cli.renderer.Infof("Default tenant switched to: %s", selectedTenant)
return nil
},
@@ -97,15 +82,6 @@ func useTenantCmd(cli *cli) *cobra.Command {
}
func openTenantCmd(cli *cli) *cobra.Command {
- var inputs struct {
- Domain string
- }
-
- var tenantDomain = Argument{
- Name: "Tenant",
- Help: "Tenant to select",
- }
-
cmd := &cobra.Command{
Use: "open",
Args: cobra.MaximumNArgs(1),
@@ -115,20 +91,12 @@ func openTenantCmd(cli *cli) *cobra.Command {
auth0 tenants open
auth0 tenants open "example.us.auth0.com"`,
RunE: func(cmd *cobra.Command, args []string) error {
- if len(args) == 0 {
- err := tenantDomain.Pick(cmd, &inputs.Domain, cli.tenantPickerOptions)
- if err != nil {
- return err
- }
- } else {
- inputs.Domain = args[0]
-
- if _, ok := cli.config.Tenants[inputs.Domain]; !ok {
- return fmt.Errorf("Unable to find tenant %s; run 'auth0 login' to configure a new tenant", inputs.Domain)
- }
+ selectedTenant, err := selectValidTenantFromConfig(cli, cmd, args)
+ if err != nil {
+ return err
}
- openManageURL(cli, inputs.Domain, "tenant/general")
+ openManageURL(cli, selectedTenant, "tenant/general")
return nil
},
}
@@ -136,19 +104,37 @@ func openTenantCmd(cli *cli) *cobra.Command {
return cmd
}
+func selectValidTenantFromConfig(cli *cli, cmd *cobra.Command, args []string) (string, error) {
+ var selectedTenant string
+
+ if len(args) == 0 {
+ err := tenantDomain.Pick(cmd, &selectedTenant, cli.tenantPickerOptions)
+ return selectedTenant, err
+ }
+
+ selectedTenant = args[0]
+ if _, ok := cli.config.Tenants[selectedTenant]; !ok {
+ return "", fmt.Errorf(
+ "failed to find tenant %s.\n\nRun 'auth0 login' to configure a new tenant.",
+ selectedTenant,
+ )
+ }
+
+ return selectedTenant, nil
+}
+
func (c *cli) tenantPickerOptions() (pickerOptions, error) {
- tens, err := c.listTenants()
+ tenants, err := c.listTenants()
if err != nil {
- return nil, fmt.Errorf("Unable to load tenants due to an unexpected error: %w", err)
+ return nil, fmt.Errorf("failed to load tenants: %w", err)
}
var priorityOpts, opts pickerOptions
+ for _, tenant := range tenants {
+ opt := pickerOption{value: tenant.Domain, label: tenant.Domain}
- for _, t := range tens {
- opt := pickerOption{value: t.Domain, label: t.Domain}
-
- // check if this is currently the default tenant.
- if t.Domain == c.config.DefaultTenant {
+ // Check if this is currently the default tenant.
+ if tenant.Domain == c.config.DefaultTenant {
priorityOpts = append(priorityOpts, opt)
} else {
opts = append(opts, opt)
@@ -156,7 +142,7 @@ func (c *cli) tenantPickerOptions() (pickerOptions, error) {
}
if len(opts)+len(priorityOpts) == 0 {
- return nil, errNoApps
+ return nil, fmt.Errorf("there are currently no tenants to pick from")
}
return append(priorityOpts, opts...), nil
diff --git a/internal/cli/users.go b/internal/cli/users.go
index d43fc0952..e9cd7cdea 100644
--- a/internal/cli/users.go
+++ b/internal/cli/users.go
@@ -126,7 +126,6 @@ func usersCmd(cli *cli) *cobra.Command {
cmd.AddCommand(userRolesCmd(cli))
cmd.AddCommand(openUserCmd(cli))
cmd.AddCommand(userBlocksCmd(cli))
- cmd.AddCommand(deleteUserBlocksCmd(cli))
cmd.AddCommand(importUsersCmd(cli))
return cmd
@@ -531,96 +530,6 @@ func openUserCmd(cli *cli) *cobra.Command {
return cmd
}
-func userBlocksCmd(cli *cli) *cobra.Command {
- cmd := &cobra.Command{
- Use: "blocks",
- Short: "Manage brute-force protection user blocks",
- Long: "Manage brute-force protection user blocks.",
- }
-
- cmd.SetUsageTemplate(resourceUsageTemplate())
- cmd.AddCommand(listUserBlocksCmd(cli))
- return cmd
-}
-
-func listUserBlocksCmd(cli *cli) *cobra.Command {
- var inputs struct {
- userID string
- }
-
- cmd := &cobra.Command{
- Use: "list",
- Args: cobra.MaximumNArgs(1),
- Short: "List brute-force protection blocks for a given user",
- Long: "List brute-force protection blocks for a given user.",
- Example: ` auth0 users blocks list
- auth0 users blocks list --json`,
- RunE: func(cmd *cobra.Command, args []string) error {
- if len(args) == 0 {
- if err := userID.Ask(cmd, &inputs.userID); err != nil {
- return err
- }
- } else {
- inputs.userID = args[0]
- }
-
- var userBlocks []*management.UserBlock
-
- err := ansi.Waiting(func() error {
- var err error
- userBlocks, err = cli.api.User.Blocks(inputs.userID)
- return err
- })
-
- if err != nil {
- return fmt.Errorf("Unable to load user blocks %v, error: %w", inputs.userID, err)
- }
-
- cli.renderer.UserBlocksList(userBlocks)
- return nil
- },
- }
-
- cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
-
- return cmd
-}
-
-func deleteUserBlocksCmd(cli *cli) *cobra.Command {
- var inputs struct {
- userID string
- }
-
- cmd := &cobra.Command{
- Use: "unblock",
- Args: cobra.MaximumNArgs(1),
- Short: "Remove brute-force protection blocks for a given user",
- Long: "Remove brute-force protection blocks for a given user.",
- Example: ` auth0 users unblock `,
- RunE: func(cmd *cobra.Command, args []string) error {
- if len(args) == 0 {
- if err := userID.Ask(cmd, &inputs.userID); err != nil {
- return err
- }
- } else {
- inputs.userID = args[0]
- }
-
- err := ansi.Spinner("Deleting blocks for user...", func() error {
- return cli.api.User.Unblock(inputs.userID)
- })
-
- if err != nil {
- return err
- }
-
- return nil
- },
- }
-
- return cmd
-}
-
func importUsersCmd(cli *cli) *cobra.Command {
var inputs struct {
Connection string
diff --git a/internal/cli/users_blocks.go b/internal/cli/users_blocks.go
new file mode 100644
index 000000000..3b71a20bb
--- /dev/null
+++ b/internal/cli/users_blocks.go
@@ -0,0 +1,98 @@
+package cli
+
+import (
+ "fmt"
+
+ "github.com/auth0/go-auth0/management"
+ "github.com/spf13/cobra"
+
+ "github.com/auth0/auth0-cli/internal/ansi"
+)
+
+func userBlocksCmd(cli *cli) *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "blocks",
+ Short: "Manage brute-force protection user blocks",
+ Long: "Manage brute-force protection user blocks.",
+ }
+
+ cmd.SetUsageTemplate(resourceUsageTemplate())
+ cmd.AddCommand(listUserBlocksCmd(cli))
+ cmd.AddCommand(deleteUserBlocksCmd(cli))
+
+ return cmd
+}
+
+func listUserBlocksCmd(cli *cli) *cobra.Command {
+ var inputs struct {
+ userID string
+ }
+
+ cmd := &cobra.Command{
+ Use: "list",
+ Args: cobra.MaximumNArgs(1),
+ Short: "List brute-force protection blocks for a given user",
+ Long: "List brute-force protection blocks for a given user.",
+ Example: ` auth0 users blocks list
+ auth0 users blocks list --json`,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ if len(args) == 0 {
+ if err := userID.Ask(cmd, &inputs.userID); err != nil {
+ return err
+ }
+ } else {
+ inputs.userID = args[0]
+ }
+
+ var userBlocks []*management.UserBlock
+ err := ansi.Waiting(func() (err error) {
+ userBlocks, err = cli.api.User.Blocks(inputs.userID)
+ return err
+ })
+ if err != nil {
+ return fmt.Errorf("failed to list user blocks for user with ID %s: %w", inputs.userID, err)
+ }
+
+ cli.renderer.UserBlocksList(userBlocks)
+ return nil
+ },
+ }
+
+ cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
+
+ return cmd
+}
+
+func deleteUserBlocksCmd(cli *cli) *cobra.Command {
+ var inputs struct {
+ userID string
+ }
+
+ cmd := &cobra.Command{
+ Use: "unblock",
+ Args: cobra.MaximumNArgs(1),
+ Short: "Remove brute-force protection blocks for a given user",
+ Long: "Remove brute-force protection blocks for a given user.",
+ Example: ` auth0 users blocks unblock `,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ if len(args) == 0 {
+ if err := userID.Ask(cmd, &inputs.userID); err != nil {
+ return err
+ }
+ } else {
+ inputs.userID = args[0]
+ }
+
+ err := ansi.Spinner("Unblocking user...", func() error {
+ return cli.api.User.Unblock(inputs.userID)
+ })
+ if err != nil {
+ return fmt.Errorf("failed to unblock user with ID %s: %w", inputs.userID, err)
+ }
+
+ return nil
+ },
+ }
+
+ return cmd
+}