robotauth

package
v0.0.0-...-61997fb Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

The robotauth package contains the class for reading and writing the robot-id.json file. This file contains the id & private key of a robot that's connected to a Cloud project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RobotAuth

type RobotAuth struct {
	RobotName           string `json:"id"`
	ProjectId           string `json:"project_id"`
	PublicKeyRegistryId string `json:"public_key_registry_id"`
	PrivateKey          []byte `json:"private_key"`
	Domain              string `json:"domain"`
}

Object containing ID, as stored in robot-id.json.

func LoadFromFile

func LoadFromFile(keyfile string) (*RobotAuth, error)

LoadFromFile loads key from json file. If keyfile is "", it tries to load from the default location.

func LoadFromK8sSecret

func LoadFromK8sSecret(ctx context.Context, clientset kubernetes.Interface, namespace string) (*RobotAuth, error)

func (*RobotAuth) CreateJWT

func (r *RobotAuth) CreateJWT(ctx context.Context, lifetime time.Duration) (string, error)

CreateJWT allows to create a JWT for authentication against the token vendor. This does not grant Google Cloud access, but can be used for for explicit authentication with the token vendor.

func (*RobotAuth) CreatePrivateKey

func (r *RobotAuth) CreatePrivateKey() error

CreatePrivateKey creates a private key. The private key is written to the RobotAuth struct.

func (*RobotAuth) CreateRobotTokenSource

func (r *RobotAuth) CreateRobotTokenSource(ctx context.Context) oauth2.TokenSource

CreateRobotTokenSource creates an OAuth2 token source for the token vendor. This token source returns Google Cloud access token minted for the robot-service@ service account.

func (*RobotAuth) StoreInFile

func (r *RobotAuth) StoreInFile() error

StoreInFile writes a newly-chosen ID to disk.

func (*RobotAuth) StoreInK8sSecret

func (r *RobotAuth) StoreInK8sSecret(ctx context.Context, clientset kubernetes.Interface, namespace string) error

StoreInK8sSecret writes new robot-id to kubernetes secret.

Jump to

Keyboard shortcuts

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