Auth

package
v0.0.0-...-02f173f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2025 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const ErrNoToken = "Token not found"
View Source
const ErrUpdate = "Unable to update config: %s"
View Source
const MsgGetToken = "Access token: (%s) %s"
View Source
const MsgNewToken = "New token: (%s) %s"
View Source
const MsgRevokeToken = "Access token was revoked"

Variables

View Source
var Command = &cli.Command{
	Name:      "auth",
	Usage:     "Manage credentials for the OneSky CLI",
	UsageText: "onesky [global options] auth <command> [options]",
	Description: "Authorize to access the OneSky API with access token: \n" +
		"			onesky auth login --access-token=some-token-string --access-type=Bearer\n\n" +
		"   List credentialed access token: \n" +
		"			onesky auth list\n\n" +
		"	Revoke access credential: \n" +
		"			onesky auth revoke\n",
	ArgsUsage:       "{login|list|revoke}",
	HideHelpCommand: true,

	Subcommands: []*cli.Command{

		SubcommandLogin,
		SubcommandList,
		SubcommandRevoke,
	},

	OnUsageError: func(c *cli.Context, err error, isSubcommand bool) error {
		_, _ = fmt.Fprintf(c.App.Writer, "for shame\n")
		return err
	},
}
View Source
var SubcommandList = &cli.Command{
	Name:        "list",
	Action:      List,
	Description: "List credentialed access token",
	Usage:       "List credentialed access token",
	UsageText:   "onesky auth list [options]",
}
View Source
var SubcommandLogin = &cli.Command{
	Name:        "login",
	Action:      Login,
	Description: "Authorize to access the OneSky API with access token",
	Usage:       "Authorize to access the OneSky API with access token",
	UsageText:   "onesky auth login --access-token=ACCESS_TOKEN [--access-type=TYPE]",
	Flags: []cli.Flag{
		SubcommandLoginFlagAccessToken,
		SubcommandLoginFlagAccessType,
	},
}
View Source
var SubcommandLoginFlagAccessToken = &cli.StringFlag{
	Name:     "access-token",
	Usage:    "Set `ACCESS_TOKEN`",
	Required: true,
}
View Source
var SubcommandLoginFlagAccessType = &cli.StringFlag{
	Name:     "access-type",
	Usage:    "Set authorization type `TYPE` ('Bearer', 'Basic', etc.)",
	Required: false,
	Value:    "Bearer",
}
View Source
var SubcommandRevoke = &cli.Command{
	Name:        "revoke",
	Action:      Revoke,
	Description: "Revoke access credential",
	Usage:       "Revoke access credential",
	UsageText:   "onesky auth revoke [options]",
}

Functions

func List

func List(c *cli.Context) (e error)

func Login

func Login(c *cli.Context) (e error)

func Revoke

func Revoke(c *cli.Context) (e error)

Types

type Auth

type Auth interface {
	Login(*cli.Context) error
	List(*cli.Context) error
	Revoke(*cli.Context) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL