Documentation
¶
Index ¶
- Constants
- func BuildSubdomainURL(target string, zoneID string) (*url.URL, error)
- func BuildTargetURL(target string) (*url.URL, error)
- type API
- func NewWithAuthorizationCode(target string, zoneID string, clientID string, clientSecret string, ...) (*API, error)
- func NewWithClientCredentials(target string, zoneID string, clientID string, clientSecret string, ...) (*API, error)
- func NewWithPasswordCredentials(target string, zoneID string, clientID string, clientSecret string, ...) (*API, error)
- func (a *API) ActivateUser(userID string, userMetaVersion int) error
- func (a *API) AddGroupMember(groupID string, memberID string, entityType string, origin string) error
- func (a *API) ChangeClientSecret(id string, newSecret string) error
- func (a *API) CreateClient(client Client) (*Client, error)
- func (a *API) CreateGroup(group Group) (*Group, error)
- func (a *API) CreateUser(user User) (*User, error)
- func (a *API) Curl(path string, method string, data string, headers []string) (string, string, error)
- func (a *API) DeactivateUser(userID string, userMetaVersion int) error
- func (a *API) DeleteClient(clientID string) (*Client, error)
- func (a *API) DeleteGroup(groupID string) (*Group, error)
- func (a *API) DeleteUser(userID string) (*User, error)
- func (a *API) GetClient(clientID string) (*Client, error)
- func (a *API) GetGroup(groupID string) (*Group, error)
- func (a *API) GetGroupByName(name string, attributes string) (*Group, error)
- func (a *API) GetInfo() (*Info, error)
- func (a *API) GetMe() (*UserInfo, error)
- func (a *API) GetUser(userID string) (*User, error)
- func (a *API) GetUserByUsername(username, origin, attributes string) (*User, error)
- func (a *API) IsHealthy() (bool, error)
- func (a *API) ListAllClients(filter string, sortBy string, sortOrder SortOrder) ([]Client, error)
- func (a *API) ListAllGroups(filter string, sortBy string, attributes string, sortOrder SortOrder) ([]Group, error)
- func (a *API) ListAllUsers(filter string, sortBy string, attributes string, sortOrder SortOrder) ([]User, error)
- func (a *API) ListClients(filter string, sortBy string, sortOrder SortOrder, startIndex int, ...) ([]Client, Page, error)
- func (a *API) ListGroups(filter string, sortBy string, attributes string, sortOrder SortOrder, ...) ([]Group, Page, error)
- func (a *API) ListUsers(filter string, sortBy string, attributes string, sortOrder SortOrder, ...) ([]User, Page, error)
- func (a *API) TokenKey() (*JWK, error)
- func (a *API) TokenKeys() ([]JWK, error)
- func (a *API) UpdateClient(client Client) (*Client, error)
- func (a *API) UpdateGroup(group Group) (*Group, error)
- func (a *API) UpdateUser(user User) (*User, error)
- type Approval
- type Client
- type Email
- type GrantType
- type Group
- type GroupMember
- type Info
- type JWK
- type Keys
- type Meta
- type Page
- type PhoneNumber
- type SortOrder
- type TokenFormat
- type User
- type UserGroup
- type UserInfo
- type UserName
Constants ¶
const ( REFRESHTOKEN = GrantType("refresh_token") AUTHCODE = GrantType("authorization_code") IMPLICIT = GrantType("implicit") PASSWORD = GrantType("password") CLIENTCREDENTIALS = GrantType("client_credentials") )
Valid GrantType values.
const ( // SortAscending sorts in ascending order. SortAscending = SortOrder("ascending") // SortDescending sorts in descending order. SortDescending = SortOrder("descending") )
const ClientsEndpoint string = "/oauth/clients"
ClientsEndpoint is the path to the clients resource.
const GroupsEndpoint string = "/Groups"
GroupsEndpoint is the path to the groups resource.
const UsersEndpoint string = "/Users"
UsersEndpoint is the path to the users resource.
Variables ¶
This section is empty.
Functions ¶
func BuildSubdomainURL ¶ added in v0.0.7
BuildSubdomainURL returns a URL that optionally includes the zone ID as a host prefix. If the target does not include a scheme, https will be used.
Types ¶
type API ¶ added in v0.0.7
type API struct { AuthenticatedClient *http.Client UnauthenticatedClient *http.Client TargetURL *url.URL SkipSSLValidation bool Verbose bool ZoneID string }
API is a client to the UAA API.
func NewWithAuthorizationCode ¶ added in v0.0.7
func NewWithAuthorizationCode(target string, zoneID string, clientID string, clientSecret string, code string, skipSSLValidation bool, tokenFormat TokenFormat) (*API, error)
NewWithAuthorizationCode builds an API that uses the authorization code grant to get a token for use with the UAA API.
You can supply an http.Client because this function has side-effects (a token is requested from the target).
If you do not supply an http.Client,
http.Client{Transport: http.DefaultTransport}
will be used.
func NewWithClientCredentials ¶ added in v0.0.7
func NewWithClientCredentials(target string, zoneID string, clientID string, clientSecret string, tokenFormat TokenFormat) (*API, error)
NewWithClientCredentials builds an API that uses the client credentials grant to get a token for use with the UAA API.
func NewWithPasswordCredentials ¶ added in v0.0.7
func NewWithPasswordCredentials(target string, zoneID string, clientID string, clientSecret string, username string, password string, tokenFormat TokenFormat) (*API, error)
NewWithPasswordCredentials builds an API that uses the password credentials grant to get a token for use with the UAA API.
func (*API) ActivateUser ¶ added in v0.0.7
ActivateUser activates the user with the given user ID http://docs.cloudfoundry.org/api/uaa/version/4.14.0/index.html#patch.
func (*API) AddGroupMember ¶ added in v0.0.8
func (a *API) AddGroupMember(groupID string, memberID string, entityType string, origin string) error
AddGroupMember adds the entity with the given memberID to the group with the given ID. If no entityType is supplied, the entityType (which can be "USER" or "GROUP") will be "USER". If no origin is supplied, the origin will be "uaa".
func (*API) ChangeClientSecret ¶ added in v0.0.8
ChangeClientSecret updates the secret with the given value for the client with the given id http://docs.cloudfoundry.org/api/uaa/version/4.14.0/index.html#change-secret.
func (*API) CreateClient ¶ added in v0.0.8
CreateClient creates the given client.
func (*API) CreateGroup ¶ added in v0.0.8
CreateGroup creates the given group.
func (*API) CreateUser ¶ added in v0.0.7
CreateUser creates the given user.
func (*API) Curl ¶ added in v0.0.8
func (a *API) Curl(path string, method string, data string, headers []string) (string, string, error)
Curl makes a request to the UAA API with the given path, method, data, and headers.
func (*API) DeactivateUser ¶ added in v0.0.7
DeactivateUser deactivates the user with the given user ID http://docs.cloudfoundry.org/api/uaa/version/4.14.0/index.html#patch.
func (*API) DeleteClient ¶ added in v0.0.8
DeleteClient deletes the client with the given client ID.
func (*API) DeleteGroup ¶ added in v0.0.8
DeleteGroup deletes the group with the given group ID.
func (*API) DeleteUser ¶ added in v0.0.7
DeleteUser deletes the user with the given user ID.
func (*API) GetGroupByName ¶ added in v0.0.8
GetGroupByName gets the group with the given name http://docs.cloudfoundry.org/api/uaa/version/4.14.0/index.html#list-4.
func (*API) GetInfo ¶ added in v0.0.7
GetInfo gets server information http://docs.cloudfoundry.org/api/uaa/version/4.14.0/index.html#server-information-2.
func (*API) GetUserByUsername ¶ added in v0.0.7
GetUserByUsername gets the user with the given username http://docs.cloudfoundry.org/api/uaa/version/4.14.0/index.html#list-with-attribute-filtering.
func (*API) IsHealthy ¶ added in v0.0.8
IsHealthy returns true if the UAA is healthy, false if it is unhealthy, and an error if there is an issue making a request to the /healthz endpoint.
func (*API) ListAllClients ¶ added in v0.0.8
ListAllClients retrieves UAA clients
func (*API) ListAllGroups ¶ added in v0.0.8
func (a *API) ListAllGroups(filter string, sortBy string, attributes string, sortOrder SortOrder) ([]Group, error)
ListAllGroups retrieves UAA groups
func (*API) ListAllUsers ¶ added in v0.0.7
func (a *API) ListAllUsers(filter string, sortBy string, attributes string, sortOrder SortOrder) ([]User, error)
ListAllUsers retrieves UAA users
func (*API) ListClients ¶ added in v0.0.8
func (a *API) ListClients(filter string, sortBy string, sortOrder SortOrder, startIndex int, itemsPerPage int) ([]Client, Page, error)
ListClients with the given filter, sortBy, attributes, sortOrder, startIndex (1-based), and count (default 100). If successful, ListClients returns the clients and the total itemsPerPage of clients for all pages. If unsuccessful, ListClients returns the error.
func (*API) ListGroups ¶ added in v0.0.8
func (a *API) ListGroups(filter string, sortBy string, attributes string, sortOrder SortOrder, startIndex int, itemsPerPage int) ([]Group, Page, error)
ListGroups with the given filter, sortBy, attributes, sortOrder, startIndex (1-based), and count (default 100). If successful, ListGroups returns the groups and the total itemsPerPage of groups for all pages. If unsuccessful, ListGroups returns the error.
func (*API) ListUsers ¶ added in v0.0.7
func (a *API) ListUsers(filter string, sortBy string, attributes string, sortOrder SortOrder, startIndex int, itemsPerPage int) ([]User, Page, error)
ListUsers with the given filter, sortBy, attributes, sortOrder, startIndex (1-based), and count (default 100). If successful, ListUsers returns the users and the total itemsPerPage of users for all pages. If unsuccessful, ListUsers returns the error.
func (*API) TokenKey ¶ added in v0.0.8
TokenKey retrieves a JWK from the token_key endpoint (http://docs.cloudfoundry.org/api/uaa/version/4.14.0/index.html#token-key-s).
func (*API) TokenKeys ¶ added in v0.0.8
TokenKeys gets the JSON Web Token signing keys for the UAA server.
func (*API) UpdateClient ¶ added in v0.0.8
UpdateClient updates the given client.
func (*API) UpdateGroup ¶ added in v0.0.8
UpdateGroup updates the given group.
type Approval ¶
type Approval struct { UserID string `json:"userId,omitempty"` ClientID string `json:"clientId,omitempty"` Scope string `json:"scope,omitempty"` Status string `json:"status,omitempty"` LastUpdatedAt string `json:"lastUpdatedAt,omitempty"` ExpiresAt string `json:"expiresAt,omitempty"` }
Approval is a record of the user's explicit approval or rejection for an application's request for delegated permissions.
type Client ¶ added in v0.0.2
type Client struct { ClientID string `json:"client_id,omitempty" generator:"id"` ClientSecret string `json:"client_secret,omitempty"` Scope []string `json:"scope,omitempty"` ResourceIDs []string `json:"resource_ids,omitempty"` AuthorizedGrantTypes []string `json:"authorized_grant_types,omitempty"` RedirectURI []string `json:"redirect_uri,omitempty"` Authorities []string `json:"authorities,omitempty"` TokenSalt string `json:"token_salt,omitempty"` AllowedProviders []string `json:"allowedproviders,omitempty"` DisplayName string `json:"name,omitempty"` LastModified int64 `json:"lastModified,omitempty"` RequiredUserGroups []string `json:"required_user_groups,omitempty"` AccessTokenValidity int64 `json:"access_token_validity,omitempty"` RefreshTokenValidity int64 `json:"refresh_token_validity,omitempty"` }
Client is a UAA client http://docs.cloudfoundry.org/api/uaa/version/4.14.0/index.html#clients.
type Email ¶ added in v0.0.2
type Email struct { Value string `json:"value,omitempty"` Primary *bool `json:"primary,omitempty"` }
Email is an email address.
type Group ¶ added in v0.0.2
type Group struct { ID string `json:"id,omitempty"` Meta *Meta `json:"meta,omitempty"` DisplayName string `json:"displayName,omitempty"` ZoneID string `json:"zoneId,omitempty"` Description string `json:"description,omitempty"` Members []GroupMember `json:"members,omitempty"` Schemas []string `json:"schemas,omitempty"` }
Group is a container for users and groups.
type GroupMember ¶ added in v0.0.2
type GroupMember struct { Origin string `json:"origin,omitempty"` Type string `json:"type,omitempty"` Value string `json:"value,omitempty"` }
GroupMember is a user or a group.
type Info ¶
type Info struct { App uaaApp `json:"app"` Links uaaLinks `json:"links"` Prompts map[string][]string `json:"prompts"` ZoneName string `json:"zone_name"` EntityID string `json:"entityID"` CommitID string `json:"commit_id"` Timestamp string `json:"timestamp"` IdpDefinitions map[string]string `json:"idpDefinitions"` }
Info is information about the UAA server.
type JWK ¶
type JWK struct { Kty string `json:"kty"` E string `json:"e,omitempty"` Use string `json:"use"` Kid string `json:"kid"` Alg string `json:"alg"` Value string `json:"value"` N string `json:"n,omitempty"` }
JWK represents a JSON Web Key (https://tools.ietf.org/html/rfc7517).
type Meta ¶ added in v0.0.2
type Meta struct { Version int `json:"version,omitempty"` Created string `json:"created,omitempty"` LastModified string `json:"lastModified,omitempty"` }
Meta describes the version and timestamps for a resource.
type Page ¶ added in v0.0.7
type Page struct { StartIndex int `json:"startIndex"` ItemsPerPage int `json:"itemsPerPage"` TotalResults int `json:"totalResults"` }
Page represents a page of information returned from the UAA API.
type PhoneNumber ¶
type PhoneNumber struct {
Value string `json:"value"`
}
PhoneNumber is a phone number for a user.
type SortOrder ¶ added in v0.0.2
type SortOrder string
SortOrder defines the sort order when listing users or groups.
type TokenFormat ¶
type TokenFormat int
TokenFormat is the format of a token.
const ( OpaqueToken TokenFormat = iota JSONWebToken )
Valid TokenFormat values.
func (TokenFormat) String ¶ added in v0.0.7
func (t TokenFormat) String() string
type User ¶ added in v0.0.2
type User struct { ID string `json:"id,omitempty"` Password string `json:"password,omitempty"` ExternalID string `json:"externalId,omitempty"` Meta *Meta `json:"meta,omitempty"` Username string `json:"userName,omitempty"` Name *UserName `json:"name,omitempty"` Emails []Email `json:"emails,omitempty"` Groups []UserGroup `json:"groups,omitempty"` Approvals []Approval `json:"approvals,omitempty"` PhoneNumbers []PhoneNumber `json:"phoneNumbers,omitempty"` Active *bool `json:"active,omitempty"` Verified *bool `json:"verified,omitempty"` Origin string `json:"origin,omitempty"` ZoneID string `json:"zoneId,omitempty"` PasswordLastModified string `json:"passwordLastModified,omitempty"` PreviousLogonTime int `json:"previousLogonTime,omitempty"` LastLogonTime int `json:"lastLogonTime,omitempty"` Schemas []string `json:"schemas,omitempty"` }
User is a UAA user http://docs.cloudfoundry.org/api/uaa/version/4.14.0/index.html#get-3.
type UserGroup ¶ added in v0.0.2
type UserGroup struct { Value string `json:"value,omitempty"` Display string `json:"display,omitempty"` Type string `json:"type,omitempty"` }
UserGroup is a group that a user belongs to.
type UserInfo ¶ added in v0.0.2
type UserInfo struct { UserID string `json:"user_id"` Sub string `json:"sub"` Username string `json:"user_name"` GivenName string `json:"given_name"` FamilyName string `json:"family_name"` Email string `json:"email"` PhoneNumber []string `json:"phone_number"` PreviousLoginTime int64 `json:"previous_logon_time"` Name string `json:"name"` }
UserInfo is a protected resource required for OpenID Connect compatibility. The response format is defined here: https://openid.net/specs/openid-connect-core-1_0.html#UserInfoResponse.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package passwordcredentials implements the OAuth2.0 "password credentials" token flow.
|
Package passwordcredentials implements the OAuth2.0 "password credentials" token flow. |