Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleResponse ¶
HandleResponse logs the response details and exits the process with a status computed from the response status code. The mapping of response status code to exit status is as follows:
401: 1 402 to 500 (other than 403 and 404): 2 403: 3 404: 4 500+: 5
Types ¶
type APIKeySigner ¶
type APIKeySigner struct { // Header is the name of the HTTP header that contains the API key. Header string // Key stores the actual key. Key string // Format is the format used to render the key, defaults to "Bearer %s" Format string }
APIKeySigner implements API Key auth.
func (*APIKeySigner) RegisterFlags ¶
func (s *APIKeySigner) RegisterFlags(app *cobra.Command)
RegisterFlags adds the "--key" and "--key-header" flags to the client tool.
type BasicSigner ¶
type BasicSigner struct { // Username is the basic auth user. Username string // Password is err guess what? the basic auth password. Password string }
BasicSigner implements basic auth.
func (*BasicSigner) RegisterFlags ¶
func (s *BasicSigner) RegisterFlags(app *cobra.Command)
RegisterFlags adds the "--user" and "--pass" flags to the client tool.
type Client ¶
type Client struct { // Client is the underlying http client. *http.Client // Scheme overrides the default action scheme. Scheme string // Host is the service hostname. Host string // UserAgent is the user agent set in requests made by the client. UserAgent string // Dump indicates whether to dump request response. Dump bool }
Client is the common client data structure for all goa service clients.
type JWTSigner ¶
type JWTSigner struct { // Header is the name of the HTTP header which contains the JWT. // The default is "Authentication" Header string // Format represents the format used to render the JWT. // The default is "Bearer %s" Format string // Token stores the actual JWT. Token string }
JWTSigner implements JSON Web Token auth.
func (*JWTSigner) RegisterFlags ¶
RegisterFlags adds the "--jwt" flag to the client tool.
type OAuth2Signer ¶
type OAuth2Signer struct { // RefreshURLFormat is a format that generates the refresh access token URL given a // refresh token. RefreshURLFormat string // RefreshToken contains the OAuth3 refresh token from which access tokens are // created. RefreshToken string // contains filtered or unexported fields }
OAuth2Signer enables the use of OAuth2 refresh tokens. It takes care of creating access tokens given a refresh token and a refresh URL as defined in RFC 6749. Note that this signer does not concern itself with generating the initial refresh token, this has to be done prior to using the client. Also it assumes the response of the refresh request response is JSON encoded and of the form:
{ "access_token":"2YotnFZFEjr1zCsicMWpAA", "expires_in":3600, "refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA" }
where the "expires_in" and "refresh_token" properties are optional and additional properties are ignored. If the response contains a "expires_in" property then the signer takes care of making refresh requests prior to the token expiration.
func (*OAuth2Signer) Refresh ¶
func (s *OAuth2Signer) Refresh(ctx context.Context) error
Refresh makes a OAuth2 refresh access token request.
func (*OAuth2Signer) RegisterFlags ¶
func (s *OAuth2Signer) RegisterFlags(app *cobra.Command)
RegisterFlags adds the "--refreshURL" and "--refreshToken" flags to the client tool.
type Signer ¶
type Signer interface { // Sign adds required headers, cookies etc. Sign(context.Context, *http.Request) error // RegisterFlags registers the command line flags that defines the values used to // initialize the signer. RegisterFlags(cmd *cobra.Command) }
Signer is the common interface implemented by all signers.