MCPcopy
hub / github.com/cloudfoundry/cli / Execute

Method Execute

command/v7/auth_command.go:25–124  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

23}
24
25func (cmd AuthCommand) Execute(args []string) error {
26 if len(cmd.Origin) > 0 {
27 uaaVersion, err := cmd.Actor.GetUAAAPIVersion()
28 if err != nil {
29 return err
30 }
31
32 err = command.MinimumUAAAPIVersionCheck(uaaVersion, uaaversion.MinUAAClientVersion, "Option '--origin'")
33 if err != nil {
34 return err
35 }
36 }
37
38 if cmd.ClientCredentials && cmd.Origin != "" {
39 return translatableerror.ArgumentCombinationError{
40 Args: []string{"--client-credentials", "--origin"},
41 }
42 }
43
44 username, password, err := cmd.getUsernamePassword()
45 if err != nil {
46 return err
47 }
48
49 cmd.UI.DisplayTextWithFlavor(
50 "API endpoint: {{.Endpoint}}",
51 map[string]interface{}{
52 "Endpoint": cmd.Config.Target(),
53 })
54
55 versionWarning, err := shared.CheckCCAPIVersion(cmd.Config.APIVersion())
56 if err != nil {
57 cmd.UI.DisplayWarning("Warning: unable to determine whether targeted API's version meets minimum supported.")
58 }
59 if versionWarning != "" {
60 cmd.UI.DisplayWarning(versionWarning)
61 }
62
63 if !cmd.ClientCredentials {
64 if cmd.Config.UAAGrantType() == string(constant.GrantTypeClientCredentials) {
65 return translatableerror.PasswordGrantTypeLogoutRequiredError{}
66 } else if (cmd.Assertion == "" && cmd.Config.UAAOAuthClient() != "cf") || cmd.Config.UAAOAuthClientSecret() != "" {
67 return translatableerror.ManualClientCredentialsError{}
68 }
69 }
70
71 cmd.UI.DisplayNewline()
72
73 cmd.UI.DisplayText("Authenticating...")
74
75 credentials := make(map[string]string)
76 grantType := constant.GrantTypePassword
77 if cmd.ClientCredentials {
78 grantType = constant.GrantTypeClientCredentials
79 if cmd.Assertion != "" {
80 if username == "" {
81 username = cmd.Config.UAAOAuthClient()
82 }

Callers

nothing calls this directly

Calls 15

getUsernamePasswordMethod · 0.95
CheckCCAPIVersionFunction · 0.92
GetUAAAPIVersionMethod · 0.65
DisplayTextWithFlavorMethod · 0.65
TargetMethod · 0.65
APIVersionMethod · 0.65
DisplayWarningMethod · 0.65
UAAGrantTypeMethod · 0.65
UAAOAuthClientMethod · 0.65
UAAOAuthClientSecretMethod · 0.65
DisplayNewlineMethod · 0.65

Tested by

no test coverage detected