Documentation
¶
Index ¶
- type EnvLookup
- type EnvVars
- type ErrMissingEnvVar
- type UAAClient
- func (lh *UAAClient) ExchangeBearerTokenForClientToken(clientID, clientSecret, bearerLine string) (*UAAOAuthGrant, error)
- func (lh *UAAClient) FetchAccessToken(clientID, clientSecret string, postData url.Values) (*UAAOAuthGrant, error)
- func (lh *UAAClient) GetAuthorizeEndpoint() string
- func (lh *UAAClient) GetTokenEndpoint() string
- func (lh *UAAClient) ValidateAccessToken(at, expectedClientID string) (jwt.MapClaims, error)
- type UAAOAuthGrant
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnvLookup ¶
EnvLookup must return the value for the given key and whether it was found or not
func NewEnvLookupFromCFAppNamedService ¶
NewEnvLookupFromCFAppNamedService looks for a CloudFoundry bound service with the given name, and will allow sourcing of environment variables from there. If no service is found, a warning is printed, but no error thrown.
type EnvVars ¶
type EnvVars struct {
// contains filtered or unexported fields
}
EnvVars provides a convenient method to access environment variables
func NewDefaultEnvLookup ¶
func NewDefaultEnvLookup() *EnvVars
NewDefaultEnvLookup will detect if running in a CloudFoundry app, and if so will look for an env variable named UPS_PATH which if specified, must be a ":" separated list of user-provided-services that will be searched in that order. If any are missing, a warning is printed, but no error occurs. In any case, env variables are always sourced from your local environment variables first.
func NewEnvVarsFromPath ¶
NewEnvVarsFromPath create an EnvVars object, where the elements in the path are searched in order to load a given variable.
func (*EnvVars) Bool ¶
Bool looks for the key, and if found, parses it using strconv.ParseBool and returns the result. If not found, returns false. If found and won't parse, panics.
func (*EnvVars) MustHexEncodedByteArray ¶
MustHexEncodedByteArray will panic if value is not a hex-encoded by array of given length, else return it
func (*EnvVars) MustString ¶
MustString will panic if value is not set, otherwise it returns the value.
type ErrMissingEnvVar ¶
type ErrMissingEnvVar struct {
// Name of the key that was not found
Name string
}
ErrMissingEnvVar is panicked if a MustGet fails.
func (*ErrMissingEnvVar) Error ¶
func (err *ErrMissingEnvVar) Error() string
Error returns an error string
type UAAClient ¶
type UAAClient struct {
// UAAURL is the URL to UAA, e.g. https://uaa.system.example.com
UAAURL string
// contains filtered or unexported fields
}
UAAClient will validate access tokens against a UAA instance, caching keys as required
func NewUAAClientFromAPIURL ¶
NewUAAClientFromAPIURL looks up, via the apiEndpoint, the correct UAA address and returns a client
func (*UAAClient) ExchangeBearerTokenForClientToken ¶
func (lh *UAAClient) ExchangeBearerTokenForClientToken(clientID, clientSecret, bearerLine string) (*UAAOAuthGrant, error)
ExchangeBearerTokenForClientToken takes a bearer token (such as that returned by CF), and exchanges via the API auth flow, for an OAuthGrant for the specified clientID. The clientSecret here is really not a secret.
func (*UAAClient) FetchAccessToken ¶
func (lh *UAAClient) FetchAccessToken(clientID, clientSecret string, postData url.Values) (*UAAOAuthGrant, error)
FetchAccessToken sends data to endpoint to fetch a token Return grant object.
func (*UAAClient) GetAuthorizeEndpoint ¶
func (*UAAClient) GetTokenEndpoint ¶
type UAAOAuthGrant ¶
type UAAOAuthGrant struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
ExpiresIn int `json:"expires_in"`
Scope string `json:"scope"`
RefreshToken string `json:"refresh_token"`
JTI string `json:"jti"`
}
UAAOAuthGrant used to parse JSON for an access token from UAA server