csp

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package csp provide functionality needed to interfact with CSP OAuth provider

Package csp provides VMware Cloud Services Platform token utilities.

Index

Constants

View Source
const (
	// StgIssuer is the VMware CSP(VCSP) staging issuer.
	StgIssuer = "https://console-stg.cloud.vmware.com/csp/gateway/am/api"

	// ProdIssuer is the VMware CSP(VCSP) issuer.
	ProdIssuer = "https://console.cloud.vmware.com/csp/gateway/am/api"

	// StgIssuerTCSP is the Tanzu CSP (TCSP) staging issuer.
	StgIssuerTCSP = "https://console-stg.tanzu.broadcom.com/csp/gateway/am/api"

	// ProdIssuerTCSP is the Tanzu CSP (TCSP) issuer
	ProdIssuerTCSP = "https://console.tanzu.broadcom.com/csp/gateway/am/api"

	// LocalTPSMIssuer is the test TPSM issuer
	LocalTPSMIssuer = "http://localhost:8080"
)

Variables

View Source
var (
	// DefaultKnownIssuers are known OAuth2 endpoints in each CSP environment.
	DefaultKnownIssuers = map[string]oauth2.Endpoint{
		StgIssuer: {
			AuthURL:   "https://console-stg.cloud.vmware.com/csp/gateway/discovery",
			TokenURL:  "https://console-stg.cloud.vmware.com/csp/gateway/am/api/auth/authorize",
			AuthStyle: oauth2.AuthStyleInHeader,
		},
		ProdIssuer: {
			AuthURL:   "https://console.cloud.vmware.com/csp/gateway/discovery",
			TokenURL:  "https://console.cloud.vmware.com/csp/gateway/am/api/auth/authorize",
			AuthStyle: oauth2.AuthStyleInHeader,
		},
		StgIssuerTCSP: {
			AuthURL:   "https://console-stg.tanzu.broadcom.com/csp/gateway/discovery",
			TokenURL:  "https://console-stg.tanzu.broadcom.com/csp/gateway/am/api/auth/authorize",
			AuthStyle: oauth2.AuthStyleInHeader,
		},
		ProdIssuerTCSP: {
			AuthURL:   "https://console.tanzu.broadcom.com/csp/gateway/discovery",
			TokenURL:  "https://console.tanzu.broadcom.com/csp/gateway/am/api/auth/authorize",
			AuthStyle: oauth2.AuthStyleInHeader,
		},
	}
)

Functions

func GetAccessTokenFromAPIToken

func GetAccessTokenFromAPIToken(apiToken, issuer string) (*common.Token, error)

GetAccessTokenFromAPIToken fetches CSP access token using the API-token.

func GetIssuer

func GetIssuer(staging bool) string

GetIssuer returns the appropriate CSP issuer based on the environment.

func GetIssuerUpdateFlagFromCentralConfig added in v1.4.0

func GetIssuerUpdateFlagFromCentralConfig() bool

GetIssuerUpdateFlagFromCentralConfig gets the issuer update flag (used to update the CLI config file) from Central config as best effort

func GetOrgNameFromOrgID added in v1.2.0

func GetOrgNameFromOrgID(orgID, accessToken, issuer string) (string, error)

GetOrgNameFromOrgID fetches CSP Org Name given the Organization ID.

func GetTokens added in v1.5.0

func GetTokens(refreshOrAPIToken, accessToken, issuer, tokenType string) (*common.Token, error)

GetTokens fetches the CSP access token

func TanzuLogin added in v1.2.0

func TanzuLogin(issuerURL string, opts ...common.LoginOption) (*common.Token, error)

Types

type TanzuCSPMetadata added in v1.4.0

type TanzuCSPMetadata struct {
	IssuerProduction string `json:"issuerProduction" yaml:"issuerProduction"`
	IssuerStaging    string `json:"issuerStaging" yaml:"issuerStaging"`
}

TanzuCSPMetadata to parse the CSP metadata from central config

func GetCSPMetadata added in v1.4.0

func GetCSPMetadata() TanzuCSPMetadata

GetCSPMetadata gets the CSP metadata from central config as best effort, If it fails to get the metadata from central config, it returns the default values

Jump to

Keyboard shortcuts

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