8000 feat: check puubkey to be allow before accept event · dezh-tech/ddsr@85754fc · GitHub
[go: up one dir, main page]

Skip to content

Commit

Permalink
feat: check puubkey to be allow before accept event
Browse files Browse the repository at this point in the history
  • Loading branch information
ZigBalthazar committed Feb 17, 2025
1 parent aa71488 commit 85754fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/workflows/zapoli-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ jobs:
tags: |
${{ steps.meta.outputs.tags }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BASE_TAG }}
labels: ${{ steps.meta.outputs.labels }}
images: ${{ env.IMAGES }} # Use the defined image names

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
Expand Down
9 changes: 8 additions & 1 deletion zapoli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ func main() {
relay.CountEvents = append(relay.CountEvents, persistStore.CountEvents)
relay.DeleteEvent = append(relay.DeleteEvent, persistStore.DeleteEvent)
relay.ReplaceEvent = append(relay.ReplaceEvent, persistStore.ReplaceEvent)
relay.RejectEvent = append(relay.RejectEvent, func(ctx context.Context, event *nostr.Event) (reject bool, msg string) {
if !slices.Contains(management.AllowedPubkeys, event.PubKey) {
return true, "unauthorized"
}

return false, "ok"
})

relay.RejectEvent = append(relay.RejectEvent, policies.ValidateKind)

Expand All @@ -78,7 +85,7 @@ func main() {
bl.DeleteBlob = append(bl.DeleteBlob, blobStorage.Delete)
bl.RejectUpload = append(bl.RejectUpload, func(ctx context.Context, auth *nostr.Event, size int, ext string) (bool, string, int) {
if !slices.Contains(management.AllowedPubkeys, auth.PubKey) {
return true, "Unauthorized to upload.", http.StatusUnauthorized
return true, "unauthorized", http.StatusUnauthorized
}

return false, "ok", http.StatusOK
Expand Down

0 comments on commit 85754fc

Please sign in to comment.
0