notiflux - subscribe over WebSockets, publish over REST

Overview

notiflux

notiflux is a pub/sub server where clients subscribe over a WebSocket and messages are broadcast over a POST request

How does it work?

Client connect via WebSocket and subscribe to topics. A publishing source will make POST requests to the broadcast endpoint, with a message and a topic, which will then publish the message to all connected clients.

Usage

Subscribing to topics

Clients connect over WebSocket and subscribe to the topics, which can be any string. The idea is that they could subscribe to something like campaign:<campaign_id> for notifications about a specific campaign, or even just campaigns for all campaign updates.

This is by calling the subscribe command with the topic and a token (see next section for token info)

/subscribe <topic> <token>

clients can then unsubscribe with

/unsubscribe <topic>  # From one topic
/unsubscribe-all      # From all topics

Broadcasting messages

To make a broadcast to a topic, a POST request must be made to /broadcast, which includes the topic, message and token

curl \
    -XPOST \
    -H "Content-Type: application/json" \
    -d '{"topic": "<topic>", "message": "<message>", "token": "<token>"}' \
    localhost:8080/broadcast

Auth token

Notiflux uses an EC256 public/private key pair JWT for authentication. Notiflux is deployed with the public key, while the broadcaster has the private key as a secret.

When clients connect, they need to provide a JWT with the topics and scope, signed by the private key. This token should be provided be the broadcasting source.

To make a broadcast, the broadcaster makes a POST request with a JWT as well, using the broadcast scope.

JWT structure

The JWT token needs to have the following payload:

{
    "sub": "notiflux",               // Can be any value
    "exp": 123,                      // Expiry just needs to be valid for the broadcast
                                     // or subscribe event, so just few seconds is enough
    "topics": ["topic"],             // The topics to validate against
    "scope": "subscribe|broadcast",  // Needs to be either 'subscribe' for clients
                                     // or 'broadcast' for broadcaster
}

Note that the topics can be a list of just one topic or multiple topics, which means the same JWT can be used to subscribe or broadcast to multiple topics.

See ./scripts folder for examples in Python

Deployment

notiflux is published as a docker container as ghcr.io/ikornaselur/notiflux:latest

The configuration is done through environment variables:

  • HOST: Defaults to 127.0.0.1
  • PORT: Defaults to 8080
  • JWT_PUBLIC_KEY_B64: Required, the base64 encoded public key

Generating a private key can be done with

openssl ecparam -genkey -name prime256v1 -out es256_private.pem

and then the public key

openssl ec -in es256_private.pem -pubout -out es256_public.pem

which can be base64 encoded with

cat es256_public.pem | base64

then running with docker is as simple as

docker run \
    -e JWT_PUBLIC_KEY_B64=... \
    -e HOST=0.0.0.0 \
    -p 127.0.0.1:8080:8080 \
    ghcr.io/ikornaselur/notiflux:latest
