Skip to content

Commit

Permalink
Removing --as-machine flag
Browse files Browse the repository at this point in the history
  • Loading branch information
willvedd committed Dec 7, 2022
1 parent 79b49c0 commit 3c0dd27
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ test-unit: ## Run unit tests
test-integration: $(GO_BIN)/commander ## Run integration tests. To run a specific test pass the FILTER var. Usage: `make test-integration FILTER="attack protection"`
${call print, "Running integration tests"}
@$(MAKE) install # ensure fresh install prior to running test
auth0 login --as-machine --domain ${AUTH0_CLI_CLIENT_DOMAIN} --client-id ${AUTH0_CLI_CLIENT_ID} --client-secret ${AUTH0_CLI_CLIENT_SECRET} && commander test ./test/integration/test-cases.yaml --filter "$(FILTER)"; \
auth0 login --domain ${AUTH0_CLI_CLIENT_DOMAIN} --client-id ${AUTH0_CLI_CLIENT_ID} --client-secret ${AUTH0_CLI_CLIENT_SECRET} && commander test ./test/integration/test-cases.yaml --filter "$(FILTER)"; \
exit_code=$$?; \
bash ./test/integration/scripts/test-cleanup.sh; \
exit $$exit_code
Expand Down
4 changes: 1 addition & 3 deletions docs/auth0_login.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ auth0 login [flags]
```
auth0 login
auth0 login --as-machine
auth0 login --as-machine --domain <TENANT_DOMAIN> --client-id <CLIENT_ID> --client-secret <CLIENT_SECRET>
auth0 login --domain <TENANT_DOMAIN> --client-id <CLIENT_ID> --client-secret <CLIENT_SECRET>
```

### Options

```
--as-machine Initiates authentication as a machine via client credentials (client ID, client secret)
-i, --client-id string Client ID of the application.
-s, --client-secret string Client Secret of the application.
--domain string Specifies tenant domain when authenticating via client credentials (client ID, client secret)
Expand Down
19 changes: 5 additions & 14 deletions internal/cli/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ import (
)

var (
loginAsMachine = Flag{
Name: "Login as machine",
LongForm: "as-machine",
Help: "Initiates authentication as a machine via client credentials (client ID, client secret)",
IsRequired: false,
}
loginTenantDomain = Flag{
Name: "Tenant Domain",
LongForm: "domain",
Expand All @@ -28,10 +22,9 @@ var (
)

type LoginInputs struct {
LoginAsMachine bool
Domain string
ClientID string
ClientSecret string
Domain string
ClientID string
ClientSecret string
}

func loginCmd(cli *cli) *cobra.Command {
Expand All @@ -44,13 +37,12 @@ func loginCmd(cli *cli) *cobra.Command {
Long: "Authenticates the Auth0 CLI either as a user using personal credentials or as a machine using client credentials (client ID/secret).",
Example: `
auth0 login
auth0 login --as-machine
auth0 login --as-machine --domain <TENANT_DOMAIN> --client-id <CLIENT_ID> --client-secret <CLIENT_SECRET>
auth0 login --domain <TENANT_DOMAIN> --client-id <CLIENT_ID> --client-secret <CLIENT_SECRET>
`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()

shouldLoginAsMachine := inputs.LoginAsMachine || inputs.ClientID != "" || inputs.ClientSecret != "" || inputs.Domain != ""
shouldLoginAsMachine := inputs.ClientID != "" || inputs.ClientSecret != "" || inputs.Domain != ""

if shouldLoginAsMachine {
if err := RunLoginAsMachine(ctx, inputs, cli, cmd); err != nil {
Expand All @@ -69,7 +61,6 @@ func loginCmd(cli *cli) *cobra.Command {
},
}

loginAsMachine.RegisterBool(cmd, &inputs.LoginAsMachine, false)
loginTenantDomain.RegisterString(cmd, &inputs.Domain, "")
tenantClientID.RegisterString(cmd, &inputs.ClientID, "")
tenantClientSecret.RegisterString(cmd, &inputs.ClientSecret, "")
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ config:

tests:
login as machine:
command: auth0 logout $AUTH0_CLI_CLIENT_DOMAIN; auth0 login --as-machine --client-id $AUTH0_CLI_CLIENT_ID --client-secret $AUTH0_CLI_CLIENT_SECRET --domain $AUTH0_CLI_CLIENT_DOMAIN
command: auth0 logout $AUTH0_CLI_CLIENT_DOMAIN; auth0 login --client-id $AUTH0_CLI_CLIENT_ID --client-secret $AUTH0_CLI_CLIENT_SECRET --domain $AUTH0_CLI_CLIENT_DOMAIN
stderr: "Successfully authenticated to"
exit-code: 0

Expand Down

0 comments on commit 3c0dd27

Please sign in to comment.