launchdarkly

package
v3.88.16 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Code generated by go generate; DO NOT EDIT.

user.go file is all related to calling APIs to get user and token information and formatting them to secretInfo User.

It calls 3 APIs:

  • /v2/caller-identity
  • /v2/tokens/<id> (with token id from previous api response)
  • /v2/roles/<role_id> (if custom role id is present in tokens) (more than one role can be assigned to token as well)

it formats all these responses into one User struct for secretInfo.

Index

Constants

This section is empty.

Variables

View Source
var (
	PermissionStrings = map[Permission]string{
		Admin:        "admin",
		Writer:       "writer",
		Reader:       "reader",
		Inlinepolicy: "inlinepolicy",
		Customroles:  "customroles",
	}

	StringToPermission = map[string]Permission{
		"admin":        Admin,
		"writer":       Writer,
		"reader":       Reader,
		"inlinepolicy": Inlinepolicy,
		"customroles":  Customroles,
	}

	PermissionIDs = map[Permission]int{
		Admin:        1,
		Writer:       2,
		Reader:       3,
		Inlinepolicy: 4,
		Customroles:  5,
	}

	IdToPermission = map[int]Permission{
		1: Admin,
		2: Writer,
		3: Reader,
		4: Inlinepolicy,
		5: Customroles,
	}
)
View Source
var (
	MetadataKey = "key"
)

Functions

func AnalyzeAndPrintPermissions

func AnalyzeAndPrintPermissions(cfg *config.Config, token string)

func CaptureResources

func CaptureResources(client *http.Client, token string, secretInfo *SecretInfo) error

func CaptureUserInformation

func CaptureUserInformation(client *http.Client, token string, secretInfo *SecretInfo) error

CaptureUserInformation call following three APIs:

  • /v2/caller-identity
  • /v2/tokens/<token_id> (token_id from previous API response)
  • /v2/roles/<role_id> (roles_id from previous API response if exist)

It format all responses into one secret info User

Types

type Analyzer

type Analyzer struct {
	Cfg *config.Config
}

func (Analyzer) Analyze

func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error)

func (Analyzer) Type

func (a Analyzer) Type() analyzers.AnalyzerType

type CustomRole

type CustomRole struct {
	ID                string
	Key               string
	Name              string
	Polices           []Policy
	BasePermission    string
	AssignedToMembers int
	AssignedToTeams   int
}

CustomRole is a flexible policies providing fine-grained access control to everything in launch darkly

type Permission

type Permission int
const (
	Invalid      Permission = iota
	Admin        Permission = iota
	Writer       Permission = iota
	Reader       Permission = iota
	Inlinepolicy Permission = iota
	Customroles  Permission = iota
)

func PermissionFromID

func PermissionFromID(id int) (Permission, error)

PermissionFromID converts an ID to its Permission enum

func PermissionFromString

func PermissionFromString(s string) (Permission, error)

PermissionFromString converts a string representation to its Permission enum

func (Permission) ToID

func (p Permission) ToID() (int, error)

ToID converts a Permission enum to its ID

func (Permission) ToString

func (p Permission) ToString() (string, error)

ToString converts a Permission enum to its string representation

type Policy

type Policy struct {
	Resources    []string
	NotResources []string
	Actions      []string
	NotActions   []string
	Effect       string
}

policy is a set of statements

type Resource

type Resource struct {
	ID             string
	Name           string
	Permission     string
	Type           string
	ParentResource *Resource
	MetaData       map[string]string
}

type SecretInfo

type SecretInfo struct {
	User        User
	Permissions []string

	Resources []Resource
	// contains filtered or unexported fields
}

func AnalyzePermissions

func AnalyzePermissions(cfg *config.Config, token string) (*SecretInfo, error)

AnalyzePermissions will collect all the scopes assigned to token along with resource it can access

type Token

type Token struct {
	ID             string       // id of the token
	Name           string       // name of the token
	CustomRoles    []CustomRole // custom roles assigned to the token
	InlineRole     []Policy     // any policy statements maybe used in place of a built-in custom role
	Role           string       // role of token
	IsServiceToken bool         // is a service token or not
	APIVersion     int          // default api version assigned to the token
}

Token is the token details

type User

type User struct {
	AccountID string // account id. It is the owner id of token as well
	MemberID  string
	Name      string
	Role      string // role of caller
	Email     string
	Token     Token
}

User is the information about the user to whom the token belongs

Jump to

Keyboard shortcuts

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