config

package
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 8 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DefaultApiUrl    = "https://api.permit.io"
	DefaultDebugMode = false
	DefaultPdpUrl    = "http://localhost:7766"
	DefaultOpaUrl    = "http://localhost:8181"

	DefaultTimeout          = time.Second * 5
	DefaultFactsSyncTimeout = 10 * time.Second
)

Default Builder consts

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeyLevel

type APIKeyLevel int
const (
	NoneAPIKeyLevel APIKeyLevel = iota
	OrganizationAPIKeyLevel
	ProjectAPIKeyLevel
	EnvironmentAPIKeyLevel
)

func GetApiKeyLevel

func GetApiKeyLevel(scope *models.APIKeyScopeRead) APIKeyLevel

type FactsSyncTimeoutPolicy added in v1.2.2

type FactsSyncTimeoutPolicy string

FactsSyncTimeoutPolicy defines the possible policies for facts synchronization timeout

const (
	// FactsSyncTimeoutPolicyIgnore indicates to ignore timeout and continue
	FactsSyncTimeoutPolicyIgnore FactsSyncTimeoutPolicy = "ignore"
	// FactsSyncTimeoutPolicyFail indicates to fail the request when timeout is reached
	FactsSyncTimeoutPolicyFail FactsSyncTimeoutPolicy = "fail"
)

type IPermitConfig

type IPermitConfig interface {
	GetApiUrl() string
	GetToken() string
	GetPdpUrl() string
	GetOpaUrl() string
	GetDebug() bool
	GetContext() *PermitContext
	GetLogger() *zap.Logger
	// Deprecated: GetProxyFactsViaPDP will be removed in future versions.
	GetProxyFactsViaPDP() bool
	GetFactsSyncTimeout() *time.Duration
	GetFactsSyncTimeoutPolicy() FactsSyncTimeoutPolicy
	GetHTTPClient() *http.Client
}

type PermitBuilder

type PermitBuilder struct {
	PermitConfig
}

func NewConfigBuilder

func NewConfigBuilder(token string) *PermitBuilder

type PermitConfig

type PermitConfig struct {
	Context *PermitContext
	Logger  *zap.Logger
	// contains filtered or unexported fields
}

func NewPermitConfig

func NewPermitConfig(apiUrl string, token string, pdpUrl string, debug bool, context *PermitContext, logger *zap.Logger) *PermitConfig

func (*PermitConfig) Build

func (c *PermitConfig) Build() PermitConfig

func (*PermitConfig) GetApiUrl

func (c *PermitConfig) GetApiUrl() string

func (*PermitConfig) GetContext

func (c *PermitConfig) GetContext() *PermitContext

func (*PermitConfig) GetDebug

func (c *PermitConfig) GetDebug() bool

func (*PermitConfig) GetFactsSyncTimeout added in v1.1.2

func (c *PermitConfig) GetFactsSyncTimeout() *time.Duration

func (*PermitConfig) GetFactsSyncTimeoutPolicy added in v1.2.2

func (c *PermitConfig) GetFactsSyncTimeoutPolicy() FactsSyncTimeoutPolicy

func (*PermitConfig) GetHTTPClient added in v0.0.10

func (c *PermitConfig) GetHTTPClient() *http.Client

func (*PermitConfig) GetLogger

func (c *PermitConfig) GetLogger() *zap.Logger

func (*PermitConfig) GetOpaUrl added in v0.0.4

func (c *PermitConfig) GetOpaUrl() string

func (*PermitConfig) GetPdpUrl

func (c *PermitConfig) GetPdpUrl() string

func (*PermitConfig) GetProxyFactsViaPDP added in v1.1.2

func (c *PermitConfig) GetProxyFactsViaPDP() bool

func (*PermitConfig) GetToken

func (c *PermitConfig) GetToken() string

func (*PermitConfig) WithApiUrl

func (c *PermitConfig) WithApiUrl(apiUrl string) *PermitConfig

func (*PermitConfig) WithContext

func (c *PermitConfig) WithContext(context *PermitContext) *PermitConfig

func (*PermitConfig) WithDebug

func (c *PermitConfig) WithDebug(debug bool) *PermitConfig

func (*PermitConfig) WithFactsSyncTimeout added in v1.1.2

func (c *PermitConfig) WithFactsSyncTimeout(timeout time.Duration) *PermitConfig

func (*PermitConfig) WithHTTPClient added in v0.0.10

func (c *PermitConfig) WithHTTPClient(client *http.Client) *PermitConfig

func (*PermitConfig) WithLogger

func (c *PermitConfig) WithLogger(logger *zap.Logger) *PermitConfig

func (*PermitConfig) WithOpaUrl added in v0.0.4

func (c *PermitConfig) WithOpaUrl(opaUrl string) *PermitConfig

func (*PermitConfig) WithPdpUrl added in v0.0.2

func (c *PermitConfig) WithPdpUrl(pdpUrl string) *PermitConfig

func (*PermitConfig) WithProxyFactsViaPDP added in v1.1.2

func (c *PermitConfig) WithProxyFactsViaPDP(proxyFactsViaPDP bool) *PermitConfig

func (*PermitConfig) WithTimeout added in v1.0.5

func (c *PermitConfig) WithTimeout(timeout time.Duration) *PermitConfig

type PermitContext

type PermitContext struct {
	APIKeyLevel   APIKeyLevel
	ProjectId     string
	EnvironmentId string
}

func NewPermitContext

func NewPermitContext(apiKeyLevel APIKeyLevel, project string, environment string) *PermitContext

func PermitContextFactory

func PermitContextFactory(ctx context.Context, client *openapi.APIClient, project string, environment string, isUserInput bool) (*PermitContext, error)

func (*PermitContext) GetContext

func (p *PermitContext) GetContext() *PermitContext

func (*PermitContext) GetEnvironment

func (p *PermitContext) GetEnvironment() string

func (*PermitContext) GetProject

func (p *PermitContext) GetProject() string

func (*PermitContext) SetPermitContext added in v0.0.4

func (p *PermitContext) SetPermitContext(project string, environment string, apiKeyLevel APIKeyLevel)

type PermitContextInterface

type PermitContextInterface interface {
	SetPermitContext(project string, environment string, apiKeyLevel APIKeyLevel)
	GetProject() string
	GetEnvironment() string
	GetContext() *PermitContext
}

Jump to

Keyboard shortcuts

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