access

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceAnonymous  = "anonymous"
	SourceLocalBasic = "local-basic"
	SourceLocalCSV   = "local-csv"
	SourceGen3Fence  = "gen3-fence"
	SourceGen3Mock   = "gen3-mock"
	SourcePlugin     = "plugin"
)

Variables

This section is empty.

Functions

func AuthorizeScopeWrite added in v0.4.2

func AuthorizeScopeWrite(ctx context.Context, organization, project string, methods ...string) error

AuthorizeScopeWrite checks the authorization policy for creating, updating, or deleting a project-scoped resource. The caller remains responsible for transport authentication, such as requiring a Gen3 authorization header.

func AuthorizedResources

func AuthorizedResources(ctx context.Context, method string) []string

AuthorizedResources returns resources for which the current session has the requested method. It preserves the canonicalization and de-duplication rules used by the rest of the access package.

func CheckAccess

func CheckAccess(recordResources []string, userResources []string) bool

CheckAccess verifies if a user has access to a record based on RBAC resources. A record is accessible if: 1. It has NO required resources (public). 2. OR the user has at least one of the resources listed on the record.

func GetUserAuthz

func GetUserAuthz(ctx context.Context) []string

GetUserAuthz returns the list of resources the user is authorized to access. If not found, returns empty list (no access to protected resources).

func GetUserPrivileges

func GetUserPrivileges(ctx context.Context) map[string]map[string]bool

func HasAnyMethodAccess

func HasAnyMethodAccess(ctx context.Context, resources []string, methods ...string) bool

func HasAnyServiceMethodAccess

func HasAnyServiceMethodAccess(ctx context.Context, resources []string, service string, methods ...string) bool

func HasAuthHeader

func HasAuthHeader(ctx context.Context) bool

func HasMethodAccess

func HasMethodAccess(ctx context.Context, method string, resources []string) bool

func HasObjectMethodAccess

func HasObjectMethodAccess(ctx context.Context, method string, resources []string) bool

func HasServiceMethodAccess

func HasServiceMethodAccess(ctx context.Context, service, method string, resources []string) bool

func IsAuthzEnforced

func IsAuthzEnforced(ctx context.Context) bool

func IsGen3Mode

func IsGen3Mode(ctx context.Context) bool

func MissingGen3AuthHeader added in v0.4.2

func MissingGen3AuthHeader(ctx context.Context) bool

func WithSession

func WithSession(ctx context.Context, session *Session) context.Context

Types

type AuthorizationError

type AuthorizationError struct {
	Method             string
	RecordID           string
	Resources          []string
	DeniedRecords      int
	TotalRecords       int
	TruncatedResources int
}

func (*AuthorizationError) Error

func (e *AuthorizationError) Error() string

func (*AuthorizationError) ErrorCategory added in v0.4.1

func (e *AuthorizationError) ErrorCategory() errorapi.ErrorCategory

func (*AuthorizationError) ErrorCode added in v0.4.1

func (e *AuthorizationError) ErrorCode() errorapi.ErrorCode

func (*AuthorizationError) Is added in v0.4.1

func (e *AuthorizationError) Is(target error) bool

func (*AuthorizationError) PublicMessage

func (e *AuthorizationError) PublicMessage() string

type Decision added in v0.4.2

type Decision uint8
const (
	DecisionContinue Decision = iota
	DecisionUnauthorized
	DecisionForbidden
	DecisionInternalError
)

type EvaluationRequest added in v0.4.2

type EvaluationRequest struct {
	Context    context.Context
	RequestID  string
	Mode       string
	AuthHeader string
	Method     string
	Path       string
}

EvaluationRequest is the framework-neutral input to request authentication.

type EvaluationResult added in v0.4.2

type EvaluationResult struct {
	Session        *Session
	Decision       Decision
	BasicChallenge bool
}

EvaluationResult contains the session state and semantic outcome for a request.

type Evaluator added in v0.4.2

type Evaluator interface {
	Evaluate(EvaluationRequest) EvaluationResult
}

type Session

type Session struct {
	Mode              string
	Source            string
	Subject           string
	Claims            map[string]interface{}
	Resources         []string
	Privileges        map[string]map[string]bool
	AuthHeaderPresent bool
	AuthzEnforced     bool
}

Session is the canonical auth state propagated through request handling.

func FromContext

func FromContext(ctx context.Context) *Session

func NewSession

func NewSession(mode string) *Session

func (*Session) Clone

func (s *Session) Clone() *Session

func (*Session) SetAuthorizations

func (s *Session) SetAuthorizations(resources []string, privileges map[string]map[string]bool, enforced bool)

func (*Session) SetClaims

func (s *Session) SetClaims(claims map[string]interface{})

func (*Session) SetSource

func (s *Session) SetSource(source string)

func (*Session) SetSubject

func (s *Session) SetSubject(subject string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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