ussodischarge

package
v1.0.0-...-203d207 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2018 License: LGPL-3.0 Imports: 9 Imported by: 2

Documentation

Overview

Package ussomacaroon provides a client that can authenticate with an identity server by discharging macaroons on an Ubuntu SSO server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Macaroon

func Macaroon(ctx context.Context, doer httprequest.Doer, url string) (*bakery.Macaroon, error)

Macaroon returns a macaroon from the identity provider at the given URL that can be discharged using a Discharger. If doer is non-nil then it will be used to collect the macaroon.

func SetInteraction

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

Types

type Discharger

type Discharger struct {
	// Email contains the email address of the user.
	Email string

	// Password contains the password of the user.
	Password string

	// OTP contains the verification code of the user.
	OTP string

	// Doer will be used to perform the discharge if non-nil.
	Doer httprequest.Doer
}

Discharger is a client that can discharge Ubuntu SSO third-party caveats.

func (*Discharger) AcquireDischarge

func (d *Discharger) AcquireDischarge(ctx context.Context, cav macaroon.Caveat, payload []byte) (*bakery.Macaroon, error)

AcquireDischarge discharges the given Ubuntu SSO third-party caveat using the user information from the Discharger.

func (*Discharger) DischargeAll

func (d *Discharger) DischargeAll(ctx context.Context, m *bakery.Macaroon) (macaroon.Slice, error)

DischargeAll discharges the given macaroon which is assumed to only have third-party caveats addressed to an Ubuntu SSO server.

type Interactor

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

Interactor is an httpbakery.Interactor that will login using a macaroon discharged by an Ubuntu SSO service.

func NewInteractor

func NewInteractor(f func(client *httpbakery.Client, url string) (macaroon.Slice, error)) *Interactor

NewInteractor creates an Interactor which uses a macaroon previously collected with Macaroon and discharged by the requisit Ubuntu SSO service to log in. The discharged macaroon to use will be requested from the given function when required.

func (*Interactor) Interact

func (i *Interactor) Interact(ctx context.Context, client *httpbakery.Client, location string, ierr *httpbakery.Error) (*httpbakery.DischargeToken, error)

func (*Interactor) Kind

func (i *Interactor) Kind() string

func (*Interactor) LegacyInteract

func (i *Interactor) LegacyInteract(ctx context.Context, client *httpbakery.Client, location string, visitURL *stdurl.URL) error

LegacyInteract implements httpbakery.LegacyInteractor for the Interactor.

type Login

type Login struct {
	Macaroons macaroon.Slice `json:"macaroons,omitempty"`
}

Login is the body of a LoginRequest.

type LoginRequest

type LoginRequest struct {
	httprequest.Route `httprequest:"POST"`
	Login             Login `httprequest:",body"`
}

LoginRequest is a request to log in using a macaroon that has been discharged by an Ubuntu SSO service.

type LoginResponse

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

LoginResponse is the response to a LoginReuest.

type MacaroonResponse

type MacaroonResponse struct {
	Macaroon *bakery.Macaroon `json:"macaroon,omitempty"`
}

MacaroonResponse is the response from a GET to a usso-macaroon identity provider, it will be a macaroon with a third party discharge addressed to an Ubuntu SSO service.

Jump to

Keyboard shortcuts

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