MCPcopy Create free account
hub / github.com/cloudfoundry/cli / Authenticate

Method Authenticate

actor/v7action/auth.go:27–53  ·  view source on GitHub ↗
(credentials map[string]string, origin string, grantType constant.GrantType)

Source from the content-addressed store, hash-verified

25}
26
27func (actor defaultAuthActor) Authenticate(credentials map[string]string, origin string, grantType constant.GrantType) error {
28 if (grantType == constant.GrantTypePassword || grantType == constant.GrantTypeJwtBearer) && actor.config.UAAGrantType() == string(constant.GrantTypeClientCredentials) {
29 return actionerror.PasswordGrantTypeLogoutRequiredError{}
30 }
31
32 actor.config.UnsetOrganizationAndSpaceInformation()
33 accessToken, refreshToken, err := actor.uaaClient.Authenticate(credentials, origin, grantType)
34 if err != nil {
35 actor.config.SetTokenInformation("", "", "")
36 return err
37 }
38
39 accessToken = fmt.Sprintf("bearer %s", accessToken)
40 actor.config.SetTokenInformation(accessToken, refreshToken, "")
41
42 if grantType == constant.GrantTypePassword {
43 actor.config.SetUAAGrantType("")
44 } else {
45 actor.config.SetUAAGrantType(string(grantType))
46 }
47
48 if (grantType == constant.GrantTypeClientCredentials || grantType == constant.GrantTypeJwtBearer) && credentials["client_id"] != "" {
49 actor.config.SetUAAClientCredentials(credentials["client_id"], "")
50 }
51
52 return nil
53}
54
55func (actor defaultAuthActor) GetLoginPrompts() (map[string]coreconfig.AuthPrompt, error) {
56 rawPrompts, err := actor.uaaClient.GetLoginPrompts()

Callers

nothing calls this directly

Calls 6

UAAGrantTypeMethod · 0.65
AuthenticateMethod · 0.65
SetTokenInformationMethod · 0.65
SetUAAGrantTypeMethod · 0.65

Tested by

no test coverage detected