about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgennyble <gen@nyble.dev>2026-09-26 02:19:13 -0500
committergennyble <gen@nyble.dev>2026-09-26 02:19:13 -0500
commit10cd0527b16aa3d01cb4af708917ad95db142a1b (patch)
treeaef45da935eb79ce92a2ffe51433153322a2092c
parent90cb2ffd874a1aeecaf4ace90c0c1155f28287b5 (diff)
allow turning off registration
-rw-r--r--splorm/README.md3
-rw-r--r--splorm/splorm.conf3
-rw-r--r--splorm/src/config.rs11
-rw-r--r--splorm/src/handler/api/auth.rs9
4 files changed, 24 insertions, 2 deletions
diff --git a/splorm/README.md b/splorm/README.md
index cabbacd..846c813 100644
--- a/splorm/README.md
+++ b/splorm/README.md
@@ -8,6 +8,9 @@ location of configuration file
 ## Configuration File Variables
 `Database` - Location of the database
 
+### Section: `Auth`
+`AllowRegistration` - Whether or not registration is enabled
+
 #### Section: `Network`
 `Port` - Port to listen on
 
diff --git a/splorm/splorm.conf b/splorm/splorm.conf
index 53aeeea..9900ff0 100644
--- a/splorm/splorm.conf
+++ b/splorm/splorm.conf
@@ -17,5 +17,8 @@ Serving /Users/gen/src/inf/served
 
 Database /Users/gen/src/awake/database.splorm
 
+Auth
+	AllowRegistration false
+
 Connectors
 	Gatherer /var/run/gatherer/socket
diff --git a/splorm/src/config.rs b/splorm/src/config.rs
index 2a4ed6c..528c519 100644
--- a/splorm/src/config.rs
+++ b/splorm/src/config.rs
@@ -72,6 +72,9 @@ impl Config {
 		let me_sec = serving.child("Me").unwrap();
 		let me_email = me_sec.child_owned("Email").unwrap();
 
+		let auth_sec = confi.child("Auth").unwrap();
+		let allow_registration = auth_sec.child_parse("AllowRegistration").unwrap();
+
 		let database_path = confi.child_parse("Database").unwrap();
 
 		let connectors_sec = confi.child("Connectors").unwrap();
@@ -93,6 +96,8 @@ impl Config {
 
 				me_email,
 
+				allow_registration,
+
 				database_path,
 
 				uploads,
@@ -134,6 +139,8 @@ pub struct Settings {
 
 	me_email: String,
 
+	allow_registration: bool,
+
 	database_path: Utf8PathBuf,
 
 	uploads: Utf8PathBuf,
@@ -191,6 +198,10 @@ impl Settings {
 		&self.me_email
 	}
 
+	pub fn registration_enabled(&self) -> bool {
+		self.allow_registration
+	}
+
 	pub fn database_path(&self) -> &Utf8Path {
 		&self.database_path
 	}
diff --git a/splorm/src/handler/api/auth.rs b/splorm/src/handler/api/auth.rs
index e90eafe..a256ffd 100644
--- a/splorm/src/handler/api/auth.rs
+++ b/splorm/src/handler/api/auth.rs
@@ -5,21 +5,26 @@
 
 use std::time::Duration;
 
-use axum::{body::Body, extract::State, http::StatusCode, response::Response};
+use axum::{Extension, body::Body, extract::State, http::StatusCode, response::Response};
 use gny::web::cookie::{self, SetCookie};
 use sessionhash::RequestContext;
 use somethings::auth::Session;
 
-use crate::{Query, RuntimeError, extractor::Wrap, state::SplormState};
+use crate::{Query, RuntimeError, config::Settings, extractor::Wrap, state::SplormState};
 
 /// POST /auth/register
 pub async fn register(
 	State(state): State<SplormState>,
+	Extension(settings): Extension<Settings>,
 	ctx: RequestContext,
 	body: String,
 ) -> Result<Response, RuntimeError> {
 	tracing::trace!("{ctx} GET /api/register");
 
+	if !settings.registration_enabled() {
+		return Err(RuntimeError::Generic403);
+	}
+
 	macro_rules! get {
 		($query:ident $field:literal) => {
 			$query