Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/auth0_domains.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ With a custom domain, your users feel confident that they are providing their cr
## Commands

- [auth0 domains create](auth0_domains_create.md) - Create a custom domain
- [auth0 domains default](auth0_domains_default.md) - Manage the default custom domain
- [auth0 domains delete](auth0_domains_delete.md) - Delete a custom domain
- [auth0 domains list](auth0_domains_list.md) - List your custom domains
- [auth0 domains show](auth0_domains_show.md) - Show a custom domain
Expand Down
1 change: 1 addition & 0 deletions docs/auth0_domains_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ auth0 domains create [flags]
## Related Commands

- [auth0 domains create](auth0_domains_create.md) - Create a custom domain
- [auth0 domains default](auth0_domains_default.md) - Manage the default custom domain
- [auth0 domains delete](auth0_domains_delete.md) - Delete a custom domain
- [auth0 domains list](auth0_domains_list.md) - List your custom domains
- [auth0 domains show](auth0_domains_show.md) - Show a custom domain
Expand Down
14 changes: 14 additions & 0 deletions docs/auth0_domains_default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
layout: default
has_toc: false
has_children: true
---
# auth0 domains default

Manage the default custom domain for the tenant. Use sub-commands to show or set the default domain.

## Commands

- [auth0 domains default set](auth0_domains_default_set.md) - Set the default custom domain
- [auth0 domains default show](auth0_domains_default_show.md) - Show the default custom domain

53 changes: 53 additions & 0 deletions docs/auth0_domains_default_set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
layout: default
parent: auth0 domains default
has_toc: false
---
# auth0 domains default set

Set the default custom domain for the tenant.

To set interactively, use `auth0 domains default set` with no arguments.

To set non-interactively, supply the domain name as an argument or through the flag.

## Usage
```
auth0 domains default set [flags]
```

## Examples

```
auth0 domains default set
auth0 domains default set <domain>
auth0 domains default set --domain <domain>
auth0 domains default set --domain <domain> --json
```


## Flags

```
-d, --domain string Domain name.
--json Output in json format.
--json-compact Output in compact json format.
```


## Inherited Flags

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


## Related Commands

- [auth0 domains default set](auth0_domains_default_set.md) - Set the default custom domain
- [auth0 domains default show](auth0_domains_default_show.md) - Show the default custom domain


47 changes: 47 additions & 0 deletions docs/auth0_domains_default_show.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
layout: default
parent: auth0 domains default
has_toc: false
---
# auth0 domains default show

Display the default custom domain configuration for the tenant.

## Usage
```
auth0 domains default show [flags]
```

## Examples

```
auth0 domains default show
auth0 domains default show --json
auth0 domains default show --json-compact
```


## Flags

```
--json Output in json format.
--json-compact Output in compact json format.
```


## Inherited Flags

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


## Related Commands

- [auth0 domains default set](auth0_domains_default_set.md) - Set the default custom domain
- [auth0 domains default show](auth0_domains_default_show.md) - Show the default custom domain


1 change: 1 addition & 0 deletions docs/auth0_domains_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ auth0 domains delete [flags]
## Related Commands

- [auth0 domains create](auth0_domains_create.md) - Create a custom domain
- [auth0 domains default](auth0_domains_default.md) - Manage the default custom domain
- [auth0 domains delete](auth0_domains_delete.md) - Delete a custom domain
- [auth0 domains list](auth0_domains_list.md) - List your custom domains
- [auth0 domains show](auth0_domains_show.md) - Show a custom domain
Expand Down
1 change: 1 addition & 0 deletions docs/auth0_domains_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ auth0 domains list [flags]
## Related Commands

- [auth0 domains create](auth0_domains_create.md) - Create a custom domain
- [auth0 domains default](auth0_domains_default.md) - Manage the default custom domain
- [auth0 domains delete](auth0_domains_delete.md) - Delete a custom domain
- [auth0 domains list](auth0_domains_list.md) - List your custom domains
- [auth0 domains show](auth0_domains_show.md) - Show a custom domain
Expand Down
1 change: 1 addition & 0 deletions docs/auth0_domains_show.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ auth0 domains show [flags]
## Related Commands

