Documentation ¶
Index ¶
- Variables
- func GetAuthorizationHeader(ssodata *SSOData, rp *RequestParameters) (string, error)
- func NormalizeParameters(parameters url.Values) (string, error)
- func NormalizeURL(inputUrl string) (string, error)
- func SignRequest(ssodata *SSOData, rp *RequestParameters, request *http.Request) error
- type Error
- type HMACSHA1
- type PLAINTEXT
- type RequestParameters
- type SSOData
- type SignatureMethod
- type UbuntuSSOServer
- func (server UbuntuSSOServer) AccountsURL() string
- func (server UbuntuSSOServer) GetAccounts(ssodata *SSOData) (string, error)
- func (server UbuntuSSOServer) GetToken(email string, password string, tokenName string) (*SSOData, error)
- func (server UbuntuSSOServer) GetTokenDetails(ssodata *SSOData) (string, error)
- func (server UbuntuSSOServer) GetTokenWithOTP(email, password, otp, tokenName string) (*SSOData, error)
- func (server UbuntuSSOServer) IsTokenValid(ssodata *SSOData) (bool, error)
- func (server UbuntuSSOServer) LoginURL() string
- func (server UbuntuSSOServer) OpenIDURL() string
- func (server UbuntuSSOServer) TokenDetailsURL() string
Constants ¶
This section is empty.
Variables ¶
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.
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 ¶
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 ¶
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.
type HMACSHA1 ¶
type HMACSHA1 struct{}
type PLAINTEXT ¶
type PLAINTEXT struct{}
type RequestParameters ¶
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. |