Documentation
¶
Index ¶
Constants ¶
View Source
const ( // TokenURLSuffix ... TokenURLSuffix = "/oauth/token" // AuthURLSuffix ... AuthURLSuffix = "/oauth/authorize" // UserInfoURLSuffix ... UserInfoURLSuffix = "/userinfo" // UsersURLSuffix ... UsersURLSuffix = "/Users" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
// PasswordAuth accepts username and password, return a token if it's valid.
PasswordAuth(username, password string) (*oauth2.Token, error)
// GetUserInfoByToken send the token to OIDC endpoint to get user info, currently it's also used to validate the token.
GetUserInfo(token string) (*UserInfo, error)
// SearchUser searches a user based on user name.
SearchUser(name string) ([]*SearchUserEntry, error)
// UpdateConfig updates the config of the current client
UpdateConfig(cfg *ClientConfig) error
}
Client provides funcs to interact with UAA.
func NewDefaultClient ¶
func NewDefaultClient(cfg *ClientConfig) (Client, error)
NewDefaultClient creates an instance of defaultClient.
type ClientConfig ¶
type ClientConfig struct {
ClientID string
ClientSecret string
Endpoint string
SkipTLSVerify bool
// Absolut path for CA root used to communicate with UAA, only effective when skipTLSVerify set to false.
CARootPath string
}
ClientConfig values to initialize UAA Client
type FakeClient ¶
FakeClient is for test only
func (*FakeClient) GetUserInfo ¶
func (fc *FakeClient) GetUserInfo(token string) (*UserInfo, error)
GetUserInfo ...
func (*FakeClient) PasswordAuth ¶
func (fc *FakeClient) PasswordAuth(username, password string) (*oauth2.Token, error)
PasswordAuth ...
func (*FakeClient) SearchUser ¶
func (fc *FakeClient) SearchUser(name string) ([]*SearchUserEntry, error)
SearchUser ...
func (*FakeClient) UpdateConfig ¶
func (fc *FakeClient) UpdateConfig(cfg *ClientConfig) error
UpdateConfig ...
type SearchUserEmailEntry ¶
SearchUserEmailEntry ...
type SearchUserEntry ¶
type SearchUserEntry struct {
ID string `json:"id"`
ExtID string `json:"externalId"`
UserName string `json:"userName"`
Emails []SearchUserEmailEntry `json:"emails"`
Groups []interface{}
}
SearchUserEntry is the struct of an entry of user within search result.
type SearchUserRes ¶
type SearchUserRes struct {
Resources []*SearchUserEntry `json:"resources"`
TotalResults int `json:"totalResults"`
Schemas []string `json:"schemas"`
}
SearchUserRes is the struct to parse the result of search user API of UAA
type UserInfo ¶
type UserInfo struct {
UserID string `json:"user_id"`
Sub string `json:"sub"`
UserName string `json:"user_name"`
Name string `json:"name"`
Email string `json:"email"`
}
UserInfo represent the JSON object of a userinfo response from UAA. As the response varies, this struct will contain only a subset of attributes that may be used in Harbor
Click to show internal directories.
Click to hide internal directories.