A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
feat(admin): allow single sign-on as the only admin sign-in (#3835)
Hampus46b7d18d5c53
diff --git a/fluxer_admin/openapi-admin.json b/fluxer_admin/openapi-admin.jsonindex 0ff05b4e5..67f518ff6 100644--- a/fluxer_admin/openapi-admin.json+++ b/fluxer_admin/openapi-admin.json@@ -24814,15 +24814,30 @@},"InstantAccountAvailabilitySchema": {"description": "Whether accounts can be created from just a display name, and why not",- "x-enumNames": ["AVAILABLE", "DISABLED", "CAPTCHA_OFF", "REGISTRATION_CLOSED", "APPROVAL_REQUIRED"],+ "x-enumNames": [+ "AVAILABLE",+ "DISABLED",+ "CAPTCHA_OFF",+ "REGISTRATION_CLOSED",+ "APPROVAL_REQUIRED",+ "EMAIL_DOMAINS_RESTRICTED"+ ],"x-enumDescriptions": ["Accounts can be created from a display name","Instant accounts are turned off","Instant accounts need the captcha, which is off","Public registration is closed",- "New accounts need approval, so they need credentials to sign in once approved"+ "New accounts need approval, so they need credentials to sign in once approved",+ "Public sign-ups must use an email address on an allowed domain"+ ],+ "enum": [+ "available",+ "disabled",+ "captcha_off",+ "registration_closed",+ "approval_required",+ "email_domains_restricted"],- "enum": ["available", "disabled", "captcha_off", "registration_closed", "approval_required"],"type": "string"},"CaptchaConfigResponse": {diff --git a/fluxer_admin/src/config/mod.rs b/fluxer_admin/src/config/mod.rsindex 4ac105d7e..1e86c6bec 100644--- a/fluxer_admin/src/config/mod.rs+++ b/fluxer_admin/src/config/mod.rs@@ -37,6 +37,7 @@ pub struct SsoConfig {pub client_secret: String,pub redirect_uri: String,pub display_name: Option<String>,+ pub only: bool,}#[derive(Clone, Debug)]@@ -165,8 +166,12 @@ fn sso_config_from_env(admin_endpoint: &str) -> anyhow::Result<Option<SsoConfig>env_value("FLUXER_ADMIN_SSO_ISSUER").map(|value| trim_trailing_slash(value.trim()));let client_id = env_value("FLUXER_ADMIN_SSO_CLIENT_ID");let client_secret = env_value("FLUXER_ADMIN_SSO_CLIENT_SECRET");+ let only = read_bool_env("FLUXER_ADMIN_SSO_ONLY", false);let (issuer, client_id, client_secret) = match (issuer, client_id, client_secret) {(Some(issuer), Some(client_id), Some(client_secret)) => (issuer, client_id, client_secret),+ (None, None, None) if only => anyhow::bail!(+ "FLUXER_ADMIN_SSO_ONLY needs FLUXER_ADMIN_SSO_ISSUER, FLUXER_ADMIN_SSO_CLIENT_ID and FLUXER_ADMIN_SSO_CLIENT_SECRET"+ ),(None, None, None) => return Ok(None),_ => anyhow::bail!("set FLUXER_ADMIN_SSO_ISSUER, FLUXER_ADMIN_SSO_CLIENT_ID and FLUXER_ADMIN_SSO_CLIENT_SECRET together, or none of them"@@ -184,6 +189,7 @@ fn sso_config_from_env(admin_endpoint: &str) -> anyhow::Result<Option<SsoConfig>redirect_uri,display_name: env_value("FLUXER_ADMIN_SSO_DISPLAY_NAME").map(|value| value.trim().to_owned()),+ only,}))}diff --git a/fluxer_admin/src/middleware/auth.rs b/fluxer_admin/src/middleware/auth.rsindex 4222d584d..a5c578574 100644--- a/fluxer_admin/src/middleware/auth.rs+++ b/fluxer_admin/src/middleware/auth.rs@@ -42,7 +42,9 @@ pub async fn require_auth(let config = state.config();let session = extract_session(&request, &config.secret_key_base);let Some(session) = session else {- let entry = if config.sso.is_some() {+ let entry = if config.sso.as_ref().is_some_and(|sso| sso.only) {+ "sso/start"+ } else if config.sso.is_some() {"login"} else {"auth/start"diff --git a/fluxer_admin/src/routes/auth.rs b/fluxer_admin/src/routes/auth.rsindex 8bef457ec..8b137b954 100644--- a/fluxer_admin/src/routes/auth.rs+++ b/fluxer_admin/src/routes/auth.rs@@ -102,6 +102,9 @@ async fn login_page(async fn auth_start(State(state): State<AppState>) -> Response {let config = state.config();+ if let Some(response) = sso_only_redirect(config) {+ return response;+ }let verifier = random_nonce();let oauth_state = generate_oauth_state(&config.secret_key_base, OAUTH_STATE_PURPOSE, &verifier);let authorize_url = oauth2::authorize_url(config, &oauth_state);@@ -248,6 +251,9 @@ async fn oauth2_callback_page(Query(query): Query<CallbackQuery>,) -> Response {let config = state.config();+ if let Some(response) = sso_only_redirect(config) {+ return response;+ }Html(oauth_callback_page(config,OAUTH_FLOW_STORAGE_KEY,@@ -267,6 +273,14 @@ async fn oauth2_callback_finish(let config = state.config();let base = &config.base_path;+ if config.sso.as_ref().is_some_and(|sso| sso.only) {+ return oauth_finish_response(+ StatusCode::FORBIDDEN,+ &format!("{base}/login?error=sso_only"),+ &[],+ );+ }+if !has_finish_header(&headers) {return oauth_finish_response(StatusCode::FORBIDDEN,@@ -686,8 +700,15 @@ fn sso_sign_in_error_code(err: &ApiError) -> &'static str {}}+fn sso_only_redirect(config: &crate::config::AdminConfig) -> Option<Response> {+ config.sso.as_ref().filter(|sso| sso.only).map(|_| {+ Redirect::to(&format!("{}/login?error=sso_only", config.base_path)).into_response()+ })+}+fn login_error_message(code: &str) -> &'static str {match code {+ "sso_only" => "Signing in with your Fluxer account is turned off here. Use single sign-on.","oauth_failed" => "Authentication failed. Please try again.","sso_failed" => "Single sign-on failed. Try again.","sso_unavailable" => "Could not reach the sign-on provider. Try again in a moment.",diff --git a/fluxer_admin/src/templates/pages/instance_config/accounts.rs b/fluxer_admin/src/templates/pages/instance_config/accounts.rsindex 05cfa7f7a..a734a51dc 100644--- a/fluxer_admin/src/templates/pages/instance_config/accounts.rs+++ b/fluxer_admin/src/templates/pages/instance_config/accounts.rs@@ -149,6 +149,9 @@ fn instant_account_inactive_reason(InstantAccountAvailability::ApprovalRequired => {Some("Inactive: new accounts need approval")}+ InstantAccountAvailability::EmailDomainsRestricted => {+ Some("Inactive: sign-ups need an allowed email domain")+ }}}@@ -265,7 +268,8 @@ pub(super) fn accounts_section((format!("New people type the name others see and start right away. {name_source}, \and they {} later to keep the account. This works while registration \- is open, or through a registration link that does not need approval.",+ is open and no allowed email domains are set, or through a registration \+ link that does not need approval.",wording.step))} @else {diff --git a/fluxer_admin/src/templates/pages/instance_registration.rs b/fluxer_admin/src/templates/pages/instance_registration.rsindex 0465e06f2..f5d59471b 100644--- a/fluxer_admin/src/templates/pages/instance_registration.rs+++ b/fluxer_admin/src/templates/pages/instance_registration.rs@@ -72,7 +72,7 @@ fn registration_policy_form((allowed_domains_input(REGISTRATION_ALLOWED_EMAIL_DOMAINS_FIELD,®istration.allowed_email_domains.join("\n"),- "Only email addresses on these domains (one per line) can sign up, claim an account or become an account's new email. People with an admin-issued registration URL can use any domain. Leave empty to allow any domain.",+ "Only email addresses on these domains (one per line) can sign up, claim an account or become an account's new email. People with an admin-issued registration URL can use any domain. While this is set, everyone else needs an email address to sign up. Leave empty to allow any domain.",))}(form_actions(html! {diff --git a/fluxer_admin/src/templates/pages/login.rs b/fluxer_admin/src/templates/pages/login.rsindex 36a647690..b3b18dd23 100644--- a/fluxer_admin/src/templates/pages/login.rs+++ b/fluxer_admin/src/templates/pages/login.rs@@ -45,7 +45,9 @@ pub fn login_page(}@if let Some(sso) = &config.sso {div class="flex flex-col gap-3 items-center w-full" {- (fluxer_sign_in_button(base, branding))+ @if !sso.only {+ (fluxer_sign_in_button(base, branding))+ }a href={(base) "/sso/start"} role="button"class="inline-flex items-center justify-center gap-2 \font-medium rounded-lg transition-all duration-150 \diff --git a/fluxer_api/src/api/auth/AuthRegistration.ts b/fluxer_api/src/api/auth/AuthRegistration.tsindex 76a1b9c48..b4b2519bb 100644--- a/fluxer_api/src/api/auth/AuthRegistration.ts+++ b/fluxer_api/src/api/auth/AuthRegistration.ts@@ -172,6 +172,9 @@ export async function instantAccountsAvailable(export function assertInstantAccountAvailable(availability: InstantAccountAvailability): void {if (availability === InstantAccountAvailability.AVAILABLE) return;if (availability === InstantAccountAvailability.REGISTRATION_CLOSED) throw new RegistrationClosedError();+ if (availability === InstantAccountAvailability.EMAIL_DOMAINS_RESTRICTED) {+ throw InputValidationError.fromCode('email', ValidationErrorCodes.EMAIL_DOMAIN_NOT_ALLOWED);+ }throw new InstantAccountsDisabledError();}diff --git a/fluxer_api/src/api/auth/tests/EmailChangeFlow.test.ts b/fluxer_api/src/api/auth/tests/EmailChangeFlow.test.tsindex 76e309548..768ba184a 100644--- a/fluxer_api/src/api/auth/tests/EmailChangeFlow.test.ts+++ b/fluxer_api/src/api/auth/tests/EmailChangeFlow.test.ts@@ -354,11 +354,11 @@ describe('Email change flow', () => {});it('refuses to claim an account with an address outside the allowed email domains', async () => {- await getInstanceConfigRepository().setRegistrationConfig({allowed_email_domains: ['example.com']});const holder = await createBuilderWithoutAuth<{token: string}>(harness).post('/auth/register').body({username: 'outsideclaimer', consent: true, date_of_birth: '1995-05-05'}).execute();+ await getInstanceConfigRepository().setRegistrationConfig({allowed_email_domains: ['example.com']});const {json} = await createBuilder<{errors: Array<{path: string; code: string}>}>(harness, holder.token).post('/users/@me/claim').body({email: `integration-claim-${Date.now()}@elsewhere.test`})diff --git a/fluxer_api/src/api/auth/tests/RegistrationPolicy.test.ts b/fluxer_api/src/api/auth/tests/RegistrationPolicy.test.tsindex efc19c749..f902aa61c 100644--- a/fluxer_api/src/api/auth/tests/RegistrationPolicy.test.ts+++ b/fluxer_api/src/api/auth/tests/RegistrationPolicy.test.ts@@ -1,12 +1,14 @@// SPDX-License-Identifier: AGPL-3.0-or-laterimport {createAuthHarness, createUniqueEmail, createUniqueUsername} from '@app/api/auth/tests/AuthTestUtils';+import {getConfig} from '@app/api/Config';import {getInstanceConfigRepository} from '@app/api/middleware/ServiceSingletons';import type {ApiTestHarness} from '@app/api/test/ApiTestHarness';import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder';+import {AccountIdentityModes} from '@fluxer/constants/src/AccountIdentityConstants';import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes';import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes';-import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest';+import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'vitest';interface PendingRegistrationResponse {registration_pending_approval: true;@@ -31,6 +33,7 @@ function registrationBody(prefix: string): Record<string, unknown> {describe('Auth registration policy', () => {let harness: ApiTestHarness;+ let originalSelfHosted: boolean;beforeAll(async () => {harness = await createAuthHarness();@@ -38,6 +41,11 @@ describe('Auth registration policy', () => {beforeEach(async () => {await harness.reset();+ originalSelfHosted = getConfig().instance.selfHosted;+ });++ afterEach(() => {+ getConfig().instance.selfHosted = originalSelfHosted;});afterAll(async () => {@@ -193,6 +201,52 @@ describe('Auth registration policy', () => {expect(registration.token.length).toBeGreaterThan(0);});+ it('refuses a public sign-up without an email while allowed email domains are set', async () => {+ const repository = getInstanceConfigRepository();+ await repository.setRegistrationConfig({mode: 'open', allowed_email_domains: ['corp.example']});+ expect(await repository.getInstantAccountAvailability()).toBe('email_domains_restricted');+ const {json} = await createBuilderWithoutAuth<{errors: Array<{path: string; code: string}>}>(harness)+ .post('/auth/register')+ .body({global_name: 'Domain Guest', date_of_birth: '2000-01-01', consent: true})+ .expect(400, APIErrorCodes.INVALID_FORM_BODY)+ .executeWithResponse();+ expect(json.errors).toEqual([+ expect.objectContaining({path: 'email', code: ValidationErrorCodes.EMAIL_DOMAIN_NOT_ALLOWED}),+ ]);+ });++ it('lets a registration URL start an account without an email while allowed email domains are set', async () => {+ const repository = getInstanceConfigRepository();+ await repository.setRegistrationConfig({mode: 'open', allowed_email_domains: ['corp.example']});+ const {code} = await repository.createRegistrationUrl({+ label: 'Guest link',+ createdByUserId: '1',+ expiresAt: null,+ maxUses: 1,+ approvalRequired: false,+ });+ const registration = await createBuilderWithoutAuth<RegistrationTokenResponse>(harness)+ .post('/auth/register')+ .body({global_name: 'Linked Guest', date_of_birth: '2000-01-01', consent: true, registration_url_code: code})+ .execute();+ expect(registration.token.length).toBeGreaterThan(0);+ });++ it('keeps accounts without an email on username instances with allowed email domains set', async () => {+ getConfig().instance.selfHosted = true;+ const repository = getInstanceConfigRepository();+ await repository.setAccountIdentityMode(AccountIdentityModes.USERNAME, 'setup');+ await repository.setAppPublicConfig({setup: {configured: true}});+ await repository.updateAuthConfig({instant_accounts: {enabled: true}});+ await repository.setRegistrationConfig({mode: 'open', allowed_email_domains: ['corp.example']});+ expect(await repository.getInstantAccountAvailability()).toBe('available');+ const registration = await createBuilderWithoutAuth<RegistrationTokenResponse>(harness)+ .post('/auth/register')+ .body({global_name: 'Username Guest', date_of_birth: '2000-01-01', consent: true})+ .execute();+ expect(registration.token.length).toBeGreaterThan(0);+ });+it('refuses an allowed email domain list with an invalid entry', async () => {await expect(getInstanceConfigRepository().setRegistrationConfig({allowed_email_domains: ['[email protected]']}),diff --git a/fluxer_api/src/api/instance/InstanceConfigRepository.ts b/fluxer_api/src/api/instance/InstanceConfigRepository.tsindex fe1b44e06..c3df8ed96 100644--- a/fluxer_api/src/api/instance/InstanceConfigRepository.ts+++ b/fluxer_api/src/api/instance/InstanceConfigRepository.ts@@ -2904,16 +2904,19 @@ export class InstanceConfigRepository {async getInstantAccountAvailability(registrationUrl: {approvalRequired: boolean} | null = null,): Promise<InstantAccountAvailability> {- const [auth, captcha, registration] = await Promise.all([+ const [auth, captcha, registration, identityMode] = await Promise.all([this.getAuthConfig(),this.getCaptchaConfig(),this.getRegistrationConfig(),+ this.getAccountIdentityMode(),]);return resolveInstantAccountAvailability({enabled: auth.instant_accounts.enabled,captchaProvider: captcha.provider,registrationMode: registration.mode,registrationUrl,+ emailDomainsRestricted:+ identityMode !== AccountIdentityModes.USERNAME && registration.allowed_email_domains.length > 0,});}diff --git a/fluxer_api/src/api/openapi/openapi.json b/fluxer_api/src/api/openapi/openapi.jsonindex 5e388ee1d..5efe2d57c 100644--- a/fluxer_api/src/api/openapi/openapi.json+++ b/fluxer_api/src/api/openapi/openapi.json@@ -39329,15 +39329,30 @@},"InstantAccountAvailabilitySchema": {"description": "Whether accounts can be created from just a display name, and why not",- "x-enumNames": ["AVAILABLE", "DISABLED", "CAPTCHA_OFF", "REGISTRATION_CLOSED", "APPROVAL_REQUIRED"],+ "x-enumNames": [+ "AVAILABLE",+ "DISABLED",+ "CAPTCHA_OFF",+ "REGISTRATION_CLOSED",+ "APPROVAL_REQUIRED",+ "EMAIL_DOMAINS_RESTRICTED"+ ],"x-enumDescriptions": ["Accounts can be created from a display name","Instant accounts are turned off","Instant accounts need the captcha, which is off","Public registration is closed",- "New accounts need approval, so they need credentials to sign in once approved"+ "New accounts need approval, so they need credentials to sign in once approved",+ "Public sign-ups must use an email address on an allowed domain"+ ],+ "enum": [+ "available",+ "disabled",+ "captcha_off",+ "registration_closed",+ "approval_required",+ "email_domains_restricted"],- "enum": ["available", "disabled", "captcha_off", "registration_closed", "approval_required"],"type": "string"},"TagStyleSchema": {diff --git a/fluxer_app/src/features/auth/flow/identifier_first/IdentifierFirstState.ts b/fluxer_app/src/features/auth/flow/identifier_first/IdentifierFirstState.tsindex 8e76a517d..ce59346a0 100644--- a/fluxer_app/src/features/auth/flow/identifier_first/IdentifierFirstState.ts+++ b/fluxer_app/src/features/auth/flow/identifier_first/IdentifierFirstState.ts@@ -81,6 +81,7 @@ export function offersInstantAccount(return (registrationUrlCode !== null &&(availability === InstantAccountAvailability.REGISTRATION_CLOSED ||- availability === InstantAccountAvailability.APPROVAL_REQUIRED)+ availability === InstantAccountAvailability.APPROVAL_REQUIRED ||+ availability === InstantAccountAvailability.EMAIL_DOMAINS_RESTRICTED));}diff --git a/fluxer_docs/src/content/docs/admin-api/instance.mdx b/fluxer_docs/src/content/docs/admin-api/instance.mdxindex e17c5d31d..60382882e 100644--- a/fluxer_docs/src/content/docs/admin-api/instance.mdx+++ b/fluxer_docs/src/content/docs/admin-api/instance.mdx@@ -268,7 +268,7 @@ The registration policy and every issued registration URL. [List pending registr| --- | --- | --- || mode | string | [Registration mode](#registration-modes) || admin_registration_urls_enabled | boolean | Whether issued registration URLs work |-| allowed_email_domains | array[string] | Email domains that new accounts and email changes must use, or empty for any. Registration URLs aren't checked |+| allowed_email_domains | array[string] | Email domains that new accounts and email changes must use, or empty for any. While set, an email mode instance turns down public sign-ups without an email. Registration URLs aren't checked || urls | array[[registration URL](#registration-url-object) object] | Every issued registration URL, newest first, including revoked and used-up ones |## Registration modesdiff --git a/fluxer_docs/src/content/docs/http-api/instance.mdx b/fluxer_docs/src/content/docs/http-api/instance.mdxindex 97ea773c9..e1e5f942a 100644--- a/fluxer_docs/src/content/docs/http-api/instance.mdx+++ b/fluxer_docs/src/content/docs/http-api/instance.mdx@@ -176,6 +176,7 @@ When `emails_enabled` is false, email verification, password recovery and IP aut| captcha_off | Instant accounts are on, but the CAPTCHA they need is off || registration_closed | Public registration is closed || approval_required | New accounts wait for admin approval |+| email_domains_restricted | Public sign-ups must use an email address on an allowed domain |### Email delivery statesdiff --git a/fluxer_docs/src/content/docs/operator/environment.mdx b/fluxer_docs/src/content/docs/operator/environment.mdxindex c84ac2ca8..dd7467736 100644--- a/fluxer_docs/src/content/docs/operator/environment.mdx+++ b/fluxer_docs/src/content/docs/operator/environment.mdx@@ -682,6 +682,10 @@ The client secret that goes with `FLUXER_ADMIN_SSO_CLIENT_ID`. Only the admin seThe provider name on the single sign-on button of the admin panel. With `Ferret`, the button says `Sign in with Ferret`. When it's empty, the button says `Sign in with single sign-on`. With rexctl, use `rexctl config set FLUXER_ADMIN_SSO_DISPLAY_NAME`.+### `FLUXER_ADMIN_SSO_ONLY`++Whether staff can sign in to the admin panel only with single sign-on. Use `true` or `false`. With `true`, the login page hides the button for signing in with a Fluxer account, and the admin panel refuses new sign-ins that way. Staff who are already signed in stay signed in. It needs `FLUXER_ADMIN_SSO_ISSUER`, `FLUXER_ADMIN_SSO_CLIENT_ID` and `FLUXER_ADMIN_SSO_CLIENT_SECRET`, and the admin service won't start without them. When it's empty, it's `false`. With rexctl, use `rexctl config set FLUXER_ADMIN_SSO_ONLY`.+The admin panel can also save the delivery mode, the sender and the SMTP server. A value saved there is used first.diff --git a/fluxer_rexctl/internal/adminapi/gen.go b/fluxer_rexctl/internal/adminapi/gen.goindex 2a93151df..49ea3f584 100644--- a/fluxer_rexctl/internal/adminapi/gen.go+++ b/fluxer_rexctl/internal/adminapi/gen.go@@ -1238,11 +1238,12 @@ func (e InstanceRegistrationModeSchema) Valid() bool {// Defines values for InstantAccountAvailabilitySchema.const (- APPROVALREQUIRED InstantAccountAvailabilitySchema = "approval_required"- AVAILABLE InstantAccountAvailabilitySchema = "available"- CAPTCHAOFF InstantAccountAvailabilitySchema = "captcha_off"- DISABLED InstantAccountAvailabilitySchema = "disabled"- REGISTRATIONCLOSED InstantAccountAvailabilitySchema = "registration_closed"+ APPROVALREQUIRED InstantAccountAvailabilitySchema = "approval_required"+ AVAILABLE InstantAccountAvailabilitySchema = "available"+ CAPTCHAOFF InstantAccountAvailabilitySchema = "captcha_off"+ DISABLED InstantAccountAvailabilitySchema = "disabled"+ EMAILDOMAINSRESTRICTED InstantAccountAvailabilitySchema = "email_domains_restricted"+ REGISTRATIONCLOSED InstantAccountAvailabilitySchema = "registration_closed")// Valid indicates whether the value is a known member of the InstantAccountAvailabilitySchema enum.@@ -1256,6 +1257,8 @@ func (e InstantAccountAvailabilitySchema) Valid() bool {return truecase DISABLED:return true+ case EMAILDOMAINSRESTRICTED:+ return truecase REGISTRATIONCLOSED:return truedefault:diff --git a/fluxer_rexctl/internal/instance/envvars.go b/fluxer_rexctl/internal/instance/envvars.goindex f74cb1eb8..36b996fde 100644--- a/fluxer_rexctl/internal/instance/envvars.go+++ b/fluxer_rexctl/internal/instance/envvars.go@@ -190,6 +190,7 @@ var envVars = []envVar{{"FLUXER_ADMIN_SSO_CLIENT_ID", "sso", "The client ID of the admin panel at the provider in FLUXER_ADMIN_SSO_ISSUER. Register the admin address followed by /sso/callback as its redirect URL."},{"FLUXER_ADMIN_SSO_CLIENT_SECRET", "sso", "The client secret that goes with FLUXER_ADMIN_SSO_CLIENT_ID. Only the admin service uses it."},{"FLUXER_ADMIN_SSO_DISPLAY_NAME", "sso", "The provider name on the single sign-on button of the admin panel. With `Ferret`, the button says `Sign in with Ferret`. When it's empty, the button says `Sign in with single sign-on`."},+ {"FLUXER_ADMIN_SSO_ONLY", "sso", "Whether staff can sign in to the admin panel only with single sign-on. Use `true` or `false`. With `true`, the login page hides the button for signing in with a Fluxer account, and the admin panel refuses new sign-ins that way. Staff who are already signed in stay signed in. It needs FLUXER_ADMIN_SSO_ISSUER, FLUXER_ADMIN_SSO_CLIENT_ID and FLUXER_ADMIN_SSO_CLIENT_SECRET, and the admin service won't start without them. When it's empty, it's `false`."},{"FLUXER_EMAIL_ENABLED", "email", "The older way to turn email on. Use FLUXER_EMAIL_DELIVERY."},{"FLUXER_EMAIL_PROVIDER", "email", "The older way to pick the email transport, which takes `smtp` or `none`. Use FLUXER_EMAIL_DELIVERY."},{"FLUXER_EMAIL_DELIVERY", "email", "How Fluxer sends email. Use `smtp` or `off`. When it's empty, FLUXER_EMAIL_ENABLED and FLUXER_EMAIL_PROVIDER decide, and email is off when those are empty too."},diff --git a/fluxer_rexctl/internal/instance/shipped.json b/fluxer_rexctl/internal/instance/shipped.jsonindex 4ca2cdf96..ef4122d49 100644--- a/fluxer_rexctl/internal/instance/shipped.json+++ b/fluxer_rexctl/internal/instance/shipped.json@@ -80,6 +80,7 @@"b91a2a6f9f9b431a1c646a1798bb79b2d9374c0b1148047482a472b02f971a68","b9507ede5b95551c3036430f06cd4f571c836fc01776c98c8d58b90b05aec8c1","bb367376891f75673a4fc0c73fc2033c76f94c8b2b0984c577d2a66435f72c12",+ "bb66110672bbb38916aacaa52e3bc19df6ab796c379546db35fd360522ea849e","bbb549147ec488d4eed8b5a9e6eb4fe2e74a5bcf7e0c141357765a82e7176da3","bc2f52bcd3bbbf29c2abc04941cde4b621e111549bb3294d88c3fd890a51b310","be2fdcf316d1c3f369efba7b70ad11898c1185ed7272cfa917c9484b8072b823",@@ -263,6 +264,7 @@"f0cbc5ad9a0b56155342e98c44edb0b8f4608968d6b552013c4894f3e44321c7","f34318eb0b7534679ee54b225f5578eb27f5b66363c928fbb52a07abb531acf5","f4c291236d71905625da4a5e1dbcc44cfa51570fff312ec0b3b733ef11700d89",+ "f6e262242ba6a14ec3523430aad085738d4cd9236876de0a30c89662d58fc397","f95cc983b5aee01a777cd63bad4da1d10c86681ae896507426c51192efd7103d","f9b7f2fb56c4b6783543e4640841108919d89449da95c47b35198411e6725928","fa4fb2ea2d033ee34fd5203f7acda3bb13f3b65c0f6f8e2003ccdd16e4eed14e",diff --git a/fluxer_rexctl/internal/stack/files/.env.example b/fluxer_rexctl/internal/stack/files/.env.exampleindex 7455f0fdc..6ce52035b 100644--- a/fluxer_rexctl/internal/stack/files/.env.example+++ b/fluxer_rexctl/internal/stack/files/.env.example@@ -983,6 +983,16 @@ FLUXER_VAPID_PRIVATE_KEY=# rexctl: rexctl config set FLUXER_ADMIN_SSO_DISPLAY_NAME# FLUXER_ADMIN_SSO_DISPLAY_NAME=+# Whether staff can sign in to the admin panel only with single sign-on. Use+# true or false. With true, the login page hides the button for signing in+# with a Fluxer account, and the admin panel refuses new sign-ins that way.+# Staff who are already signed in stay signed in. It needs+# FLUXER_ADMIN_SSO_ISSUER, FLUXER_ADMIN_SSO_CLIENT_ID and+# FLUXER_ADMIN_SSO_CLIENT_SECRET, and the admin service won't start without+# them. When it's empty, it's false.+# rexctl: rexctl config set FLUXER_ADMIN_SSO_ONLY+# FLUXER_ADMIN_SSO_ONLY=+# ============================================================================diff --git a/fluxer_rexctl/internal/stack/files/docker-compose.yml b/fluxer_rexctl/internal/stack/files/docker-compose.ymlindex 21a1e24e3..09731d2a9 100644--- a/fluxer_rexctl/internal/stack/files/docker-compose.yml+++ b/fluxer_rexctl/internal/stack/files/docker-compose.yml@@ -888,6 +888,7 @@ services:FLUXER_STATIC_CDN_ENDPOINT: ${FLUXER_STATIC_CDN_ENDPOINT:-${FLUXER_PUBLIC_ORIGIN:-${FLUXER_PUBLIC_SCHEME:-https}://${FLUXER_DOMAIN:-}}}FLUXER_ADMIN_SSO_CLIENT_SECRET: ${FLUXER_ADMIN_SSO_CLIENT_SECRET:-}FLUXER_ADMIN_SSO_DISPLAY_NAME: ${FLUXER_ADMIN_SSO_DISPLAY_NAME:-}+ FLUXER_ADMIN_SSO_ONLY: ${FLUXER_ADMIN_SSO_ONLY:-}healthcheck:test: ["CMD-SHELL", "bash -c 'exec 3<>/dev/tcp/127.0.0.1/8080 && printf \"GET /_health HTTP/1.0\\r\\n\\r\\n\" >&3 && head -n 1 <&3 | grep -q \" 200 \"'"]<<: *fluxer-app-healthcheckdiff --git a/packages/constants/src/AccountConfigConstants.ts b/packages/constants/src/AccountConfigConstants.tsindex 8fafec9c6..fff52ade6 100644--- a/packages/constants/src/AccountConfigConstants.ts+++ b/packages/constants/src/AccountConfigConstants.ts@@ -108,6 +108,7 @@ export const InstantAccountAvailability = {CAPTCHA_OFF: 'captcha_off',REGISTRATION_CLOSED: 'registration_closed',APPROVAL_REQUIRED: 'approval_required',+ EMAIL_DOMAINS_RESTRICTED: 'email_domains_restricted',} as const;export type InstantAccountAvailability = ValueOf<typeof InstantAccountAvailability>;diff --git a/packages/constants/src/AccountTierRules.test.ts b/packages/constants/src/AccountTierRules.test.tsindex d51dab383..c0ef4cdd2 100644--- a/packages/constants/src/AccountTierRules.test.ts+++ b/packages/constants/src/AccountTierRules.test.ts@@ -610,6 +610,7 @@ describe('resolveInstantAccountAvailability', () => {captchaProvider: CaptchaProviders.ALTCHA,registrationMode: RegistrationModes.OPEN,registrationUrl: null,+ emailDomainsRestricted: false,};it('is available while enabled, with a captcha and open sign-ups', () => {@@ -631,6 +632,19 @@ describe('resolveInstantAccountAvailability', () => {);});+ it('needs an email for public sign-ups while allowed email domains are set', () => {+ expect(resolveInstantAccountAvailability({...open, emailDomainsRestricted: true})).toBe(+ InstantAccountAvailability.EMAIL_DOMAINS_RESTRICTED,+ );+ expect(+ resolveInstantAccountAvailability({+ ...open,+ emailDomainsRestricted: true,+ registrationUrl: {approvalRequired: false},+ }),+ ).toBe(InstantAccountAvailability.AVAILABLE);+ });+it('follows a registration URL over the registration mode', () => {for (const registrationMode of Object.values(RegistrationModes)) {expect(diff --git a/packages/constants/src/AccountTierRules.ts b/packages/constants/src/AccountTierRules.tsindex 2a487c18e..3816452f3 100644--- a/packages/constants/src/AccountTierRules.ts+++ b/packages/constants/src/AccountTierRules.ts@@ -316,6 +316,7 @@ export function resolveInstantAccountAvailability(params: {captchaProvider: CaptchaProvider;registrationMode: RegistrationMode;registrationUrl: {approvalRequired: boolean} | null;+ emailDomainsRestricted: boolean;}): InstantAccountAvailability {if (!params.enabled) return InstantAccountAvailability.DISABLED;if (params.captchaProvider === CaptchaProviders.NONE) return InstantAccountAvailability.CAPTCHA_OFF;@@ -326,7 +327,9 @@ export function resolveInstantAccountAvailability(params: {}switch (params.registrationMode) {case RegistrationModes.OPEN:- return InstantAccountAvailability.AVAILABLE;+ return params.emailDomainsRestricted+ ? InstantAccountAvailability.EMAIL_DOMAINS_RESTRICTED+ : InstantAccountAvailability.AVAILABLE;case RegistrationModes.APPROVAL:return InstantAccountAvailability.APPROVAL_REQUIRED;case RegistrationModes.CLOSED:diff --git a/packages/schema/src/domains/account/AccountTierSchemas.ts b/packages/schema/src/domains/account/AccountTierSchemas.tsindex d794ebf13..f2f09ed0f 100644--- a/packages/schema/src/domains/account/AccountTierSchemas.ts+++ b/packages/schema/src/domains/account/AccountTierSchemas.ts@@ -63,6 +63,11 @@ export const InstantAccountAvailabilitySchema = withOpenApiType('APPROVAL_REQUIRED','New accounts need approval, so they need credentials to sign in once approved',],+ [+ InstantAccountAvailability.EMAIL_DOMAINS_RESTRICTED,+ 'EMAIL_DOMAINS_RESTRICTED',+ 'Public sign-ups must use an email address on an allowed domain',+ ],],'Whether accounts can be created from just a display name, and why not',),