credentialstype

package
v0.258.0 Latest Latest
Warning

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

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

Documentation

Overview

Package credentialstype defines the CredType used for specifying the type of JSON credentials.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCredentialType

func CheckCredentialType(b []byte, expected CredType, allowed ...CredType) error

CheckCredentialType checks if the provided JSON bytes match the expected credential type and, if present, one of the allowed credential types. An error is returned if the JSON is invalid, the type field is missing, or the types do not match expected and (if present) allowed.

Types

type CredType

type CredType string

CredType specifies the type of JSON credentials.

const (
	// Unknown represents an unknown JSON file type.
	Unknown CredType = ""
	// ServiceAccount represents a service account file type.
	ServiceAccount CredType = "service_account"
	// AuthorizedUser represents an authorized user credentials file type.
	AuthorizedUser CredType = "authorized_user"
	// ImpersonatedServiceAccount represents an impersonated service account file type.
	//
	// IMPORTANT:
	// This credential type does not validate the credential configuration. A security
	// risk occurs when a credential configuration configured with malicious urls
	// is used.
	// You should validate credential configurations provided by untrusted sources.
	// See [Security requirements when using credential configurations from an external
	// source] https://cloud.google.com/docs/authentication/external/externally-sourced-credentials
	// for more details.
	ImpersonatedServiceAccount CredType = "impersonated_service_account"
	// ExternalAccount represents an external account file type.
	//
	// IMPORTANT:
	// This credential type does not validate the credential configuration. A security
	// risk occurs when a credential configuration configured with malicious urls
	// is used.
	// You should validate credential configurations provided by untrusted sources.
	// See [Security requirements when using credential configurations from an external
	// source] https://cloud.google.com/docs/authentication/external/externally-sourced-credentials
	// for more details.
	ExternalAccount CredType = "external_account"
	// GDCHServiceAccount represents a GDCH service account file type.
	GDCHServiceAccount CredType = "gdc_service_account"
	// ExternalAccountAuthorizedUser represents an external account authorized user file type.
	ExternalAccountAuthorizedUser CredType = "external_account_authorized_user"
)

func GetCredType

func GetCredType(data []byte) (CredType, error)

GetCredType returns the credentials type or the Unknown type, or an error for empty data or failure to unmarshal JSON.

Jump to

Keyboard shortcuts

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