Documentation
¶
Index ¶
- func NewAccessControlChecker(ctx context.Context, config Config) (port.AccessControlChecker, error)
- type AccessCheckNATSRequest
- type AccessCheckNATSResponse
- type Config
- type NATSAccessControlChecker
- func (n *NATSAccessControlChecker) CheckAccess(ctx context.Context, subj string, data []byte, timeout time.Duration) (model.AccessCheckResult, error)
- func (n *NATSAccessControlChecker) Close() error
- func (n *NATSAccessControlChecker) IsReady(ctx context.Context) error
- func (n *NATSAccessControlChecker) ReadTuples(ctx context.Context, user string, objectType string, timeout time.Duration) ([]string, error)
- type NATSClient
- func (c *NATSClient) CheckAccess(ctx context.Context, request *AccessCheckNATSRequest) (AccessCheckNATSResponse, error)
- func (c *NATSClient) Close() error
- func (c *NATSClient) IsReady(ctx context.Context) error
- func (c *NATSClient) ReadTuples(ctx context.Context, request *ReadTuplesNATSRequest) (*ReadTuplesNATSResponse, error)
- type NATSClientInterface
- type ReadTuplesNATSRequest
- type ReadTuplesNATSResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAccessControlChecker ¶
NewAccessControlChecker creates a new NATS access control checker
Types ¶
type AccessCheckNATSRequest ¶
type AccessCheckNATSRequest struct {
// Subject is the NATS subject for the request
Subject string `json:"subject"`
// Message is the serialized request data
Message []byte `json:"message"`
// Timeout is the request timeout duration
Timeout time.Duration `json:"timeout"`
}
AccessCheckNATSRequest represents a NATS request for access checking
type AccessCheckNATSResponse ¶
AccessCheckNATSResponse represents a NATS response for access checking
type Config ¶
type Config struct {
// URL is the NATS server URL
URL string `json:"url"`
// Timeout is the request timeout duration
Timeout time.Duration `json:"timeout"`
// MaxReconnect is the maximum number of reconnection attempts
MaxReconnect int `json:"max_reconnect"`
// ReconnectWait is the time to wait between reconnection attempts
ReconnectWait time.Duration `json:"reconnect_wait"`
}
Config represents NATS configuration
type NATSAccessControlChecker ¶
type NATSAccessControlChecker struct {
// contains filtered or unexported fields
}
NATSAccessControlChecker implements the AccessControlChecker interface for NATS
func (*NATSAccessControlChecker) CheckAccess ¶
func (n *NATSAccessControlChecker) CheckAccess(ctx context.Context, subj string, data []byte, timeout time.Duration) (model.AccessCheckResult, error)
CheckAccess implements the AccessControlChecker interface
func (*NATSAccessControlChecker) Close ¶
func (n *NATSAccessControlChecker) Close() error
Close gracefully closes the NATS connection
type NATSClient ¶
type NATSClient struct {
// contains filtered or unexported fields
}
NATSClient wraps the NATS connection and provides access control operations
func NewClient ¶
func NewClient(ctx context.Context, config Config) (*NATSClient, error)
NewClient creates a new NATS client with the given configuration
func (*NATSClient) CheckAccess ¶
func (c *NATSClient) CheckAccess(ctx context.Context, request *AccessCheckNATSRequest) (AccessCheckNATSResponse, error)
CheckAccess sends an access control request via NATS and waits for the response
func (*NATSClient) Close ¶
func (c *NATSClient) Close() error
Close gracefully closes the NATS connection
func (*NATSClient) IsReady ¶
func (c *NATSClient) IsReady(ctx context.Context) error
IsReady checks if the NATS client is ready
func (*NATSClient) ReadTuples ¶ added in v0.4.17
func (c *NATSClient) ReadTuples(ctx context.Context, request *ReadTuplesNATSRequest) (*ReadTuplesNATSResponse, error)
ReadTuples sends a read_tuples request via NATS and returns the parsed response
type NATSClientInterface ¶
type NATSClientInterface interface {
CheckAccess(ctx context.Context, request *AccessCheckNATSRequest) (AccessCheckNATSResponse, error)
ReadTuples(ctx context.Context, request *ReadTuplesNATSRequest) (*ReadTuplesNATSResponse, error)
Close() error
IsReady(ctx context.Context) error
}
NATSClientInterface defines the interface for NATS operations This allows for easy mocking and testing
type ReadTuplesNATSRequest ¶ added in v0.4.17
type ReadTuplesNATSRequest struct {
User string `json:"user"`
ObjectType string `json:"object_type"`
Timeout time.Duration `json:"-"`
}
ReadTuplesNATSRequest represents a NATS request for reading FGA tuples
type ReadTuplesNATSResponse ¶ added in v0.4.17
type ReadTuplesNATSResponse struct {
Results []string `json:"results"`
Error string `json:"error,omitempty"`
}
ReadTuplesNATSResponse represents a NATS response for reading FGA tuples