Documentation
¶
Index ¶
- Variables
- func EvaluatePolicy(policy *BucketPolicy, tokenID, action, objectKey, clientIP string) (allowed, denied bool)
- func EvaluatePolicyDeny(policy *BucketPolicy, tokenID, action, objectKey, clientIP string) bool
- func HashSecret(secret string) (string, error)
- type Auth
- func (a *Auth) Authenticate(r *http.Request) (*meta.Token, error)
- func (a *Auth) AuthenticateCredentials(tokenID, secret string) (*meta.Token, error)
- func (a *Auth) AuthenticateSigV4(r *http.Request) (*meta.Token, error)
- func (a *Auth) Authorize(token *meta.Token, action, bucketName, objectKey string) error
- func (a *Auth) AuthorizeWithPolicy(token *meta.Token, action, bucketName, objectKey, clientIP string, ...) error
- func (a *Auth) InvalidateToken(tokenID string)
- func (a *Auth) IsPublicRead(bucketName string) bool
- type BucketPolicy
- type PolicyConditions
- type PolicyStatement
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func EvaluatePolicy ¶
func EvaluatePolicy(policy *BucketPolicy, tokenID, action, objectKey, clientIP string) (allowed, denied bool)
EvaluatePolicy is a backward-compatible wrapper around EvaluatePolicyDeny. Deprecated: Use EvaluatePolicyDeny instead. The allowed return value is always false — policies in jay are deny-overlays on token-level permissions.
func EvaluatePolicyDeny ¶
func EvaluatePolicyDeny(policy *BucketPolicy, tokenID, action, objectKey, clientIP string) bool
EvaluatePolicyDeny checks policy deny statements against the request context. Returns true if any deny statement matches (access should be refused).
func HashSecret ¶
HashSecret hashes a secret for storage using bcrypt.
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth handles authentication and authorization.
func (*Auth) Authenticate ¶
Authenticate extracts and validates credentials from the request. Supports: Authorization: Bearer <token_id>:<secret>
func (*Auth) AuthenticateCredentials ¶
AuthenticateCredentials validates a token_id and secret pair directly, without requiring an HTTP request. Used by the native protocol.
func (*Auth) AuthenticateSigV4 ¶
AuthenticateSigV4 validates AWS Signature V4 auth from an HTTP request. Format: AWS4-HMAC-SHA256 Credential=<access-key>/<date>/<region>/s3/aws4_request,
SignedHeaders=<headers>, Signature=<signature>
func (*Auth) Authorize ¶
Authorize checks if the token has permission for the given action on the bucket/key.
func (*Auth) AuthorizeWithPolicy ¶
func (a *Auth) AuthorizeWithPolicy(token *meta.Token, action, bucketName, objectKey, clientIP string, policyJSON json.RawMessage) error
AuthorizeWithPolicy performs all existing Authorize checks and additionally evaluates a bucket policy (if provided) against the request context. Deny in the policy always takes precedence.
func (*Auth) InvalidateToken ¶
InvalidateToken removes all cache entries for a given token ID. Call this when a token is revoked or modified.
func (*Auth) IsPublicRead ¶
IsPublicRead checks if a bucket is publicly readable.
type BucketPolicy ¶
type BucketPolicy struct {
Version string `json:"version"`
Statements []PolicyStatement `json:"statements"`
}
BucketPolicy defines prefix-based access rules for a bucket.
func (*BucketPolicy) Compile ¶
func (p *BucketPolicy) Compile()
Compile pre-parses all CIDRs in the policy statements so that matchesIPConditionNets can use them without re-parsing on every request. Call this after unmarshalling a BucketPolicy.
type PolicyConditions ¶
type PolicyConditions struct {
IPWhitelist []string `json:"ip_whitelist,omitempty"` // CIDR notation
// contains filtered or unexported fields
}
PolicyConditions holds optional conditions for a policy statement.
type PolicyStatement ¶
type PolicyStatement struct {
Effect string `json:"effect"` // "allow" or "deny"
Actions []string `json:"actions"` // e.g. ["object:get", "object:list"] or ["*"]
Prefixes []string `json:"prefixes"` // e.g. ["public/", "shared/"], empty = all
Subjects []string `json:"subjects"` // token IDs or "*" for any authenticated
Conditions *PolicyConditions `json:"conditions,omitempty"`
}
PolicyStatement is a single allow/deny rule within a bucket policy.