authorization

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

authorization package contains the abstraction for handling the different authorization methods and manage the tokens retrivial and refresh

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAuthenticator

func NewAuthenticator(config *client.Config, cacheReadWriter client.AuthCacheReadWriter, authConfig client.AuthConfig) client.AuthProvider

Types

type Config

type Config struct {
	// AppID the app id to use for getting the correct authorization from the Mia-Platform console
	AppID string

	// LocalServerBindAddress hostname and port which the local server binds to, you can use the
	// port 0 for allocate the first free port
	LocalServerBindAddress []string

	// Client the http client to use for sending the request
	Client client.Interface

	// ServerReadyHandler function to call when the local server is ready to receive traffic
	ServerReadyHandler LocalServerReadyHandler
}

func (*Config) GetToken

func (c *Config) GetToken(ctx context.Context) (*oauth2.Token, error)

GetToken performs the authorization flow against the Mia-Platform Console This perform the following actions: 1. Send a request for getting the provider id for the configured AppID 2. Start a local server for intercetting the callback 3. Open the browser and start the login flow 4. Wait for the user authorization 5. Exchange the code received via callback 6. Return the oauth2 token

func (*Config) RefreshToken

func (c *Config) RefreshToken(ctx context.Context, refreshToken string) (*oauth2.Token, error)

RefreshToken perform a refresh token request and return an error if something went wrong or the new oauth2 token

type LocalServerReadyHandler

type LocalServerReadyHandler func(string) error

Jump to

Keyboard shortcuts

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