Coder Social home page Coder Social logo

thesimplekid / manage-relay-users Goto Github PK

View Code? Open in Web Editor NEW
5.0 4.0 3.0 165 KB

gRPC plugin for nostr-rs-relay to mange admited users via API or nostr event

License: BSD 3-Clause "New" or "Revised" License

Rust 98.24% Just 1.76%
nostr nostr-relay nostr-rs-relay

manage-relay-users's Introduction

Manage relay users gRPC Server

License

gRPC Extensions for nostr-rs-relay

gRPC authz server for nostr-rs-rely. Admits events based on whether they have been allowed by the relay admin.

Build and Run

This package is an extension of nostr-rs-relay and the instructions here assume the relay exists in ./nostr-rs-relay/

  1. Make sure you are running the latest version of Rust, if you installed with rustup:
rustup update
  1. Clone and compile
git clone https://github.com/thesimplekid/manage-relay-users.git
cd manage-relay-users
cargo build -r
  1. Edit the config file.
vim config.toml

Add a secret key. Categorized People Lists from this key will update the allowed and denied users. If the users are updated via http api this extension with publish an update list, this enables the extension to restore from the lists stored on configured relays.

Uncomment the grpc and db_path lines.

  1. Edit the config of the relay
cd ../nostr-rs-relay
vim config.toml

Find the line with event_admission_server

[grpc]
# event_admission_server = "http://[::1]:50051" <---- this line

Uncomment this line and change it to reflect your local setup that matches the grpc config you used above. For example:

event_admission_server = "http://127.0.0.1:50001"
  1. Run You will need to use screen or tmux or a different terminal tab so that you can run two processes. Start the relay manager first:
cd ../manage-relay-users
./target/release/manage_relay_users --config config.toml

In a different terminal on the same system:

cd ../nostr-rs-relay
RUST_LOG=warn,nostr_rs_relay=info ./target/release/nostr-rs-relay --config config.toml

Managing Users

Via Nostr

Allowed and Denied pubkeys are maintained in two Categorized People Lists. The nsec set in the config file is used by clients to publish list an allow list and a deny with the format set in NIP-51.

HTTP API


The users can be updated by sending a http `POST` to the  `/update` endpoint with a json body with the following format.
This extension with publish an updated Categorized People List with the updated users.

```json
{
    "allow":, [<32-bytes hex of a pubkey>,  <32-bytes hex of a pubkey>, ...],
    "deny": [<32-bytes hex of a pubkey>, <32-bytes hex of a pubkey>, ...],
}

There is also a GET endpoint with at /users that will return json of the same format with allowed and denied users.

If the relay has nip42 enabled it will use the authenticated pubkey if not the author pubkey of the note will be used.

License

Code is under the BSD 3-Clause License

Contact

I can be contacted for comments or questions on nostr at [email protected] (npub1qjgcmlpkeyl8mdkvp4s0xls4ytcux6my606tgfx9xttut907h0zs76lgjw) or via email [email protected].

manage-relay-users's People

Contributors

gsovereignty avatar thesimplekid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

manage-relay-users's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.