ussologin

package
v0.0.0-...-15392b0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2017 License: LGPL-3.0 Imports: 13 Imported by: 9

Documentation

Overview

Package ussologin defines functionality used for allowing clients to authenticate with the IDM server using USSO OAuth.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewInteractor

func NewInteractor(tg TokenGetter) httpbakery.Interactor

NewInteractor creates a new httpbakery.Interactor that interacts using the usso_oauth protocol.

func SetInteraction

func SetInteraction(ierr *httpbakery.Error, url string)

SetInteraction sets the required values for the usso_oauth interaction method on an interaction required error.

Types

type FileTokenStore

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

FileTokenStore implements the TokenStore interface by storing the JSON-encoded oauth token in a file.

func NewFileTokenStore

func NewFileTokenStore(path string) *FileTokenStore

NewFileTokenStore returns a new FileTokenStore that uses the given path for storage.

func (*FileTokenStore) Get

func (f *FileTokenStore) Get() (*usso.SSOData, error)

Get implements TokenStore.Get by reading the token from the FileTokenStore's file.

func (*FileTokenStore) Put

func (f *FileTokenStore) Put(tok *usso.SSOData) error

Put implements TokenStore.Put by writing the token to the FileTokenStore's file. If the file doesn't exist it will be created, including any required directories.

type FormTokenGetter

type FormTokenGetter struct {
	Filler form.Filler
	Name   string
}

A FormTokenGetter is a TokenGetter implementation that presents a form to the user to get login details, and then uses those to get a token from Ubuntu SSO.

func (FormTokenGetter) GetToken

func (g FormTokenGetter) GetToken(ctx context.Context) (*usso.SSOData, error)

GetToken uses filler to interact with the user and uses the provided information to obtain an OAuth token from Ubuntu SSO. The returned token can subsequently be used with LoginWithToken to perform a login. The tokenName argument is used as the name of the generated token in Ubuntu SSO. If Ubuntu SSO returned an error when trying to retrieve the token the error will have a cause of type *usso.Error.

type LoginResponse

type LoginResponse struct {
	DischargeToken *httpbakery.DischargeToken `json:"discharge-token"`
}

A LoginResponse is a response from the login endpoint following a successful interaction.

type StoreTokenGetter

type StoreTokenGetter struct {
	Store       TokenStore
	TokenGetter TokenGetter
}

A StoreTokenGetter is a TokenGetter that will try to retrieve the token from some storage, before falling back to another TokenGetter. If the fallback TokenGetter sucessfully retrieves a token then that token will be put in the store.

func (StoreTokenGetter) GetToken

func (g StoreTokenGetter) GetToken(ctx context.Context) (*usso.SSOData, error)

GetToken implements TokenGetter.GetToken. A token is first attmepted to retireve from the store. If a stored token is not available then GetToken will fallback to TokenGetter.GetToken (if configured).

type TokenGetter

type TokenGetter interface {
	GetToken(context.Context) (*usso.SSOData, error)
}

A TokenGetter is used to fetch a Ubuntu SSO OAuth token.

type TokenStore

type TokenStore interface {
	// Put stores an Ubuntu SSO OAuth token.
	Put(tok *usso.SSOData) error
	// Get returns an Ubuntu SSO OAuth token from store
	Get() (*usso.SSOData, error)
}

TokenStore defines the interface for something that can store and returns oauth tokens.

Jump to

Keyboard shortcuts

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