uaa

package
v0.0.0-...-be16e78 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2018 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Overview

Package to interact with Cloudfoundry UAA server. Constructors are generally provided for objects a client needs to use

This link is helpful for understanding UAA OAUTH handshakes: http://blog.cloudfoundry.org/2012/07/23/uaa-intro/

Index

Constants

View Source
const MaxQueryLength = 8000

Variables

View Source
var (
	TokenDecodeError = errors.New("Failed to decode token")
	JSONParseError   = errors.New("Failed to parse JSON")
)
View Source
var InvalidRefreshToken = errors.New("UAA Invalid Refresh Token")

Functions

func GetClient

func GetClient(client Client) *http.Client

func GetTokenKey

func GetTokenKey(u UAA) (string, error)

func ThereAreMorePages

func ThereAreMorePages(users []User, totalResults int) bool

func UsersEmailsQueryURIFromParts

func UsersEmailsQueryURIFromParts(host string, filters []string) string

func UsersGUIDsByScope

func UsersGUIDsByScope(u UAA, scope string) ([]string, error)

func UsersQueryURIFromParts

func UsersQueryURIFromParts(host string, filters []string) string

func UsersQueryURIFromStartIndex

func UsersQueryURIFromStartIndex(host string, startIndex int) string

Types

type AllUsersInterface

type AllUsersInterface interface {
	AllUsers() ([]User, error)
}

type AuthorizeURLInterface

type AuthorizeURLInterface interface {
	AuthorizeURL() string
}

type Client

type Client struct {
	Host              string
	BasicAuthUsername string
	BasicAuthPassword string
	AccessToken       string
	VerifySSL         bool
}

Http Client, wraps go's http.Client for our usecase

func NewClient

func NewClient(host string, verifySSL bool) Client

func (Client) MakeRequest

func (client Client) MakeRequest(method, path string, requestBody io.Reader) (int, []byte, error)

Make request with the given basic auth and ssl settings, returns reponse code and body as a byte array

func (Client) TLSConfig

func (client Client) TLSConfig() *tls.Config

func (Client) WithAuthorizationToken

func (client Client) WithAuthorizationToken(token string) Client

func (Client) WithBasicAuthCredentials

func (client Client) WithBasicAuthCredentials(clientID, clientSecret string) Client

type ExchangeInterface

type ExchangeInterface interface {
	Exchange(string) (Token, error)
}

type Failure

type Failure struct {
	// contains filtered or unexported fields
}

used to encapuslate info about errors

func NewFailure

func NewFailure(code int, message []byte) Failure

Failure constructor

func (Failure) Code

func (failure Failure) Code() int

func (Failure) Error

func (failure Failure) Error() string

func (Failure) Message

func (failure Failure) Message() string

type GetClientTokenInterface

type GetClientTokenInterface interface {
	GetClientToken() (Token, error)
}

type GetTokenKeyInterface

type GetTokenKeyInterface interface {
	GetTokenKey() (string, error)
}

type LoginURLInterface

type LoginURLInterface interface {
	LoginURL() string
}

type Name

type Name struct {
	FamilyName string
	GivenName  string
}

type RefreshInterface

type RefreshInterface interface {
	Refresh(string) (Token, error)
}

type SetTokenInterface

type SetTokenInterface interface {
	SetToken(string)
}

type Token

type Token struct {
	Access  string `json:"access_token"`
	Refresh string `json:"refresh_token"`
}

Encapsulates the access and refresh tokens from UAA

func Exchange

func Exchange(u UAA, authCode string) (Token, error)

func GetClientToken

func GetClientToken(u UAA) (Token, error)

Retrieves ClientToken from UAA server

func NewToken

func NewToken() Token

func Refresh

func Refresh(u UAA, refreshToken string) (Token, error)

func (Token) ExpiresBefore

func (token Token) ExpiresBefore(timeBuffer time.Duration) (bool, error)

Determines if the token expires by the current time plus the time buffer

func (Token) IsExpired

func (token Token) IsExpired() (bool, error)

Determines if the token has expired

func (Token) IsPresent

func (token Token) IsPresent() bool

Determines if all the token's information is present

