Documentation
¶
Index ¶
- Constants
- func AuthStatusCode(ctx context.Context) int
- func AuthorizedResources(ctx context.Context, method string) []string
- func CheckAccess(recordResources []string, userResources []string) bool
- func GetUserAuthz(ctx context.Context) []string
- func GetUserPrivileges(ctx context.Context) map[string]map[string]bool
- func HasAnyMethodAccess(ctx context.Context, resources []string, methods ...string) bool
- func HasAnyServiceMethodAccess(ctx context.Context, resources []string, service string, methods ...string) bool
- func HasAuthHeader(ctx context.Context) bool
- func HasMethodAccess(ctx context.Context, method string, resources []string) bool
- func HasObjectMethodAccess(ctx context.Context, method string, resources []string) bool
- func HasServiceMethodAccess(ctx context.Context, service, method string, resources []string) bool
- func IsAuthzEnforced(ctx context.Context) bool
- func IsGen3Mode(ctx context.Context) bool
- func ResourcePath(organization, project string) (string, error)
- func WithSession(ctx context.Context, session *Session) context.Context
- type AuthorizationError
- type Session
Constants ¶
const ( SourceAnonymous = "anonymous" SourceLocalBasic = "local-basic" SourceLocalCSV = "local-csv" SourceGen3Fence = "gen3-fence" SourceGen3Mock = "gen3-mock" SourcePlugin = "plugin" )
Variables ¶
This section is empty.
Functions ¶
func AuthStatusCode ¶
func AuthorizedResources ¶
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 ¶
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 ¶
GetUserAuthz returns the list of resources the user is authorized to access. If not found, returns empty list (no access to protected resources).
func HasAnyMethodAccess ¶
func HasAuthHeader ¶
func HasMethodAccess ¶
func HasObjectMethodAccess ¶
func HasServiceMethodAccess ¶
func IsAuthzEnforced ¶
func IsGen3Mode ¶
func ResourcePath ¶
ResourcePath returns the canonical resource path for an organization and optional project scope.
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) PublicMessage ¶
func (e *AuthorizationError) PublicMessage() string
func (*AuthorizationError) Unwrap ¶
func (e *AuthorizationError) Unwrap() error
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.