bkiam

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiGwJWTKey     = "X-Bkapi-JWT"
	BcsUserTokenKey = "X-Bcs-User-Token"
)
View Source
const (
	SubRoot   = "/bcs/services/auth"
	TokenPath = SubRoot + "/token"
	KeyPath   = SubRoot + "/key"
)

Variables

This section is empty.

Functions

func NewAuth

func NewAuth(conf *config.ApiServConfig) (auth.BcsAuth, error)

Types

type ApiGwData

type ApiGwData struct {
	ISS     string           `json:"iss"`
	App     ApiGwDataApp     `json:"app"`
	Project ApiGwDataProject `json:"project"`
	User    ApiGwDataUser    `json:"user"`
	Exp     float64          `json:"exp"`
	NBF     float64          `json:"nbf"`
}

type ApiGwDataApp

type ApiGwDataApp struct {
	Version  float64 `json:"version"`
	Verified bool    `json:"verified"`
	AppCode  string  `json:"app_code"`
}

type ApiGwDataProject

type ApiGwDataProject struct {
	ProjectID   string `json:"project_id"`
	ProjectCode string `json:"project_code"`
	Verified    bool   `json:"verified"`
}

type ApiGwDataUser

type ApiGwDataUser struct {
	Username string  `json:"username"`
	Version  float64 `json:"version"`
	Verified bool    `json:"verified"`
}

type Auth

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

Auth manage the authority check with bk-iam,

func (*Auth) Allow

func (a *Auth) Allow(token *auth.Token, action auth.Action, resource auth.Resource) (bool, error)

func (*Auth) GetToken

func (a *Auth) GetToken(header http.Header) (*auth.Token, error)

type Client

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

func NewClient

func NewClient(conf *config.ApiServConfig) (*Client, error)

func (*Client) Query

func (c *Client) Query(username string, action auth.Action, resource auth.Resource) (bool, error)

type QueryData

type QueryData struct {
	IsPass bool `json:"is_pass"`
}

type QueryParam

type QueryParam struct {
	PrincipalType string      `json:"principal_type"`
	PrincipalID   string      `json:"principal_id"`
	ScopeType     string      `json:"scope_type"`
	ScopeID       string      `json:"scope_id"`
	ActionID      auth.Action `json:"action_id"`
	ResourceType  string      `json:"resource_type"`
	ResourceID    string      `json:"resource_id"`
}

func (*QueryParam) ParseResource

func (qp *QueryParam) ParseResource(resource auth.Resource)

type QueryResp

type QueryResp struct {
	RequestID  string    `json:"request_id"`
	Result     bool      `json:"result"`
	ErrCode    int       `json:"bk_error_code"`
	ErrMessage string    `json:"bk_error_msg"`
	Data       QueryData `json:"data"`
}

type TokenCache

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

func NewTokenCache

func NewTokenCache(conf *config.ApiServConfig) (*TokenCache, error)

func (*TokenCache) Get

func (tc *TokenCache) Get(tokenKey string) (*auth.Token, error)

func (*TokenCache) Update

func (tc *TokenCache) Update(token *auth.Token)

Jump to

Keyboard shortcuts

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