MCPcopy
hub / github.com/smallstep/cli / oauthCmd

Function oauthCmd

command/oauth/cmd.go:351–538  ·  view source on GitHub ↗
(c *cli.Context)

Source from the content-addressed store, hash-verified

349}
350
351func oauthCmd(c *cli.Context) error {
352 opts := &options{
353 Provider: c.String("provider"),
354 Email: c.String("email"),
355 Console: c.Bool("console"),
356 Implicit: c.Bool("implicit"),
357 CallbackListener: c.String("listen"),
358 CallbackListenerURL: c.String("listen-url"),
359 CallbackPath: "/",
360 TerminalRedirect: c.String("redirect-url"),
361 Browser: c.String("browser"),
362 }
363 if err := opts.Validate(); err != nil {
364 return err
365 }
366 if (opts.Provider != "google" || c.IsSet("authorization-endpoint")) && !c.IsSet("client-id") {
367 return errors.New("flag '--client-id' required with '--provider'")
368 }
369
370 isOOBFlow, isDeviceFlow := false, false
371 consoleFlowInput := c.String("console-flow")
372 switch {
373 case strings.EqualFold(consoleFlowInput, "device"):
374 opts.Console = true
375 opts.ConsoleFlow = deviceConsoleFlow
376 isDeviceFlow = true
377 case strings.EqualFold(consoleFlowInput, "oob"):
378 opts.Console = true
379 opts.ConsoleFlow = oobConsoleFlow
380 isOOBFlow = true
381 case c.IsSet("console-flow"):
382 return errs.InvalidFlagValue(c, "console-flow", consoleFlowInput, "device, oob")
383 case c.Bool("console"):
384 isDeviceFlow = true
385 opts.ConsoleFlow = deviceConsoleFlow
386 }
387
388 var clientID, clientSecret string
389 switch {
390 case opts.Implicit:
391 if !c.Bool("insecure") {
392 return errs.RequiredInsecureFlag(c, "implicit")
393 }
394 if !c.IsSet("client-id") {
395 return errs.RequiredWithFlag(c, "implicit", "client-id")
396 }
397 case isDeviceFlow:
398 clientID = defaultDeviceAuthzClientID
399 clientSecret = defaultDeviceAuthzClientNotSoSecret
400 default:
401 clientID = defaultClientID
402 clientSecret = defaultClientNotSoSecret
403 }
404
405 if c.IsSet("client-id") {
406 clientID = c.String("client-id")
407 clientSecret = c.String("client-secret")
408 }

Callers

nothing calls this directly

Calls 8

ValidateMethod · 0.95
newOauthFunction · 0.85
DoJWTAuthorizationMethod · 0.80
DoDeviceAuthorizationMethod · 0.80
DoManualAuthorizationMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…