oauth

package
v0.0.0-...-610ce61 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoginPath    string = "/auth"
	CallbackPath string = "/callback"
)

Variables

This section is empty.

Functions

func LoadTokenIntoContext

func LoadTokenIntoContext(ctx context.Context) (context.Context, error)

LoadTokenIntoContext creates metadata for authentication to the apiServer with the token from filesystem will return an error, if the Token could not be loaded

func NeedTokenRefresh

func NeedTokenRefresh(t Token) (bool, error)

func SafeTokenToFile

func SafeTokenToFile(t Token) error

SafeTokenToFile will persist a token on filesystem

Types

type Config

type Config struct {
	OAuth2Config *oauth2.Config
	OIDCConfig   *oauth.Config
}

func NewConfig

func NewConfig(ctx context.Context, issuerURL, redirectURL *url.URL, clientID, clientSecret string) (*Config, error)

func (*Config) RefreshToken

func (c *Config) RefreshToken(t Token) (Token, error)

RefreshToken refreshes the token for a given Token

type Server

type Server struct {
	TokenChan chan Token
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ctx context.Context, c *Config, redirectUrl *url.URL) (*Server, error)

func (*Server) Start

func (s *Server) Start(errChan chan error)

Start starts the execution of the oauth server, calling the serve function in a goroutine, so non blocking

func (*Server) Stop

func (s *Server) Stop()

Stop stops the execution of the oauth server

type Token

type Token struct {
	IDToken     string
	OAuth2Token *oauth2.Token
}

func LoadTokenFromFile

func LoadTokenFromFile() (Token, error)

LoadTokenFromFile loads the token. Error is only returned if the token file exists but could not be loaded.

Jump to

Keyboard shortcuts

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