token

package
v0.0.0-...-5eda4f8 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package token provides functions to save and load tokens from disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheAuthInfo

func CacheAuthInfo(path string, token AuthCachedInfo) (err error)

CacheAuthInfo saves the token to the given path.

func CleanupOldEncryptedToken

func CleanupOldEncryptedToken(path string)

CleanupOldEncryptedToken removes the old encrypted token file at the given path and its parent directories if they are empty.

func UseOldEncryptedToken

func UseOldEncryptedToken(passwordPath, tokenPath, oldEncryptedTokenPath string) (bool, error)

UseOldEncryptedToken checks if the password file or the old encrypted token file exists. It returns false if the password file exists, true if only the old encrypted token file exists, and an error if neither exists.

Types

type AuthCachedInfo

type AuthCachedInfo struct {
	Token            *oauth2.Token
	ExtraFields      map[string]interface{}
	RawIDToken       string
	ProviderMetadata map[string]interface{}
	UserInfo         info.User
}

AuthCachedInfo represents the token that will be saved on disk for offline authentication.

func LoadAuthInfo

func LoadAuthInfo(path string) (AuthCachedInfo, error)

LoadAuthInfo reads the token from the given path.

func LoadOldEncryptedAuthInfo

func LoadOldEncryptedAuthInfo(path, password string) (AuthCachedInfo, error)

LoadOldEncryptedAuthInfo reads the token in the old encrypted format from the given path and decrypts it using the given password. It's used for backward compatibility.

func NewAuthCachedInfo

func NewAuthCachedInfo(token *oauth2.Token, rawIDToken string, provider providers.Provider) AuthCachedInfo

NewAuthCachedInfo creates a new AuthCachedInfo. It sets the provided token and rawIDToken and the provider-specific extra fields which should be stored persistently.

Jump to

Keyboard shortcuts

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