obtainer

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: Apache-2.0 Imports: 4 Imported by: 7

Documentation

Overview

Package obtainer provides an interface for OpenID Connect token obtainment from a provider

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, driver Driver)

Register registers a driver (called by a the driver package)

Types

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewClient

func NewClient(providerName, providerURL, username, password, clientID string) (*Client, error)

func (*Client) Obtain

func (c *Client) Obtain() (tokenString string, err error)

Obtain obtains a new token and returns the token string. If token is already available, it just returns the token string

func (*Client) Renew

func (c *Client) Renew() (tokenString string, err error)

Renew renews the token and returns the token string

func (*Client) Revoke added in v1.2.0

func (c *Client) Revoke() error

Revoke revokes the token

type Conf added in v1.1.0

type Conf struct {
	// Enabled is to toggle obtainer client
	Enabled bool `json:"enabled"`
	// Provider is the authentication provider name
	Provider string `json:"provider"`
	// ProviderURL is the authentication provider URL
	ProviderURL string `json:"providerURL"`
	// ClientID is the authentication client id.
	ClientID string `json:"clientID"`
	// Username is the client's username
	Username string `json:"username"`
	// Password is the client's password
	Password string `json:"password"`
}

Conf is a reference configuration struct for Obtainer

func (Conf) Validate added in v1.1.0

func (c Conf) Validate() error

Validate validates the configuration object

type Driver

type Driver interface {
	// ObtainToken requests a token in exchange for user credentials
	ObtainToken(serverAddr string, username, password, clientID string) (token interface{}, err error)
	// TokenString returns the string part of token object (e.g. access_token, id_token strings)
	TokenString(token interface{}) (tokenString string, err error)
	// RenewToken renews the token (when applicable) using information inside the token (e.g. refresh_token)
	RenewToken(serverAddr string, token interface{}, clientID string) (newToken interface{}, err error)
	// RevokeToken revokes a previously obtained token
	RevokeToken(serverAddr string, token interface{}) error
}

Interface methods to login, obtain Service Ticket, and logout

type Obtainer

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

Obtainer struct

func Setup

func Setup(name, serverAddr string) (*Obtainer, error)

Setup configures and returns the Obtainer

func (*Obtainer) ObtainToken added in v1.2.0

func (o *Obtainer) ObtainToken(username, password, clientID string) (token interface{}, err error)

func (*Obtainer) RenewToken added in v1.2.0

func (o *Obtainer) RenewToken(token interface{}, clientID string) (newToken interface{}, err error)

func (*Obtainer) RevokeToken added in v1.2.0

func (o *Obtainer) RevokeToken(token interface{}) error

func (*Obtainer) TokenString added in v1.2.0

func (o *Obtainer) TokenString(token interface{}) (tokenString string, err error)

Jump to

Keyboard shortcuts

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