mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-09-20 17:24:16 +00:00
more logging to troubleshoot crew management
This commit is contained in:
@@ -97,13 +97,18 @@ func (p *ProxyBlobStore) checkWriteAccess(ctx context.Context) error {
|
||||
if p.ctx.Authorizer == nil {
|
||||
return nil // No authorization check if authorizer not configured
|
||||
}
|
||||
|
||||
fmt.Printf("[checkWriteAccess] Checking write access for userDID=%s to holdDID=%s\n", p.ctx.DID, p.ctx.HoldDID)
|
||||
allowed, err := p.ctx.Authorizer.CheckWriteAccess(ctx, p.ctx.HoldDID, p.ctx.DID)
|
||||
if err != nil {
|
||||
fmt.Printf("[checkWriteAccess] Authorization check error: %v\n", err)
|
||||
return fmt.Errorf("authorization check failed: %w", err)
|
||||
}
|
||||
if !allowed {
|
||||
fmt.Printf("[checkWriteAccess] Write access DENIED for userDID=%s to holdDID=%s\n", p.ctx.DID, p.ctx.HoldDID)
|
||||
return fmt.Errorf("write access denied to hold %s", p.ctx.HoldDID)
|
||||
}
|
||||
fmt.Printf("[checkWriteAccess] Write access ALLOWED for userDID=%s to holdDID=%s\n", p.ctx.DID, p.ctx.HoldDID)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -55,18 +55,27 @@ func CheckReadAccessWithCaptain(captain *atproto.CaptainRecord, userDID string)
|
||||
// - Must be authenticated
|
||||
// - Must be hold owner OR crew member
|
||||
func CheckWriteAccessWithCaptain(captain *atproto.CaptainRecord, userDID string, isCrew bool) bool {
|
||||
fmt.Printf("[CheckWriteAccessWithCaptain] userDID=%s captain.Owner=%s isCrew=%v\n", userDID, captain.Owner, isCrew)
|
||||
|
||||
if userDID == "" {
|
||||
// Anonymous writes not allowed
|
||||
fmt.Printf("[CheckWriteAccessWithCaptain] DENIED: Anonymous user\n")
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if DID is the hold owner
|
||||
if userDID == captain.Owner {
|
||||
// Owner always has write access
|
||||
fmt.Printf("[CheckWriteAccessWithCaptain] ALLOWED: User is hold owner\n")
|
||||
return true
|
||||
}
|
||||
|
||||
// Check if DID is a crew member
|
||||
if isCrew {
|
||||
fmt.Printf("[CheckWriteAccessWithCaptain] ALLOWED: User is crew member\n")
|
||||
} else {
|
||||
fmt.Printf("[CheckWriteAccessWithCaptain] DENIED: User is not owner or crew\n")
|
||||
}
|
||||
return isCrew
|
||||
}
|
||||
|
||||
|
||||
@@ -265,27 +265,33 @@ func (a *RemoteHoldAuthorizer) IsCrewMember(ctx context.Context, holdDID, userDI
|
||||
|
||||
// Check approval cache first (15min TTL)
|
||||
if approved, err := a.getCachedApproval(holdDID, userDID); err == nil && approved {
|
||||
fmt.Printf("[IsCrewMember] Using cached APPROVAL: holdDID=%s userDID=%s\n", holdDID, userDID)
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// Check denial cache with backoff
|
||||
if blocked, err := a.isBlockedByDenialBackoff(holdDID, userDID); err == nil && blocked {
|
||||
// Still in backoff period - don't query again
|
||||
fmt.Printf("[IsCrewMember] BLOCKED by denial backoff cache: holdDID=%s userDID=%s\n", holdDID, userDID)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// Cache miss or expired - query XRPC endpoint
|
||||
fmt.Printf("[IsCrewMember] Cache miss, querying hold: holdDID=%s userDID=%s\n", holdDID, userDID)
|
||||
isCrew, err := a.isCrewMemberNoCache(ctx, holdDID, userDID)
|
||||
if err != nil {
|
||||
fmt.Printf("[IsCrewMember] Query error: %v\n", err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
// Update cache based on result
|
||||
if isCrew {
|
||||
// Cache approval for 15 minutes
|
||||
fmt.Printf("[IsCrewMember] Query result: APPROVED, caching for 15min\n")
|
||||
_ = a.cacheApproval(holdDID, userDID, 15*time.Minute)
|
||||
} else {
|
||||
// Cache denial with exponential backoff
|
||||
fmt.Printf("[IsCrewMember] Query result: DENIED, caching with backoff\n")
|
||||
_ = a.cacheDenial(holdDID, userDID)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user