Documentation ¶
Index ¶
- func FormatError(r *resty.Response, customError ...string) error
- type APIError
- type AuthenticateRequest
- type AuthenticateResponse
- type Client
- func (c *Client) AuthenticateRBACToken(token string) (*AuthenticateResponse, error)
- func (c *Client) CreateRole(role *Role, token string) (string, error)
- func (c *Client) GenerateRBACToken(token string, request TokenRequest) (string, error)
- func (c *Client) GetCurrentUser(token string) (*User, error)
- func (c *Client) GetRBACToken(authRequest *RequestKeys) (*Token, error)
- func (c *Client) GetRole(id uint, token string) (*Role, error)
- func (c *Client) GetRoles(token string) ([]Role, error)
- func (c *Client) GetSpecificUser(token string, sid string) (*User, error)
- func (c *Client) GetUsers(token string) ([]User, error)
- func (c *Client) RevokeRBACToken(token string) error
- type Permission
- type RequestKeys
- type Role
- type Token
- type TokenRequest
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatError ¶
FormatError takes the resty response and a possible resty err and tries to create an APIError with as much info as possible
Types ¶
type APIError ¶
type APIError struct { Kind string `json:"kind"` Msg string `json:"msg"` Details string `json:"details"` StatusCode int }
APIError represents an error response from the RBAC API
func (*APIError) GetStatusCode ¶
GetStatusCode will return the HTTP status code.
type AuthenticateRequest ¶ added in v1.6.1
type AuthenticateRequest struct { Token string `json:"token"` UpdateLastActivity bool `json:"update_last_activity?"` }
AuthenticateRequest will hold the request needed for an authenticate.
type AuthenticateResponse ¶ added in v1.6.1
type AuthenticateResponse struct { Description string `json:"description"` Login string `json:"login"` RoleIDs []int `json:"role_ids"` UserID string `json:"user_id"` DisplayName string `json:"display_name"` }
AuthenticateResponse will hold the response from an authenticate.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for the RBAC API
func (*Client) AuthenticateRBACToken ¶ added in v1.6.1
func (c *Client) AuthenticateRBACToken(token string) (*AuthenticateResponse, error)
AuthenticateRBACToken returns a response with the token details or errors otherwise.
func (*Client) CreateRole ¶ added in v1.2.0
CreateRole creates a role, and attaches to it the specified permissions and the specified users and groups. Authentication is required.
If the role was created successfully then the path of the new role is returned, otherwise an error is returned.
func (*Client) GenerateRBACToken ¶ added in v1.9.0
func (c *Client) GenerateRBACToken(token string, request TokenRequest) (string, error)
GenerateRBACToken returns an RBAC token or errors otherwise
func (*Client) GetCurrentUser ¶ added in v1.10.0
GetCurrentUser will return the current user details.
func (*Client) GetRBACToken ¶
func (c *Client) GetRBACToken(authRequest *RequestKeys) (*Token, error)
GetRBACToken returns an auth token given user/password information
func (*Client) GetRole ¶ added in v1.3.0
GetRole fetches information about a single role, identified by its ID.
func (*Client) GetSpecificUser ¶ added in v1.10.0
GetSpecificUser will return a specific user details
func (*Client) RevokeRBACToken ¶ added in v1.8.0
type Permission ¶ added in v1.2.0
type Permission struct { ObjectType string `json:"object_type"` Action string `json:"action"` Instance string `json:"instance"` }
Permission represents an RBAC permission
type RequestKeys ¶
type RequestKeys struct { Login string `json:"login"` Password string `json:"password"` Lifetime string `json:"lifetime,omitempty"` Description string `json:"description,omitempty"` Client string `json:"client,omitempty"` Label string `json:"label,omitempty"` }
RequestKeys describes the keys used by the token endpoint
type Role ¶ added in v1.2.0
type Role struct { ID uint `json:"id,omitempty"` Permissions []Permission `json:"permissions"` UserIDs []string `json:"user_ids"` GroupIDs []string `json:"group_ids"` DisplayName string `json:"display_name"` Description string `json:"description"` }
Role represents an RBAC role
type TokenRequest ¶ added in v1.9.0
type TokenRequest struct { Lifetime string `json:"lifetime,omitempty"` Description string `json:"description,omitempty"` Client string `json:"client,omitempty"` }
TokenRequest will hold the details needed by the /tokens endpoint.
type User ¶ added in v1.10.0
type User struct { ID string `json:"id"` Login string `json:"login"` Email string `json:"email,omitempty"` DisplayName string `json:"display_name,omitempty"` RoleIDs []int `json:"role_ids,omitempty"` IsGroup bool `json:"is_group,omitempty"` IsRemote bool `json:"is_remote,omitempty"` IsUser bool `json:"is_user,omitempty"` IsSuperUser bool `json:"is_superuser,omitempty"` IsRevoked bool `json:"is_revoked,omitempty"` LastLogin time.Time `json:"last_login,omitempty"` InheritedRoleIDs []int `json:"inherited_role_ids,omitempty"` GroupIDs []string `json:"group_ids,omitempty"` }
User describes the user keys.