token

package
v0.97.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package token obtains, caches, and provides an ID token to authenticate to the holos api server.

Index

Constants

This section is empty.

Variables

View Source
var CacheDir = expandHomedir(filepath.Join("~", ".holos", "cache"))

Functions

func NewClient

func NewClient(cfg *Config) *http.Client

Client returns a http.Client which adds the authorization bearer token to each request.

Types

type Claims

type Claims struct {
	Email string `json:"email"`
	Name  string `json:"name"`
}

type Config

type Config struct {
	Issuer       string
	ClientID     string
	Scopes       stringSlice
	ExtraScopes  stringSlice
	ForceRefresh bool
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig() *Config

NewConfig returns a Config with default values.

func (*Config) FlagSet

func (c *Config) FlagSet() *flag.FlagSet

type Token

type Token struct {
	// Bearer is the oidc token for the authorization: bearer header
	Bearer string
	// Expiry is the expiration time of the id token
	Expiry time.Time
	// Pretty is the JSON encoding of the token claims
	Pretty string
	// contains filtered or unexported fields
}

Token represents an authorization bearer token. Token is useful as an output dto of the Tokener service use case.

func Get

func Get(ctx context.Context, log *slog.Logger, cfg *Config) (*Token, error)

Get returns an oidc token for use as an authorization bearer http header.

func (Token) Claims

func (t Token) Claims() *Claims

Jump to

Keyboard shortcuts

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