usso

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: LGPL-3.0 Imports: 13 Imported by: 21

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProductionUbuntuSSOServer = UbuntuSSOServer{"https://login.ubuntu.com", "https://one.ubuntu.com/oauth/sso-finished-so-get-tokens/"}

ProductionUbuntuSSOServer represents the production Ubuntu SSO server located at https://login.ubuntu.com.

View Source
var StagingUbuntuSSOServer = UbuntuSSOServer{"https://login.staging.ubuntu.com", "https://one.staging.ubuntu.com/oauth/sso-finished-so-get-tokens/"}

StagingUbuntuSSOServer represents the staging Ubuntu SSO server located at https://login.staging.ubuntu.com. Use it for testing.

Functions

func GetAuthorizationHeader

func GetAuthorizationHeader(
	ssodata *SSOData, rp *RequestParameters) (string, error)

Given oauth credentials return a valid http authorization header.

func NormalizeParameters

func NormalizeParameters(parameters url.Values) (string, error)

Normalize the parameters in the query string according to http://tools.ietf.org/html/rfc5849#section-3.4.1.3.2. url.Values.Encode encoded the GET parameters in a consistent order we do the encoding ourselves.

func NormalizeURL

func NormalizeURL(inputUrl string) (string, error)

Normalize the URL according to OAuth specs.

func SignRequest

func SignRequest(
	ssodata *SSOData, rp *RequestParameters, request *http.Request) error

Given oauth credentials and a request, return it signed.

Types

type Error

type Error struct {
	Message string                 `json:"message"`
	Code    string                 `json:"code,omitempty"`
	Extra   map[string]interface{} `json:"extra,omitempty"`
}

Error represents an error message returned from Ubuntu SSO.

func (*Error) Error

func (err *Error) Error() string

Error implements error.Error.

type HMACSHA1

type HMACSHA1 struct{}

func (HMACSHA1) Name

func (HMACSHA1) Name() string

Return the name of the signature method, used to compose the Authentication Header.

func (HMACSHA1) Signature

func (HMACSHA1) Signature(
	ssodata *SSOData, rp *RequestParameters) (string, error)

Calculate the oaut_signature part of the Authentication Header.

type PLAINTEXT

type PLAINTEXT struct{}

func (PLAINTEXT) Name

func (PLAINTEXT) Name() string

Return the name of the signature method, used to compose the Authentication Header.

func (PLAINTEXT) Signature

func (PLAINTEXT) Signature(
	ssodata *SSOData, rp *RequestParameters) (string, error)

Calculate the oaut_signature part of the Authentication Header.

type RequestParameters

type RequestParameters struct {
	HTTPMethod      string
	BaseURL         string
	Params          url.Values
	Nonce           string
	Timestamp       string
	SignatureMethod SignatureMethod
}

type SSOData

type SSOData struct {
	ConsumerKey    string `json:"consumer_key"`
	ConsumerSecret string `json:"consumer_secret"`
	Realm          string `json:"realm"`
	TokenKey       string `json:"token_key"`
	TokenName      string `json:"token_name"`
	TokenSecret    string `json:"token_secret"`
}

Contains the oauth data to perform a request.

func (*SSOData) GetAuthorizationHeader

func (ssodata *SSOData) GetAuthorizationHeader(
	rp *RequestParameters) (string, error)

Sign the provided request.

func (*SSOData) SignRequest

func (ssodata *SSOData) SignRequest(
	rp *RequestParameters, req *http.Request) error

Sign the provided request.

type SignatureMethod

type SignatureMethod interface {
	Name() string
	Signature(
		ssodata *SSOData, rp *RequestParameters) (string, error)
}

type UbuntuSSOServer

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

func (UbuntuSSOServer) AccountsURL

func (server UbuntuSSOServer) AccountsURL() string

AccountURL returns the URL where the Ubuntu SSO account information can be requested.

func (UbuntuSSOServer) GetAccounts

func (server UbuntuSSOServer) GetAccounts(ssodata *SSOData) (string, error)

Returns all the Ubuntu SSO information related to this account.

func (UbuntuSSOServer) GetToken

func (server UbuntuSSOServer) GetToken(email string, password string, tokenName string) (*SSOData, error)

Giving user credentials and token name, retrieves oauth credentials for the users, the oauth credentials can be used later to sign requests. If an error is returned from the identity server then it will be of type *Error.

func (UbuntuSSOServer) GetTokenDetails

func (server UbuntuSSOServer) GetTokenDetails(ssodata *SSOData) (string, error)

Returns all the Ubuntu SSO information related to this token.

func (UbuntuSSOServer) GetTokenWithOTP

func (server UbuntuSSOServer) GetTokenWithOTP(email, password, otp, tokenName string) (*SSOData, error)

GetTokenWithOTP retrieves an oauth token from the Ubuntu SSO server. Using the user credentials including two-factor authentication and the token name, an oauth token is retrieved that can later be used to sign requests. If an error is returned from the identity server then it will be of type *Error. If otp is blank then this is identical to GetToken.

func (UbuntuSSOServer) IsTokenValid

func (server UbuntuSSOServer) IsTokenValid(ssodata *SSOData) (bool, error)

Verify the validity of the token, abusing the API to get the token details.

func (UbuntuSSOServer) LoginURL

func (server UbuntuSSOServer) LoginURL() string

LoginURL returns the URL for the interactive login.

func (UbuntuSSOServer) OpenIDURL

func (server UbuntuSSOServer) OpenIDURL() string

OpenIDURL returns the URL of the OpenID login endpoint.

func (UbuntuSSOServer) TokenDetailsURL

func (server UbuntuSSOServer) TokenDetailsURL() string

TokenDetailURL returns the URL where the Ubuntu SSO token details can be requested.

Directories

Path Synopsis
Package openid contains functions to help log-in to Ubuntu SSO using OpenID 2.0.
Package openid contains functions to help log-in to Ubuntu SSO using OpenID 2.0.
example
Example web application that performs an OpenID login to Ubuntu SSO.
Example web application that performs an OpenID login to Ubuntu SSO.

Jump to

Keyboard shortcuts

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