src/server/auth/cmds/cmds.go
func GetAuthTokenCmd(noMetrics, noPortForwarding *bool) *cobra.Command {
	var quiet bool
	getAuthToken := &cobra.Command{
		Use:   "{{alias}} <username>",
		Short: "Get an auth token that authenticates the holder as \"username\"",
		Long: "Get an auth token that authenticates the holder as \"username\"; " +
			"this can only be called by cluster admins",
		Run: cmdutil.RunFixedArgs(1, func(args []string) error {
			subject := args[0]
			c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user")
			if err != nil {
				return fmt.Errorf("could not connect: %v", err)
			}
			defer c.Close()
			resp, err := c.GetAuthToken(c.Ctx(), &auth.GetAuthTokenRequest{
				Subject: subject,
			})
			if err != nil {
				return grpcutil.ScrubGRPC(err)
			}
			if quiet {
				fmt.Println(resp.Token)
			} else {
				fmt.Printf("New credentials:\n  Subject: %s\n  Token: %s\n", resp.Subject, resp.Token)
			}
			return nil
		}),
	}
	getAuthToken.PersistentFlags().BoolVarP(&quiet, "quiet", "q", false, "if "+
		"set, only print the resulting token (if successful). This is useful for "+
		"scripting, as the output can be piped to use-auth-token")
	return cmdutil.CreateAlias(getAuthToken, "auth get-auth-token")
}
func GetAuthTokenCmd(noMetrics, noPortForwarding *bool) *cobra.Command {
	var quiet bool
	getAuthToken := &cobra.Command{
		Use:   "{{alias}} <username>",
		Short: "Get an auth token that authenticates the holder as \"username\"",
		Long: "Get an auth token that authenticates the holder as \"username\"; " +
			"this can only be called by cluster admins",
		Run: cmdutil.RunFixedArgs(1, func(args []string) error {
			subject := args[0]
			c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user")
			if err != nil {
				return fmt.Errorf("could not connect: %v", err)
			}
			defer c.Close()
			resp, err := c.GetAuthToken(c.Ctx(), &auth.GetAuthTokenRequest{
				Subject: subject,
			})
			if err != nil {
				return grpcutil.ScrubGRPC(err)
			}
			if quiet {
				fmt.Println(resp.Token)
			} else {
				fmt.Printf("New credentials:\n  Subject: %s\n  Token: %s\n", resp.Subject, resp.Token)
			}
			return nil
		}),
	}
	getAuthToken.PersistentFlags().BoolVarP(&quiet, "quiet", "q", false, "if "+
		"set, only print the resulting token (if successful). This is useful for "+
		"scripting, as the output can be piped to use-auth-token")
	return cmdutil.CreateAlias(getAuthToken, "auth get-auth-token")
}
func GetAuthTokenCmd ( noMetrics , noPortForwarding * bool ) * cobra . Command { var quiet bool getAuthToken := & cobra . Command { Use : " " , Short : " \" \" " , Long : " \" \" " + " " , Run : cmdutil . RunFixedArgs ( 1 , func ( args [ ] string ) error { subject := args [ 0 ] c , err := client . NewOnUserMachine ( ! * noMetrics , ! * noPortForwarding , " " ) if err != nil { return fmt . Errorf ( " " , err ) } defer c . Close ( ) resp , err := c . GetAuthToken ( c . Ctx ( ) , & auth . GetAuthTokenRequest { Subject : subject , } ) if err != nil { return grpcutil . ScrubGRPC ( err ) } if quiet { fmt . Println ( resp . Token ) } else { fmt . Printf ( " \n \n \n " , resp . Subject , resp . Token ) } return nil } ) , } getAuthToken . PersistentFlags ( ) . BoolVarP ( & quiet , " " , " " , false , " " + " " + " " ) return cmdutil . CreateAlias ( getAuthToken , " " ) }
// GetAuthTokenCmd returns a cobra command that lets a user get a pachyderm
// token on behalf of themselves or another user
GetAuthTokenCmd returns a cobra command that lets a user get a pachyderm token on behalf of themselves or another user