authmgr

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package authmgr provides simple interface for Google oauth2 authentication for console applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenBrowser

func OpenBrowser(url string) (err error)

OpenBrowser attempts to open browser.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is authorization manager

func New

func New(config *oauth2.Config, opts ...Option) (*Manager, error)

New creates a new instance of Manager from oauth.Config

func NewFromEnv

func NewFromEnv(idKey, secretKey string, scopes []string, opts ...Option) (*Manager, error)

NewFromEnv creates manager from environment variables.

func NewFromGoogleCreds

func NewFromGoogleCreds(filename string, scopes []string, opts ...Option) (*Manager, error)

NewFromGoogleCreds creates manager from a credentials file

func (*Manager) Client

func (m *Manager) Client() (*http.Client, error)

Client returns authenticated client.

func (*Manager) Config

func (m *Manager) Config() *oauth2.Config

Config returns oauth2 config.

func (*Manager) Handlers

func (m *Manager) Handlers(tokenChan chan<- *oauth2.Token) http.Handler

Handlers registers authentication handling routes.

func (*Manager) Token

func (m *Manager) Token() (*oauth2.Token, error)

Token return oauth2 token.

type Option

type Option func(*Manager) error

Option sets option variables.

func OptAppName

func OptAppName(vendor, name string) Option

OptAppName sets the application name.

func OptListenerAddr

func OptListenerAddr(addr string) Option

OptListenerAddr sets the template directory for templates.

func OptResetAuth

func OptResetAuth() Option

OptResetAuth resets the token and forces reauthentication.

func OptTemplateDir

func OptTemplateDir(dir string) Option

OptTemplateDir sets the template directory for templates (and loads the templates).

func OptTryWebAuth

func OptTryWebAuth(b bool, rootPath string, redirectURLBase string) Option

OptTryWebAuth sets the flag to attempt to present user with browser for authentication. Otherwise - console login is used.

func OptUseIndexPage

func OptUseIndexPage(b bool) Option

OptUseIndexPage sets the optional index page display prior to redirecting to Oauth provider scopes permission page.

Jump to

Keyboard shortcuts

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