ussologin

package
v0.0.0-...-88f418e Latest Latest
Warning

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

Go to latest
Published: May 13, 2016 License: LGPL-3.0 Imports: 12 Imported by: 0

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 GetToken

func GetToken(filler form.Filler, tokenName string) (*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.

func LoginWithToken

func LoginWithToken(client *http.Client, ussoAuthUrl string, tok *usso.SSOData) error

LoginWithToken completes a login attempt using tok. The ussoAuthURL should have been obtained from the UbuntuSSOOAuth field in a response to a LoginMethods request from the target service.

func VisitWebPage

func VisitWebPage(tokenName string, client *http.Client, filler form.Filler, store TokenStore) func(*url.URL) error

VisitWebPage returns a function which will allow authentication via USSO OAuth. If UbuntuSSO OAuth login is not available then this function falls back to httpbakery.OpenWebBrowser. The user will be prompted for username, password and any two factor authentication code via the command line. Existing oauth tokens can be obtained, or new ones stored If non-nil, the given TokenStore is used to store the oauth token obtained during the login process so that less interaction may be required in future.

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 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.

type Visitor

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

Visitor is an httpbakery.Visitor that will login using Ubuntu SSO OAuth if it is supported by the discharger.

func NewVisitor

func NewVisitor(tokenName string, filler form.Filler, store TokenStore) *Visitor

NewVisitor creates a new Visitor that will attempt to interact using an Ubuntu SSO OAuth token. If there is a token stored in store then that will be used. Otherwise filler will be used to ineract with the user and the credentials will be sent to Ubuntu SSO to create a token named tokenName. That token will be stored in store if possible and used to interact with the discharger.

func (*Visitor) VisitWebPage

func (v *Visitor) VisitWebPage(client *httpbakery.Client, methodURLs map[string]*url.URL) error

VisitWebPage implements httpbakery.Visitor.VisitWebPage by attempting to obtain an Ubuntu SSO OAuth token and use that to sign a request to the identity manager. If Ubuntu SSO returns an error when attempting to obtain the token the error returned will have a cause of type *usso.Error.

Jump to

Keyboard shortcuts

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