types

package
v0.0.0-...-cb472e6 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestIDKey       = "rid"
	RequestIDHeaderKey = "X-Request-Id"
)

request id key, travel in context.

View Source
const (
	// the key to describe the auth path that this resource need to auth.
	// only if the path is matched one of the use's auth policy, then a use's
	// have this resource's operate authorize.
	IamPathKey = "_bk_iam_path_"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	ID string `json:"id"`
}

Action define's the use's action, which is must correspond to the registered action ids in iam.

type ActionPolicy

type ActionPolicy struct {
	Action Action           `json:"action"`
	Policy *operator.Policy `json:"condition"`
}

type AuthBatch

type AuthBatch struct {
	Action    Action     `json:"action"`
	Resources []Resource `json:"resources"`
}

type AuthBatchOptions

type AuthBatchOptions struct {
	System  string       `json:"system"`
	Subject Subject      `json:"subject"`
	Batch   []*AuthBatch `json:"batch"`
}

func (AuthBatchOptions) Validate

func (a AuthBatchOptions) Validate() error

type AuthError

type AuthError struct {
	// request id, parsed from iam's http response header(X-Request-Id)
	Rid     string
	Code    int64
	Message string
}

func (*AuthError) Error

func (ae *AuthError) Error() string

type AuthOptions

type AuthOptions struct {
	System    string     `json:"system"`
	Subject   Subject    `json:"subject"`
	Action    Action     `json:"action"`
	Resources []Resource `json:"resources"`
}

AuthOptions describes a item to be authorized

func (AuthOptions) Validate

func (a AuthOptions) Validate() error

type BaseResp

type BaseResp struct {
	Code    int64  `json:"code"`
	Message string `json:"message"`
}

type Config

type Config struct {
	Iam     IamConfig
	Options Options
}

type Decision

type Decision struct {
	Authorized bool `json:"authorized"`
}

Decision describes the authorize decision, have already been authorized(true) or not(false)

type GetPolicyOption

type GetPolicyOption AuthOptions

type GetPolicyResp

type GetPolicyResp struct {
	BaseResp `json:",inline"`
	Data     *operator.Policy `json:"data"`
}

type IamConfig

type IamConfig struct {
	// blueking's auth center addresses
	Address []string
	// app code is used for authorize used.
	AppCode string
	// app secret is used for authorized
	AppSecret string
	// the system id which used in auth center.
	SystemID string
	// http TLS config
	TLS util.TLSClientConfig
}

func (IamConfig) Validate

func (a IamConfig) Validate() error

type ListPolicyOptions

type ListPolicyOptions struct {
	System    string     `json:"system"`
	Subject   Subject    `json:"subject"`
	Actions   []Action   `json:"actions"`
	Resources []Resource `json:"resources"`
}

type ListPolicyResp

type ListPolicyResp struct {
	BaseResp `json:",inline"`
	Data     []*ActionPolicy `json:"data"`
}

type ListWithAttributes

type ListWithAttributes struct {
	Operator operator.OperType `json:"op"`
	// resource instance id list, this list is not required, it also
	// one of the query filter with Operator.
	IDList     []string               `json:"ids"`
	Attributes []*operator.FieldValue `json:"attributes"`
	Type       ResourceType           `json:"type"`
}

type Options

type Options struct {
	Metric prometheus.Registerer
}

type Resource

type Resource struct {
	System    string             `json:"system"`
	Type      ResourceType       `json:"type"`
	ID        string             `json:"id"`
	Attribute ResourceAttributes `json:"attribute"`
}

Resource defines all the information used to authorize a resource.

type ResourceAttributes

type ResourceAttributes map[string]interface{}

ResourceAttributes is the attributes of resource. map key: one of the attribute of this resource. map value: the value of this attribute for a resource instance. value can only be one of string, int, boolean. Note: _bk_iam_path_ key is a special key, which represent the resource's depended auth topology path. it's value's protocol should be like this: ["/biz,1/set,2/"].

type ResourceType

type ResourceType string

type Subject

type Subject struct {
	Type ResourceType `json:"type"`
	ID   string       `json:"id"`
}

Jump to

Keyboard shortcuts

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