Comments
  • deps: Bump serde_json from 1.0.114 to 1.0.115

    deps: Bump serde_json from 1.0.114 to 1.0.115

    Bumps serde_json from 1.0.114 to 1.0.115.

    Release notes

    Sourced from serde_json's releases.

    v1.0.115

    • Documentation improvements
    Commits
    • b1ebf38 Release 1.0.115
    • c3dc153 Merge pull request #1119 from titaniumtraveler/pr
    • 218770b Explicitly install a Rust toolchain for cargo-outdated job
    • 840da8e Fix missing backticks in doc comments
    • 3a3f61b Temporarily disable miri on doctests
    • 4a0be88 Format regression tests with rustfmt
    • d2dbbf7 Ignore dead code lint in tests
    • 8e7b37b Merge pull request #1118 from serde-rs/transparent
    • a25f6c6 Remove conditional on repr(transparent)
    • fedf834 Ignore non_local_definitions false positive in test
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 2
  • chore(main): release 0.2.1

    chore(main): release 0.2.1

    opened by release-harbinger[bot] 1
  • chore(main): release 0.2.0

    chore(main): release 0.2.0

    :robot: I have created a release beep boop

    0.2.0 (2024-04-02)

    Features

    • Update JWTs to support multiple topics (#12) (b120327)

    Miscellaneous

    • Update readme with deployment info (#10) (19add21)
    • Update readme with multiple topics in JWT (#13) (b16bd47)

    This PR was generated with Release Please. See documentation.

    autorelease: tagged 
    opened by release-harbinger[bot] 1
  • chore(main): release 0.1.1

    chore(main): release 0.1.1

    :robot: I have created a release beep boop

    0.1.1 (2024-03-25)

    Miscellaneous

    • Add build-and-push github action (#8) (3ac969e)
    • Add healthcheck endpoint (#7) (370c52d)
    • Add tests for config (#4) (6bb836a)
    • Add workflows for test and release (2cc4509)
    • Provide codecov token directly (#5) (8ba240e)
    • Refactor channel/join to topic/subscribe (#6) (77c4ee8)
    • Replace anyhow with just basic error handling (#3) (44ea875)

    Dependencies

    • github-actions: bump codecov/codecov-action from 3 to 4 (b465f58)

    This PR was generated with Release Please. See documentation.

    autorelease: tagged 
    opened by release-harbinger[bot] 1
  • deps(github-actions): bump codecov/codecov-action from 3 to 4

    deps(github-actions): bump codecov/codecov-action from 3 to 4

    Bumps codecov/codecov-action from 3 to 4.

    Release notes

    Sourced from codecov/codecov-action's releases.

    v4.0.0

    v4 of the Codecov Action uses the CLI as the underlying upload. The CLI has helped to power new features including local upload, the global upload token, and new upcoming features.

    Breaking Changes

    • The Codecov Action runs as a node20 action due to node16 deprecation. See this post from GitHub on how to migrate.
    • Tokenless uploading is unsupported. However, PRs made from forks to the upstream public repos will support tokenless (e.g. contributors to OS projects do not need the upstream repo's Codecov token). This doc shows instructions on how to add the Codecov token.
    • OS platforms have been added, though some may not be automatically detected. To see a list of platforms, see our CLI download page
    • Various arguments to the Action have been changed. Please be aware that the arguments match with the CLI's needs

    v3 versions and below will not have access to CLI features (e.g. global upload token, ATS).

    What's Changed

    ... (truncated)

    Changelog

    Sourced from codecov/codecov-action's changelog.

    4.0.0-beta.2

    Fixes

    • #1085 not adding -n if empty to do-upload command

    4.0.0-beta.1

    v4 represents a move from the universal uploader to the Codecov CLI. Although this will unlock new features for our users, the CLI is not yet at feature parity with the universal uploader.

    Breaking Changes

    • No current support for aarch64 and alpine architectures.
    • Tokenless uploading is unsuported
    • Various arguments to the Action have been removed

    3.1.4

    Fixes

    • #967 Fix typo in README.md
    • #971 fix: add back in working dir
    • #969 fix: CLI option names for uploader

    Dependencies

    • #970 build(deps-dev): bump @​types/node from 18.15.12 to 18.16.3
    • #979 build(deps-dev): bump @​types/node from 20.1.0 to 20.1.2
    • #981 build(deps-dev): bump @​types/node from 20.1.2 to 20.1.4

    3.1.3

    Fixes

    • #960 fix: allow for aarch64 build

    Dependencies

    • #957 build(deps-dev): bump jest-junit from 15.0.0 to 16.0.0
    • #958 build(deps): bump openpgp from 5.7.0 to 5.8.0
    • #959 build(deps-dev): bump @​types/node from 18.15.10 to 18.15.12

    3.1.2

    Fixes

    • #718 Update README.md
    • #851 Remove unsupported path_to_write_report argument
    • #898 codeql-analysis.yml
    • #901 Update README to contain correct information - inputs and negate feature
    • #955 fix: add in all the extra arguments for uploader

    Dependencies

    • #819 build(deps): bump openpgp from 5.4.0 to 5.5.0
    • #835 build(deps): bump node-fetch from 3.2.4 to 3.2.10
    • #840 build(deps): bump ossf/scorecard-action from 1.1.1 to 2.0.4
    • #841 build(deps): bump @​actions/core from 1.9.1 to 1.10.0
    • #843 build(deps): bump @​actions/github from 5.0.3 to 5.1.1
    • #869 build(deps): bump node-fetch from 3.2.10 to 3.3.0
    • #872 build(deps-dev): bump jest-junit from 13.2.0 to 15.0.0
    • #879 build(deps): bump decode-uri-component from 0.2.0 to 0.2.2

    ... (truncated)

    Commits
    • 54bcd87 chore(release): v4.1.0 (#1307)
    • 8ba77ef build(deps-dev): bump eslint from 8.56.0 to 8.57.0 (#1305)
    • c60aa80 build(deps): bump github/codeql-action from 3.24.3 to 3.24.5 (#1306)
    • 2fc4847 fix: set safe directory (#1304)
    • 0cfda1d chore(release): bump to 4.0.2 (#1302)
    • 7d3a55e build(deps): bump actions/upload-artifact from 4.3.0 to 4.3.1 (#1286)
    • fe84a0b build(deps-dev): bump @​typescript-eslint/eslint-plugin from 6.21.0 to 7.0.0 (...
    • e12c940 Use updated syntax for GitHub Markdown notes (#1300)
    • ef7f8a5 build(deps): bump github/codeql-action from 3.24.0 to 3.24.3 (#1298)
    • b8a1d6a build(deps-dev): bump @​typescript-eslint/eslint-plugin from 6.20.0 to 6.21.0 ...
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 1
  • deps: Bump h2 from 0.3.25 to 0.3.26

    deps: Bump h2 from 0.3.25 to 0.3.26

    Bumps h2 from 0.3.25 to 0.3.26.

    Release notes

    Sourced from h2's releases.

    v0.3.26

    What's Changed

    • Limit number of CONTINUATION frames for misbehaving connections.

    See https://seanmonstar.com/blog/hyper-http2-continuation-flood/ for more info.

    Changelog

    Sourced from h2's changelog.

    0.3.26 (April 3, 2024)

    • Limit number of CONTINUATION frames for misbehaving connections.
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies rust 
    opened by dependabot[bot] 0
Releases(v0.2.1)
Owner
Axel Örn Sigurðsson
Axel Örn Sigurðsson
Lightweight, event-driven WebSockets for Rust.

WS-RS Lightweight, event-driven WebSockets for Rust. /// A WebSocket echo server listen("127.0.0.1:3012", |out| { move |msg| { out.send(ms

Jason Housley 1.3k Jan 8, 2023
Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions

websocat Netcat, curl and socat for WebSockets. Examples Connect to public echo server $ websocat ws://echo.websocket.org 123 123 ABC ABC Serve and c

Vitaly Shukela 5k Jan 4, 2023
Rust + wasm + websockets

This is a template repo for eframe, a framework for writing apps using egui.

Emil Ernerfeldt 12 Oct 3, 2022
Clearly a repo about websockets and their comparison...

Tags Go vs Typescript: Video 1 of the series is tag go-vs-ts-video-1 Current Project Video 2 and 3 are going to be likely Go vs Rust vs Typescript, bu

ThePrimeagen 344 Dec 31, 2022
Composable WebSockets made easy, for Rust 🦀

ezsockets Have you ever struggle with creating a WebSocket server or a client in Rust? This crate is for you. High level abstraction of WebSocket, han

Grzegorz Baranski 55 Dec 30, 2022
😎 A custom invoke system for Tauri that leverages WebSockets

?? tauri-awesome-rpc This is a crate provides a custom invoke system for Tauri using a localhost JSON RPC WebSocket. Each message is delivered through

Victor Aremu 20 Dec 2, 2022
Rust API connector for Bybit's WebSockets APIs.

rust-bybit English | 简体中文 Unofficial Rust API connector for Bybit's WebSockets APIs. Disclaimer This is an unofficial Rust API connector for Bybit's A

yufuquant 12 Nov 12, 2022
A MITM Proxy Written in Rust 🦀! Toolkit for HTTP/1, HTTP/2, and WebSockets with SSL/TLS Capabilities. Learning Project.

Man In The Middle Proxy Description Rust-based Man in the Middle proxy, an early-stage project aimed at providing visibility into network traffic. Cur

null 158 Mar 9, 2023
A command-line tool for exposing a wrapped program's standard IO using WebSockets/SSE

cmdpiped cmdpiped is a command-line tool for exposing a wrapped cli program's standard IO to WebSockets/SSE Installation Ready to use Binaries are ava

Geoffrey Mureithi 10 Nov 11, 2022
Services Info Register/KeepAlive/Publish/Subscribe. Based on etcd-rs, tokio

Services Info Register/KeepAlive/Publish/Subscribe. Based on etcd-rs, tokio

Mutalisk 5 Oct 4, 2022
Synchronized state machines for Rust over WebSockets.

Aper is a framework for real-time sharing of application state over WebSockets.

null 191 Dec 20, 2022
A simple web server(and library) to display server stats over HTTP and Websockets/SSE or stream it to other systems.

x-server-stats A simple web server(and library) to display server stats over HTTP and Websockets/SSE or stream it to other systems. x-server(in x-serv

Pratyaksh 11 Oct 17, 2022
A tool to subscribe to Twitch channels and store them efficiently on disk

twitch-messages A tool to subscribe to Twitch channels and store them efficiently on disk Build the Tools You can start by building the binaries that

Clément Renault 1 Oct 31, 2021
Subscribe to MQTT topics and push them to InfluxDB 1.x or v2

MQTT 2 InfluxDB Subscribe to MQTT topics and push them to InfluxDB 1.x or v2 Something like Telegraf for MQTT like it does with inputs.mqtt_consumer a

null 2 Feb 20, 2022
A tray application for Windows that gives you push notifications and instant downloads of new posts, messages and stories posted by models you subscribe to on Onlyfans.

OF-notifier A tray application for Windows that gives you push notifications and instant downloads of new posts, messages and stories posted by models

Gentlemen Mercenary 10 Dec 20, 2022
A wasm template for Rust to publish to gh-pages without npm-deploy

Wasm template for Rust hosting without npm-deploy on github pages using Travis script It automatically hosts you wasm projects on gh-pages using a tra

Siddharth Naithani 102 Dec 24, 2022
Travis CI and AppVeyor template to test your Rust crate on 5 architectures and publish binary releases of it for Linux, macOS and Windows

trust Travis CI and AppVeyor template to test your Rust crate on 5 architectures and publish binary releases of it for Linux, macOS and Windows Featur

Jorge Aparicio 1.2k Dec 30, 2022
A Rust CLI to provide last publish dates for packages in a package-lock.json file

NPM Package Age A Rust CLI which if you provide a npm lockfile (package-lock.json to start), it will give you a listing of all of the packages & the l

Benjamin Lannon 1 Feb 4, 2022
host, edit and publish markdown posts

insight insight is a web server allowing you to edit markdown posts and host the rendered result publicly. It has less than 40 dependencies in total.

Nathan Royer 3 Nov 16, 2022
Automatically publish MongoDB changes to Redis for Meteor.

changestream-to-redis Warning The project is currently in its alpha phase. There are no production loads using it yet nor any large-scale tests were c

Radosław Miernik 8 Jul 29, 2023