auth

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: EPL-2.0 Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

Index

Constants

View Source
const (
	TOKEN_PROPERTY  = "GALASA_TOKEN"
	TOKEN_SEPARATOR = ":"
)
View Source
const (
	TOKEN_EXPIRY_BUFFER_MINUTES = 10
)

Variables

This section is empty.

Functions

func GetAuthProperties

func GetAuthProperties(fileSystem files.FileSystem, galasaHome utils.GalasaHome, env utils.Environment) (galasaapi.AuthProperties, error)

Gets authentication properties from the user's galasactl.properties file or from the environment or a mixture.

func GetAuthenticatedAPIClient

func GetAuthenticatedAPIClient(
	apiServerUrl string,
	fileSystem files.FileSystem,
	galasaHome utils.GalasaHome,
	timeService utils.TimeService,
	env utils.Environment,
) *galasaapi.APIClient

Gets a new authenticated API client, attempting to log in if a bearer token file does not exist

func GetBearerTokenFromTokenJsonFile

func GetBearerTokenFromTokenJsonFile(fileSystem files.FileSystem, galasaHome utils.GalasaHome, timeService utils.TimeService) (string, error)

Gets the JWT from the bearer-token.json file if it exists, errors if the file does not exist or if the token is invalid

func GetJwtFromRestApi

func GetJwtFromRestApi(apiServerUrl string, authProperties galasaapi.AuthProperties) (string, error)

Gets a JSON Web Token (JWT) from the API server's /auth endpoint

func IsBearerTokenValid

func IsBearerTokenValid(bearerTokenString string, timeService utils.TimeService) bool

Checks whether a given bearer token is valid or not, returning true if it is valid and false otherwise

func Login

func Login(apiServerUrl string, fileSystem files.FileSystem, galasaHome utils.GalasaHome, env utils.Environment) error

Login - performs all the logic to implement the `galasactl auth login` command

func Logout

func Logout(fileSystem files.FileSystem, galasaHome utils.GalasaHome) error

func WriteBearerTokenJsonFile

func WriteBearerTokenJsonFile(fileSystem files.FileSystem, galasaHome utils.GalasaHome, jwt string) error

Writes a new bearer-token.json file containing a JWT in the following format:

{
  "jwt": "<bearer-token-here>"
}

Types

type BearerTokenJson

type BearerTokenJson struct {
	Jwt string `json:"jwt"`
}

Jump to

Keyboard shortcuts

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