feat: add configurable JWT secret, anonymous authentication and standardize rust practices#1
Open
vihu wants to merge 2 commits intoKayleexx:mainfrom
Open
feat: add configurable JWT secret, anonymous authentication and standardize rust practices#1vihu wants to merge 2 commits intoKayleexx:mainfrom
vihu wants to merge 2 commits intoKayleexx:mainfrom
Conversation
…mode Add production-ready JWT configuration with environment variable support and an optional anonymous authentication mode for development/testing scenarios. JWT Secret Configuration: - Load CONFLUX_JWT_SECRET from environment via LazyLock - Panic in release builds if secret is not set - Use default dev secret in debug builds with warning Anonymous Authentication Mode: - Add validate_token_anonymous() that verifies JWT structure without signature verification, enabling client-generated tokens - Add --anonymous CLI flag to enable this mode - Add anonymous_mode field to AppState for conditional auth routing CLI Enhancements: - Migrate to clap with derive macros for argument parsing - Add --port, --host, --anonymous, and --idle-timeout flags - Emit warning when anonymous mode is enabled Infrastructure: - Consolidate dependencies to workspace level in root Cargo.toml - Add rust-toolchain.toml pinning stable with clippy, rustfmt, rust-analyzer - Add GitHub Actions CI workflow (fmt, clippy, build, test) Includes 12 unit tests covering token generation, validation, expiry, future-dated tokens, signature verification, and anonymous mode behavior.
- Fresh clients send an empty state vector when requesting initial sync. Previously this would fail during StateVector decoding. Now empty input is treated as "client has no state" and returns the full document. - Add tests for empty, valid, and invalid state vector inputs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello!
Firstly, thank you for starting this project and secondly I apologize for the large diff here.
Basically the changes in this branch are to bring the project upto some sort of production-ready standardization along with an introduction of anonymous mode for potentially hosting the server somewhere. That said, below is the full rundown of the most critical changes.
Summary
Changes
Authentication (
conflux/src/auth.rs)JWT_SECRETstatic viaLazyLockloading fromCONFLUX_JWT_SECRETenv varCONFLUX_JWT_SECRETis not set; use dev default in debug modevalidate_token_anonymous()function that validates JWT structure without signature verificationServer (
conflux/src/server.rs)anonymous_mode: boolfield toAppStateCLI (
confluxd/src/main.rs)--port,--host,--anonymous,--idle-timeoutargumentsInfrastructure
rust-toolchain.tomland.github/workflows/rust.ymlUsage
Breaking Changes
Production deployments must set CONFLUX_JWT_SECRET: Release builds will panic on startup if the environment variable is not set.