# README
go-uaa

Overview
go-uaa
is a client library for the UAA API. It is a go module
.
Usage
Step 1: Add go-uaa
As A Dependency
$ go mod init # optional
$ go get -u github.com/cloudfoundry-community/go-uaa
$ cat go.mod
module github.com/cloudfoundry-community/go-uaa/cmd/test
go 1.13
require github.com/cloudfoundry-community/go-uaa latest
Step 2: Construct and Use uaa.API
Construct a uaa.API
by using uaa.New(target string, authOpt AuthenticationOption, opts ...Option)
:
- The target is the URL of your UAA API (for example, https://uaa.run.pivotal.io); do not include
/oauth/token
suffix - You must choose one authentication method and supply it as the third argument. There are a number of authentication methods available:
uaa.WithClientCredentials(clientID string, clientSecret string, tokenFormat TokenFormat)
uaa.WithPasswordCredentials(clientID string, clientSecret string, username string, password string, tokenFormat TokenFormat)
uaa.WithAuthorizationCode(clientID string, clientSecret string, authorizationCode string, tokenFormat TokenFormat, redirectURL *url.URL)
uaa.WithRefreshToken(clientID string, clientSecret string, refreshToken string, tokenFormat TokenFormat)
uaa.WithToken(token *oauth2.Token)
(this is the only authentication methods that cannot automatically refresh the token when it expires)
- You can optionally supply one or more options:
uaa.WithZoneID(zoneID string)
if you want to specify your own zone IDuaa.WithClient(client *http.Client)
if you want to specify your ownhttp.Client
uaa.WithSkipSSLValidation(skipSSLValidation bool)
if you want to ignore SSL validation issues; this is not recommended, and you should instead ensure you trust the certificate authority that issues the certificates used by UAAuaa.WithUserAgent(userAgent string)
if you want to supply your own user agent for requests to the UAA APIuaa.WithVerbosity(verbose bool)
if you want to enable verbose logging
$ cat main.go
package main
import (
"log"
uaa "github.com/cloudfoundry-community/go-uaa"
)
func main() {
// construct the API
api, err := uaa.New(
"https://uaa.example.net",
uaa.WithClientCredentials("client-id", "client-secret", uaa.JSONWebToken),
)
if err != nil {
log.Fatal(err)
}
// use the API to fetch a user
user, err := api.GetUserByUsername("[email protected]", "uaa", "")
if err != nil {
log.Fatal(err)
}
log.Printf("Hello, %s\n", user.Name.GivenName)
}
Experimental
- For the foreseeable future, releases will be in the
v0.x.y
range - You should expect breaking changes until
v1.x.y
releases occur - Notifications of breaking changes will be made via release notes associated with each tag
- You should use
go modules
with this package
Contributing
Pull requests welcome.
# Packages
No description provided by the author
Package passwordcredentials implements the OAuth2.0 "password credentials" token flow.
# Functions
BuildSubdomainURL returns a URL that optionally includes the zone ID as a host prefix.
BuildTargetURL returns a URL.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Constants
Valid GrantType values.
Valid GrantType values.
ClientsEndpoint is the path to the clients resource.
GroupsEndpoint is the path to the groups resource.
IdentityZonesEndpoint is the path to the users resource.
Valid GrantType values.
Valid TokenFormat values.
MFAProvidersEndpoint is the path to the MFA providers resource.
Valid TokenFormat values.
Valid GrantType values.
Valid GrantType values.
SortAscending sorts in ascending order.
SortDescending sorts in descending order.
UsersEndpoint is the path to the users resource.
# Structs
API is a client to the UAA API.
Approval is a record of the user's explicit approval or rejection for an application's request for delegated permissions.
Branding is the branding for a UAA identity zone.
Client is a UAA client http://docs.cloudfoundry.org/api/uaa/version/4.19.0/index.html#clients.
ClientSecretPolicy is an identity zone client secret policy.
CORSPolicy is an identity zone CORSPolicy.
Email is an email address.
Group is a container for users and groups.
GroupMapping is a container for external group mapping.
GroupMember is a user or a group.
IdentityZone is a UAA identity zone.
IdentityZoneConfig is the configuration for an identity zone.
IdentityZoneLinks is an identity zone link.
IdentityZoneMFAConfig is the MFA configuration for an identity zone.
IdentityZoneUserConfig is the user configuration for an identity zone.
Info is information about the UAA server.
JWK represents a JSON Web Key (https://tools.ietf.org/html/rfc7517).
Keys is a slice of JSON Web Keys.
Meta describes the version and timestamps for a resource.
MFAProvider is a UAA MFA provider http://docs.cloudfoundry.org/api/uaa/version/4.19.0/index.html#get-2.
MFAProviderConfig is configuration for an MFA provider.
No description provided by the author
Page represents a page of information returned from the UAA API.
PhoneNumber is a phone number for a user.
Prompt is a UAA prompt.
No description provided by the author
SAMLConfig is an identity zone SAMLConfig.
SAMLKey is an identity zone SAML key.
TokenPolicy is an identity zone token policy.
User is a UAA user http://docs.cloudfoundry.org/api/uaa/version/4.14.0/index.html#get-3.
UserGroup is a group that a user belongs to.
UserInfo is a protected resource required for OpenID Connect compatibility.
UserName is a person's name.
# Interfaces
No description provided by the author
No description provided by the author
# Type aliases
GrantType is a type of oauth2 grant.
SortOrder defines the sort order when listing users or groups.
TokenFormat is the format of a token.