Documentation
¶
Index ¶
- func DaysSince(t time.Time) int
- func HoursSince(t time.Time) int
- func IPInRange(ip string, cidrs []string) bool
- func InTimeRange(now time.Time, start, end string) bool
- func IsWeekday(t time.Time) bool
- type ContextAttributeProvider
- type DeviceInfo
- type Geolocation
- type MockResourceService
- type MockUserService
- type RequestContext
- type Resource
- type ResourceAttributeProvider
- type ResourceRequest
- type ResourceService
- type User
- type UserAttributeProvider
- type UserService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HoursSince ¶
HoursSince returns the number of hours since the given time
func InTimeRange ¶
InTimeRange checks if current time is between start and end times (24-hour format) start and end are in format "HH:MM" (e.g., "09:00", "17:00")
Types ¶
type ContextAttributeProvider ¶
type ContextAttributeProvider struct {
}
ContextAttributeProvider provides request context attributes
func NewContextAttributeProvider ¶
func NewContextAttributeProvider() *ContextAttributeProvider
NewContextAttributeProvider creates a new context attribute provider
func (*ContextAttributeProvider) GetAttributes ¶
func (p *ContextAttributeProvider) GetAttributes(ctx context.Context, key string) (map[string]interface{}, error)
GetAttributes returns the request context attributes key is ignored as context is typically set directly in the evaluation context
func (*ContextAttributeProvider) GetBatchAttributes ¶
func (p *ContextAttributeProvider) GetBatchAttributes(ctx context.Context, keys []string) (map[string]map[string]interface{}, error)
GetBatchAttributes returns context attributes for multiple keys For context, batch operations don't make much sense, so we return individual contexts
func (*ContextAttributeProvider) Name ¶
func (p *ContextAttributeProvider) Name() string
Name returns the provider name
type DeviceInfo ¶
type DeviceInfo struct {
Type string `json:"type"` // mobile, desktop, tablet
OS string `json:"os"` // iOS, Android, Windows, macOS, Linux
Browser string `json:"browser"` // Chrome, Firefox, Safari, etc.
IsMobile bool `json:"is_mobile"`
IsDesktop bool `json:"is_desktop"`
}
DeviceInfo contains device-specific information
type Geolocation ¶
type Geolocation struct {
Country string `json:"country"`
Region string `json:"region"`
City string `json:"city"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Timezone string `json:"timezone"`
}
Geolocation contains geographic information about the request
type MockResourceService ¶
type MockResourceService struct {
// contains filtered or unexported fields
}
MockResourceService provides a mock implementation for testing
func NewMockResourceService ¶
func NewMockResourceService() *MockResourceService
NewMockResourceService creates a new mock resource service
func (*MockResourceService) AddResource ¶
func (m *MockResourceService) AddResource(resource *Resource)
AddResource adds a resource to the mock service
func (*MockResourceService) GetResource ¶
func (m *MockResourceService) GetResource(ctx context.Context, resourceType, resourceID string) (*Resource, error)
GetResource fetches a resource by type and ID
func (*MockResourceService) GetResources ¶
func (m *MockResourceService) GetResources(ctx context.Context, requests []ResourceRequest) ([]*Resource, error)
GetResources fetches multiple resources
type MockUserService ¶
type MockUserService struct {
// contains filtered or unexported fields
}
MockUserService provides a mock implementation for testing
func NewMockUserService ¶
func NewMockUserService() *MockUserService
NewMockUserService creates a new mock user service
func (*MockUserService) AddUser ¶
func (m *MockUserService) AddUser(user *User)
AddUser adds a user to the mock service
type RequestContext ¶
type RequestContext struct {
IP string `json:"ip"`
UserAgent string `json:"user_agent"`
Method string `json:"method"`
Path string `json:"path"`
Timestamp time.Time `json:"timestamp"`
Geolocation *Geolocation `json:"geolocation,omitempty"`
Device *DeviceInfo `json:"device,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
RequestContext contains ephemeral request-specific data
type Resource ¶
type Resource struct {
ID string `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
Owner string `json:"owner"`
OrgID string `json:"org_id"`
TeamID string `json:"team_id"`
ProjectID string `json:"project_id"`
Visibility string `json:"visibility"` // public, private, team, org
Status string `json:"status"` // active, archived, deleted
Tags []string `json:"tags"`
Metadata map[string]interface{} `json:"metadata"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
CreatedBy string `json:"created_by"`
Confidential string `json:"confidential"` // public, internal, confidential, secret
}
Resource represents resource data for attribute resolution
type ResourceAttributeProvider ¶
type ResourceAttributeProvider struct {
// contains filtered or unexported fields
}
ResourceAttributeProvider fetches resource attributes from resource services
func NewResourceAttributeProvider ¶
func NewResourceAttributeProvider(resourceService ResourceService) *ResourceAttributeProvider
NewResourceAttributeProvider creates a new resource attribute provider
func (*ResourceAttributeProvider) GetAttributes ¶
func (p *ResourceAttributeProvider) GetAttributes(ctx context.Context, key string) (map[string]interface{}, error)
GetAttributes fetches resource attributes key is expected to be in format "type:id" (e.g., "document:123")
func (*ResourceAttributeProvider) GetBatchAttributes ¶
func (p *ResourceAttributeProvider) GetBatchAttributes(ctx context.Context, keys []string) (map[string]map[string]interface{}, error)
GetBatchAttributes fetches attributes for multiple resources
func (*ResourceAttributeProvider) Name ¶
func (p *ResourceAttributeProvider) Name() string
Name returns the provider name
type ResourceRequest ¶
ResourceRequest represents a request for a specific resource
type ResourceService ¶
type ResourceService interface {
// GetResource fetches a resource by type and ID
GetResource(ctx context.Context, resourceType, resourceID string) (*Resource, error)
// GetResources fetches multiple resources
GetResources(ctx context.Context, requests []ResourceRequest) ([]*Resource, error)
}
ResourceService defines the interface for fetching resource data This should be implemented by your application's resource services
type User ¶
type User struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
Roles []string `json:"roles"`
Groups []string `json:"groups"`
OrgID string `json:"org_id"`
Department string `json:"department"`
Permissions []string `json:"permissions"`
Metadata map[string]interface{} `json:"metadata"`
CreatedAt string `json:"created_at"`
EmailVerified bool `json:"email_verified"`
Active bool `json:"active"`
}
User represents user data for attribute resolution
type UserAttributeProvider ¶
type UserAttributeProvider struct {
// contains filtered or unexported fields
}
UserAttributeProvider fetches user attributes from the user service
func NewUserAttributeProvider ¶
func NewUserAttributeProvider(userService UserService) *UserAttributeProvider
NewUserAttributeProvider creates a new user attribute provider
func (*UserAttributeProvider) GetAttributes ¶
func (p *UserAttributeProvider) GetAttributes(ctx context.Context, key string) (map[string]interface{}, error)
GetAttributes fetches user attributes by user ID
func (*UserAttributeProvider) GetBatchAttributes ¶
func (p *UserAttributeProvider) GetBatchAttributes(ctx context.Context, keys []string) (map[string]map[string]interface{}, error)
GetBatchAttributes fetches attributes for multiple users
func (*UserAttributeProvider) Name ¶
func (p *UserAttributeProvider) Name() string
Name returns the provider name
type UserService ¶
type UserService interface {
// GetUser fetches a user by ID
GetUser(ctx context.Context, userID string) (*User, error)
// GetUsers fetches multiple users by IDs
GetUsers(ctx context.Context, userIDs []string) ([]*User, error)
}
UserService defines the interface for fetching user data This should be implemented by AuthSome's user service