rbac

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatError

func FormatError(r *resty.Response, customError ...string) error

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) Error

func (oe *APIError) Error() string

func (*APIError) GetStatusCode

func (oe *APIError) GetStatusCode() int

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 NewClient

func NewClient(hostURL string, tlsConfig *tls.Config) *Client

NewClient access the RBAC API via TLS

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

func (c *Client) CreateRole(role *Role, token string) (string, error)

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

func (c *Client) GetCurrentUser(token string) (*User, error)

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

func (c *Client) GetRole(id uint, token string) (*Role, error)

GetRole fetches information about a single role, identified by its ID.

func (*Client) GetRoles added in v1.3.0

func (c *Client) GetRoles(token string) ([]Role, error)

GetRoles fetches information about all user roles.

func (*Client) GetSpecificUser added in v1.10.0

func (c *Client) GetSpecificUser(token string, sid string) (*User, error)

GetSpecificUser will return a specific user details

func (*Client) GetUsers added in v1.10.0

func (c *Client) GetUsers(token string) ([]User, error)

GetUsers returns all the users in the system.

func (*Client) RevokeRBACToken added in v1.8.0

func (c *Client) RevokeRBACToken(token string) error

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 Token

type Token struct {
	Token string `json:"token"`
}

Token is the returned auth token

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.

Jump to

Keyboard shortcuts

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