Documentation ¶
Overview ¶
Package ussologin defines functionality used for allowing clients to authenticate with the IDM server using USSO OAuth.
Index ¶
- func GetToken(filler form.Filler, tokenName string) (*usso.SSOData, error)
- func LoginWithToken(client *http.Client, ussoAuthUrl string, tok *usso.SSOData) error
- func VisitWebPage(tokenName string, client *http.Client, filler form.Filler, store TokenStore) func(*url.URL) error
- type FileTokenStore
- type TokenStore
- type Visitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetToken ¶
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 ¶
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.
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 ¶
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.