authorization

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Copyright © 2022 Flagship Team flagship@abtasty.com

Copyright © 2022 Flagship Team flagship@abtasty.com

Index

Constants

This section is empty.

Variables

View Source
var AuthenticateCmd = &cobra.Command{
	Use:   "authenticate [--grant-type=<grant-type>] [--scope=<scope>] [--expiration=<expiration>]",
	Short: "Generate your access token",
	Long:  `Generate the access token based on your credentials`,
	Run: func(cmd *cobra.Command, args []string) {
		config.SetOptionalsDefault(grantType, scope, expiration)
		token, err := httprequest.HTTPCreateToken(viper.GetString("client_id"), viper.GetString("client_secret"), grantType, scope, expiration)
		if err != nil {
			log.Fatalf("%s", err)
			return
		}
		if token == "" {
			log.Fatal("client_id or client_secret not valid")
			return
		} else {
			fmt.Fprintln(cmd.OutOrStdout(), "Token generated successfully")
		}
		config.WriteToken(config.CredentialsFile, token)
	},
}

AuthenticateCmd represents the authenticate command

View Source
var ConfigureCmd = &cobra.Command{
	Use:   "configure [-i <client-id> | --client-id=<client-id>] [-s <client-secret> | --client-secret=<client-secret>] [-a <account-id> | --account-id=<account-id>] [-e <account-env-id> | --account-environment-id=<account-env-id>]",
	Short: "Set the credentials of your flagship account",
	Long: `Set your credentials (account_id, account_env_id, client_id, client_secret) 
	by managing the file credentials.yaml ($HOME/.flagship/credentials.yaml)
	
	The command create credentials file at $HOME/.flagship/credentials.yaml and write value of flag as key-value pairs.
	`,
	Run: func(cmd *cobra.Command, args []string) {
		config.WriteOptionals(config.CredentialsFile, config.GrantType, config.Scope, config.Expiration)

		if credentialsFile != "" {
			viper.SetConfigFile(credentialsFile)
			viper.ReadInConfig()
		}

		if clientId == "" {
			clientId = viper.GetString("client_id")
		}
		if clientSecret == "" {
			clientSecret = viper.GetString("client_secret")
		}
		if accountId == "" {
			accountId = viper.GetString("account_id")
		}
		if accountEnvId == "" {
			accountEnvId = viper.GetString("account_environment_id")
		}
		if clientId == "" || clientSecret == "" || accountId == "" || accountEnvId == "" {
			log.Fatal("required client-id and client-secret and account-id and account-env-id")
		} else {
			config.WriteCredentials(config.CredentialsFile, clientId, clientSecret, accountId, accountEnvId)
			fmt.Fprintln(cmd.OutOrStdout(), "Credentials wrote successfully")
		}

	},
}

loginCmd represents the login command

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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