- [auth0 domains create](auth0_domains_create.md) - Create a custom domain
- [auth0 domains default](auth0_domains_default.md) - Manage the default custom domain
- [auth0 domains delete](auth0_domains_delete.md) - Delete a custom domain
- [auth0 domains list](auth0_domains_list.md) - List your custom domains
- [auth0 domains show](auth0_domains_show.md) - Show a custom domain
Expand Down
1 change: 1 addition & 0 deletions docs/auth0_domains_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ auth0 domains update [flags]
## Related Commands

- [auth0 domains create](auth0_domains_create.md) - Create a custom domain
- [auth0 domains default](auth0_domains_default.md) - Manage the default custom domain
- [auth0 domains delete](auth0_domains_delete.md) - Delete a custom domain
- [auth0 domains list](auth0_domains_list.md) - List your custom domains
- [auth0 domains show](auth0_domains_show.md) - Show a custom domain
Expand Down
1 change: 1 addition & 0 deletions docs/auth0_domains_verify.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ auth0 domains verify [flags]
## Related Commands

- [auth0 domains create](auth0_domains_create.md) - Create a custom domain
- [auth0 domains default](auth0_domains_default.md) - Manage the default custom domain
- [auth0 domains delete](auth0_domains_delete.md) - Delete a custom domain
- [auth0 domains list](auth0_domains_list.md) - List your custom domains
- [auth0 domains show](auth0_domains_show.md) - Show a custom domain
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/PuerkitoBio/rehttp v1.4.0
github.com/atotto/clipboard v0.1.4
github.com/auth0/go-auth0 v1.36.0
github.com/auth0/go-auth0 v1.36.1-0.20260317125325-3fac89c7c7d6
github.com/auth0/go-auth0/v2 v2.6.0
github.com/briandowns/spinner v1.23.2
github.com/charmbracelet/glamour v0.10.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/auth0/go-auth0 v1.36.0 h1:B3gxl26i4HLKoUmpEF4KrtsEA0Tx0Quxci+9f8/Lvfg=
github.com/auth0/go-auth0 v1.36.0/go.mod h1:32sQB1uAn+99fJo6N819EniKq8h785p0ag0lMWhiTaE=
github.com/auth0/go-auth0 v1.36.1-0.20260317125325-3fac89c7c7d6 h1:U2c6oyHdYeVBRkiWZyQ03jB9OZZCdKBdABRNc409z4Q=
github.com/auth0/go-auth0 v1.36.1-0.20260317125325-3fac89c7c7d6/go.mod h1:32sQB1uAn+99fJo6N819EniKq8h785p0ag0lMWhiTaE=
github.com/auth0/go-auth0/v2 v2.6.0 h1:KCoLxTcH8qXPYbwKZxxFrL/6P+P+Zc58BQPL6w0Kt30=
github.com/auth0/go-auth0/v2 v2.6.0/go.mod h1:XVRck9fw1EIw1z4guYcbKFGmElnexb+xOvQ/0U1hHd0=
github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0 h1:0NmehRCgyk5rljDQLKUO+cRJCnduDyn11+zGZIc9Z48=
Expand Down
6 changes: 6 additions & 0 deletions internal/auth0/custom_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,10 @@ type CustomDomainAPI interface {

// ListWithPagination lists all custom domains with support for pagination.
ListWithPagination(ctx context.Context, opts ...management.RequestOption) (c *management.CustomDomainList, err error)

// ReadDefault retrieves the default domain configuration for the tenant.
ReadDefault(ctx context.Context, opts ...management.RequestOption) (c *management.CustomDomainDefault, err error)

// UpdateDefault updates the default domain for the tenant.
UpdateDefault(ctx context.Context, c *management.CustomDomainDefault, opts ...management.RequestOption) error
}
40 changes: 40 additions & 0 deletions internal/auth0/mock/custom_domain_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

125 changes: 125 additions & 0 deletions internal/cli/custom_domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func customDomainsCmd(cli *cli) *cobra.Command {
cmd.AddCommand(updateCustomDomainCmd(cli))
cmd.AddCommand(deleteCustomDomainCmd(cli))
cmd.AddCommand(verifyCustomDomainCmd(cli))
cmd.AddCommand(defaultCustomDomainCmd(cli))

return cmd
}
Expand Down Expand Up @@ -517,6 +518,101 @@ func apiProvisioningTypeFor(v string) *string {
}
}

func defaultCustomDomainCmd(cli *cli) *cobra.Command {
cmd := &cobra.Command{
Use: "default",
Short: "Manage the default custom domain",
Long: "Manage the default custom domain for the tenant. Use sub-commands to show or set the default domain.",
}

cmd.SetUsageTemplate(resourceUsageTemplate())
cmd.AddCommand(showDefaultCustomDomainCmd(cli))
cmd.AddCommand(setDefaultCustomDomainCmd(cli))

return cmd
}

func showDefaultCustomDomainCmd(cli *cli) *cobra.Command {
cmd := &cobra.Command{
Use: "show",
Args: cobra.NoArgs,
Short: "Show the default custom domain",
Long: "Display the default custom domain configuration for the tenant.",
Example: ` auth0 domains default show
auth0 domains default show --json
auth0 domains default show --json-compact`,
RunE: func(cmd *cobra.Command, args []string) error {
var defaultDomain *management.CustomDomainDefault

if err := ansi.Waiting(func() (err error) {
defaultDomain, err = cli.api.CustomDomain.ReadDefault(cmd.Context())
return err
}); err != nil {
return fmt.Errorf("failed to read default custom domain: %w", err)
}

cli.renderer.CustomDomainDefaultShow(defaultDomain)

return nil
},
}

cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
cmd.Flags().BoolVar(&cli.jsonCompact, "json-compact", false, "Output in compact json format.")

return cmd
}

func setDefaultCustomDomainCmd(cli *cli) *cobra.Command {
var inputs struct {
Domain string
}

cmd := &cobra.Command{
Use: "set",
Args: cobra.MaximumNArgs(1),
Short: "Set the default custom domain",
Long: "Set the default custom domain for the tenant.\n\n" +
"To set interactively, use `auth0 domains default set` with no arguments.\n\n" +
"To set non-interactively, supply the domain name as an argument or through the flag.",
Example: ` auth0 domains default set
auth0 domains default set <domain>
auth0 domains default set --domain <domain>
auth0 domains default set --domain <domain> --json`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
inputs.Domain = args[0]
}

if inputs.Domain == "" {
if err := customDomainDomain.Pick(cmd, &inputs.Domain, cli.customDomainNamePickerOptions); err != nil {
return err
}
}

defaultDomain := &management.CustomDomainDefault{
Domain: &inputs.Domain,
}

if err := ansi.Waiting(func() error {
return cli.api.CustomDomain.UpdateDefault(cmd.Context(), defaultDomain)
}); err != nil {
return fmt.Errorf("failed to set default custom domain to %q: %w", inputs.Domain, err)
}

cli.renderer.CustomDomainDefaultUpdate(defaultDomain)

return nil
},
}

customDomainDomain.RegisterString(cmd, &inputs.Domain, "")
cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
cmd.Flags().BoolVar(&cli.jsonCompact, "json-compact", false, "Output in compact json format.")

return cmd
}

func apiVerificationMethodFor(v string) *string {
switch v {
case "txt":
Expand Down Expand Up @@ -565,3 +661,32 @@ func (c *cli) customDomainsPickerOptions(ctx context.Context) (pickerOptions, er

return opts, nil
}

func (c *cli) customDomainNamePickerOptions(ctx context.Context) (pickerOptions, error) {
var opts pickerOptions

domains, err := c.api.CustomDomain.List(ctx)
if err != nil {
var errStatus management.Error
errors.As(err, &errStatus)
// 403 is a valid response for free tenants that don't have
// custom domains enabled.
if errStatus != nil && errStatus.Status() == 403 {
return nil, errNoCustomDomains
}

return nil, fmt.Errorf("failed to list custom domains: %w", err)
}

for _, d := range domains {
domain := d.GetDomain()
label := fmt.Sprintf("%s %s", domain, ansi.Faint("("+d.GetID()+")"))
opts = append(opts, pickerOption{value: domain, label: label})
}

if len(opts) == 0 {
return nil, errNoCustomDomains
}

return opts, nil
}
Loading
Loading