func (Token) Type

func (token Token) Type() string

type UAA

type UAA struct {
	ClientID       string
	ClientSecret   string
	RedirectURL    string
	Scope          string
	State          string
	AccessType     string
	ApprovalPrompt string
	AccessToken    string
	VerifySSL      bool

	ExchangeCommand          func(UAA, string) (Token, error)
	RefreshCommand           func(UAA, string) (Token, error)
	GetClientTokenCommand    func(UAA) (Token, error)
	UserByIDCommand          func(UAA, string) (User, error)
	GetTokenKeyCommand       func(UAA) (string, error)
	UsersByIDsCommand        func(UAA, ...string) ([]User, error)
	UsersEmailsByIDsCommand  func(UAA, ...string) ([]User, error)
	UsersGUIDsByScopeCommand func(UAA, string) ([]string, error)
	AllUsersCommand          func(UAA) ([]User, error)
	// contains filtered or unexported fields
}

Contains necessary info to communicate with Cloudfoundry UAA server, use the NewUAA constructor to create one.

func NewUAA

func NewUAA(loginURL, uaaURL, clientID, clientSecret, token string) UAA

func (UAA) AllUsers

func (u UAA) AllUsers() ([]User, error)

func (UAA) AuthorizeURL

func (u UAA) AuthorizeURL() string

func (UAA) Exchange

func (u UAA) Exchange(authCode string) (Token, error)

Gets auth token based on the code UAA provides during redirect process

func (UAA) GetClientToken

func (u UAA) GetClientToken() (Token, error)

Retrieves ClientToken from UAA server

func (UAA) GetTokenKey

func (u UAA) GetTokenKey() (string, error)

func (UAA) LoginURL

func (u UAA) LoginURL() string

Returns url used to login to UAA

func (UAA) Refresh

func (u UAA) Refresh(refreshToken string) (Token, error)

Refreshes token from UAA server

func (*UAA) SetToken

func (u *UAA) SetToken(token string)

func (UAA) UserByID

func (u UAA) UserByID(id string) (User, error)

Retrieves User from UAA server using the user id

func (UAA) UsersByIDs

func (u UAA) UsersByIDs(ids ...string) ([]User, error)

func (UAA) UsersEmailsByIDs

func (u UAA) UsersEmailsByIDs(ids ...string) ([]User, error)

func (UAA) UsersGUIDsByScope

func (u UAA) UsersGUIDsByScope(scope string) ([]string, error)

type User

type User struct {
	Username string
	ID       string
	Name     Name
	Emails   []string
	Active   bool
	Verified bool
}

func AllUsers

func AllUsers(u UAA) ([]User, error)

func PaginatedUsersFromQuery

func PaginatedUsersFromQuery(u UAA, uriString string) ([]User, int, error)

func UserByID

func UserByID(u UAA, id string) (User, error)

func UserFromJSON

func UserFromJSON(jsonBytes []byte) (User, error)

func UserFromResource

func UserFromResource(resource map[string]interface{}) (User, error)

func UsersByIDs

func UsersByIDs(u UAA, ids ...string) ([]User, error)

func UsersByIDsWithMaxLength

func UsersByIDsWithMaxLength(u UAA, length int, ids ...string) ([]User, error)

func UsersEmailsByIDs

func UsersEmailsByIDs(uaa UAA, ids ...string) ([]User, error)

func UsersEmailsByIDsWithMaxLength

func UsersEmailsByIDsWithMaxLength(u UAA, length int, ids ...string) ([]User, error)

func UsersFromQuery

func UsersFromQuery(u UAA, uriString string) ([]User, error)

type UserByIDInterface

type UserByIDInterface interface {
	UserByID(string) (User, error)
}

type UsersByIDsInterface

type UsersByIDsInterface interface {
	UsersByIDs(...string) ([]User, error)
}

type UsersEmailsByIDsInterface

type UsersEmailsByIDsInterface interface {
	UsersEmailsByIDs(...string) ([]User, error)
}

type UsersGUIDsByScopeInterface

type UsersGUIDsByScopeInterface interface {
	UsersGUIDsByScope(string) ([]string, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL