auth

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2025 License: EPL-2.0 Imports: 18 Imported by: 0

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

* 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 (
	// If a JWT only has less than a certain time left before it expires, don't use it.
	// This sets the boundary where tokens about-to-expire are never returned from the cache.
	TOKEN_EXPIRY_BUFFER_MINUTES = 10
)

Variables

View Source
var (
	// Expect the pattern:
	// letters and numbers
	// dashes (-) and underscores (_)
	// + ensures a non-empty string
	// ^ matches the start of the string
	// $ matches the end of the string
	TOKEN_ID_PATTERN *regexp.Regexp = regexp.MustCompile(`^[a-zA-Z0-9-_]+$`)
)

Functions

func DeleteToken added in v0.36.0

func DeleteToken(
	tokenId string,
	apiClient *galasaapi.APIClient,
) error

DeleteToken - performs all the logic to implement the `galasactl auth tokens delete --tokenid xxx` command

func GetTokens added in v0.34.0

func GetTokens(
	apiClient *galasaapi.APIClient,
	console spi.Console,
	loginId string,
) error

GetTokens - performs all the logic to implement the `galasactl auth tokens get` command

func NewAuthenticator added in v0.34.0

func NewAuthenticator(
	apiServerUrl string,
	fileSystem spi.FileSystem,
	galasaHome spi.GalasaHome,
	timeService spi.TimeService,
	env spi.Environment,
	jwtCache JwtCache,
) spi.Authenticator

Types

type JwtCache added in v0.34.0

type JwtCache interface {

	// Adds a jwt to the cache.
	Put(serverApiUrl string, galasaToken string, jwt string) error

	// Returns the jwt if we have one, or "" if not.
	Get(serverApiUrl string, galasaToken string) (jwt string, err error)

	// Clears the jwt if we have one in the cache. ie: Logs out.
	Clear(serverApiUrl string, galasaToken string) error

	// Clears all the cache content.
	ClearAll() error
}

func NewJwtCache added in v0.34.0

func NewJwtCache(
	fileSystem spi.FileSystem,
	galasaHome spi.GalasaHome,
	timeService spi.TimeService,
) JwtCache

Jump to

Keyboard shortcuts

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