auth

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 7 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

Package auth provides tokens for calls to other services (SEC-03, CLI-10).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expiry

func Expiry(token string) (time.Time, bool)

Expiry reads the exp claim of a token without verifying it; false if there is none.

func UnsignedToken

func UnsignedToken(userId string, roles ...string) string

UnsignedToken builds a token without signature. It is accepted only by services that do not verify signatures: the in-process test client, and permissions-v2 when a user's resources are listed for the deletion of that user, as device-repository does.

func UnsignedTokens

func UnsignedTokens(userId string) (string, error)

UnsignedTokens returns unsigned tokens of users with the role "user"; for tests.

Types

type TokenExchange

type TokenExchange struct {
	// contains filtered or unexported fields
}

TokenExchange gets tokens of other users through Keycloak token exchange, so that work on behalf of an owner runs with the owner's rights (SEC-06). Tokens are cached until shortly before they expire.

func NewTokenExchange

func NewTokenExchange(endpoint string, clientId string, clientSecret string) *TokenExchange

func (*TokenExchange) Token

func (this *TokenExchange) Token(userId string) (string, error)

type TokenSource

type TokenSource func() (string, error)

TokenSource returns a token including the "Bearer " prefix.

func ClientCredentials

func ClientCredentials(endpoint string, clientId string, clientSecret string) TokenSource

ClientCredentials gets and refreshes a token of a Keycloak client; endpoint is the Keycloak base URL, e.g. http://keycloak:8080.

func Static

func Static(token string) TokenSource

Static returns a fixed token; for tests.

type UserTokenSource

type UserTokenSource func(userId string) (string, error)

UserTokenSource returns a token of a user including the "Bearer " prefix.

Jump to

Keyboard shortcuts

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