cliauthtoken

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 11 Imported by: 0

README

cliauthtoken - simple CLI token handing

Allows to either start a local callback server waiting for the users browser to redirect to localhost sending the token or prints a URL and waits for user to paste the token in

Documentation

Index

Constants

View Source
const AuthRequestCallbackParameter = "redirect"
View Source
const AuthRequestCopyParameter = "sessioncopy"
View Source
const AuthRequestCopyParameterValue = "true"
View Source
const CallbackPath = "/"
View Source
const CallbackQueryParameter = "session"
View Source
const CallbackSuccessPage = `` /* 236-byte string literal not displayed */

Variables

View Source
var PromptOpenBrowserURL = "You will now be taken to your browser for authentication. Or browse this URL {{.url}}\n"
View Source
var PromptPasteToken = "Please paste the displayed token"
View Source
var PromptPleaseOpen = "Please open {{.url}} in your Browser\n"

Functions

func DefaultAuthRequestCallbackParameterValueFunc

func DefaultAuthRequestCallbackParameterValueFunc(listener net.Listener) string

DefaultAuthRequestCallbackParameterValueFunc build the callback parameter from net.Listener example: "http://127.0.0.1:12345"

Types

type AuthRequestCallbackValueFunc

type AuthRequestCallbackValueFunc func(net.Listener) string

AuthRequestCallbackValueFunc gets the net.Listener from callback server and returns the callback parameter value

type CLIAuthToken

type CLIAuthToken struct {
	// AuthRequestURL is the url to be opened in users browser
	AuthRequestURL string
	// AuthRequestCopyParameter is the parameter to signal the auth server to show
	// copy paste dialog
	AuthRequestCopyParameter string
	// AuthRequestCopyParameterValue
	AuthRequestCopyParameterValue string
	// The AuthRequestCallbackParameter defining the url parameter for redirect callback
	AuthRequestCallbackParameter string
	// AuthRequestCallbackParameterValueFunc is a function receiving net.Listener to return
	// a value for `AuthRequestCallbackParameter`.
	// By default DefaultAuthRequestCallbackParameterValueFunc is being used returning the
	// local server URL
	AuthRequestCallbackParameterValueFunc AuthRequestCallbackValueFunc

	// CallbackQueryParameter is the query paramter we expect the token as a value
	CallbackQueryParameter string
	// Use a different path than `/` for expecting the callback
	CallbackPath string
	// Define the returned html after successfull callback.
	CallbackSuccessPage string

	TokenTimeout time.Duration

	// Should be 127.0.0.1
	ListenAddr string
	// Log specifies the logger to be used. `logrus.New()` is default
	Log *log.Logger
}

func NewCLIAuthToken

func NewCLIAuthToken(authRequestURL string) (clia *CLIAuthToken)

NewCLIAuthToken creates a new *CLIAuthToken with defaults

func (*CLIAuthToken) RequestTokenPasteable

func (clia *CLIAuthToken) RequestTokenPasteable() string

func (*CLIAuthToken) RequestTokenRedirected

func (clia *CLIAuthToken) RequestTokenRedirected() string

RequestTokenRedirected starts a local callback server and tries to open the users browser starting the callback procedure

Jump to

Keyboard shortcuts

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