diff --git a/backend/global_settings/urls.py b/backend/global_settings/urls.py
index bc1e34e085..71a7515a69 100644
--- a/backend/global_settings/urls.py
+++ b/backend/global_settings/urls.py
@@ -3,7 +3,7 @@
from iam.sso.views import SSOSettingsViewSet
-from .views import GlobalSettingsViewSet, get_sso_info, update_global_settings
+from .views import GlobalSettingsViewSet, get_sso_info, update_general_settings
from .routers import DefaultSettingsRouter
@@ -20,7 +20,7 @@
urlpatterns = [
# This route should ideally be placed under the routes of the routers, but the DefaultRouter usage overwrite the route and makes it inaccessible.
# Could we use DefaultSettingsRouter to register the "global" route to fix that ?
- path(r"global/update/", update_global_settings, name="update_global_settings"),
+ path(r"general/update/", update_general_settings, name="update_general_settings"),
path(r"", include(router.urls)),
path(r"", include(settings_router.urls)),
path(r"sso/info/", get_sso_info, name="get_sso_info"),
diff --git a/backend/global_settings/views.py b/backend/global_settings/views.py
index b913567114..e6645a9379 100644
--- a/backend/global_settings/views.py
+++ b/backend/global_settings/views.py
@@ -34,33 +34,33 @@ def update(self, request, *args, **kwargs):
)
-UPDATABLE_GLOBAL_SETTINGS = frozenset(
+UPDATABLE_GENERAL_SETTINGS = frozenset(
["lang"]
-) # This represents the list of GlobalSettings an admin has the right to change.
+) # This represents the list of "general" GlobalSettings an admin has the right to change.
@api_view(["PATCH"])
@permission_classes([permissions.IsAdminUser])
-def update_global_settings(request):
+def update_general_settings(request):
"""
- API endpoint that returns the CSRF token.
+ API endpoint to update general settings as an administrator.
"""
BaseModelViewSet._process_request_data(request)
- global_settings = GlobalSettings.objects.filter(name="general").first()
- if global_settings is not None:
- global_settings = global_settings.value
+ general_settings = GlobalSettings.objects.filter(name="general").first()
+ if general_settings is not None:
+ general_settings = general_settings.value
else:
- global_settings = {}
+ general_settings = {}
for key, value in request.data.items():
# There is no schema verification for this
- # An attacker may be able to break a ciso-assistant instance by injecting values with bad types in future global settings.
- if key in UPDATABLE_GLOBAL_SETTINGS:
- global_settings[key] = value
+ # An attacker may be able to break a ciso-assistant instance by injecting values with bad types in future general settings.
+ if key in UPDATABLE_GENERAL_SETTINGS:
+ general_settings[key] = value
GlobalSettings.objects.update_or_create(
- name="general", defaults={"value": global_settings}
+ name="general", defaults={"value": general_settings}
)
return Response({})
diff --git a/frontend/src/lib/components/Forms/ModelForm.svelte b/frontend/src/lib/components/Forms/ModelForm.svelte
index d2f90e2cd3..97210f5373 100644
--- a/frontend/src/lib/components/Forms/ModelForm.svelte
+++ b/frontend/src/lib/components/Forms/ModelForm.svelte
@@ -23,7 +23,7 @@
import FrameworksForm from './ModelForm/FrameworkForm.svelte';
import UsersForm from './ModelForm/UserForm.svelte';
import SsoSettingsForm from './ModelForm/SsoSettingForm.svelte';
- import GlobalSettingsForm from './ModelForm/GlobalSettingForm.svelte';
+ import GeneralSettingsForm from './ModelForm/GeneralSettingForm.svelte';
import AutocompleteSelect from './AutocompleteSelect.svelte';
@@ -243,8 +243,8 @@
{:else if URLModel === 'sso-settings'}
- {:else if URLModel === 'global-settings'}
-
+ {:else if URLModel === 'general-settings'}
+
{/if}
{#if closeModal}
diff --git a/frontend/src/lib/components/Forms/ModelForm/GlobalSettingForm.svelte b/frontend/src/lib/components/Forms/ModelForm/GeneralSettingForm.svelte
similarity index 100%
rename from frontend/src/lib/components/Forms/ModelForm/GlobalSettingForm.svelte
rename to frontend/src/lib/components/Forms/ModelForm/GeneralSettingForm.svelte
diff --git a/frontend/src/lib/utils/schemas.ts b/frontend/src/lib/utils/schemas.ts
index ac38907041..82050f1742 100644
--- a/frontend/src/lib/utils/schemas.ts
+++ b/frontend/src/lib/utils/schemas.ts
@@ -278,7 +278,7 @@ export const SSOSettingsSchema = z.object({
want_name_id_encrypted: z.boolean().optional().nullable()
});
-export const GlobalSettingsSchema = z.object({
+export const GeneralSettingsSchema = z.object({
lang: z.string()
});
@@ -347,7 +347,7 @@ const SCHEMA_MAP: Record = {
evidences: EvidenceSchema,
users: UserCreateSchema,
'sso-settings': SSOSettingsSchema,
- 'global-settings': GlobalSettingsSchema,
+ 'general-settings': GeneralSettingsSchema,
entities: EntitiesSchema,
'entity-assessments': EntityAssessmentSchema,
representatives: representativeSchema,
diff --git a/frontend/src/routes/(app)/(internal)/settings/+page.server.ts b/frontend/src/routes/(app)/(internal)/settings/+page.server.ts
index 8a344f06b1..eebba3df16 100644
--- a/frontend/src/routes/(app)/(internal)/settings/+page.server.ts
+++ b/frontend/src/routes/(app)/(internal)/settings/+page.server.ts
@@ -1,7 +1,7 @@
import { handleErrorResponse } from '$lib/utils/actions';
import { BASE_API_URL } from '$lib/utils/constants';
import { getModelInfo } from '$lib/utils/crud';
-import { SSOSettingsSchema, GlobalSettingsSchema } from '$lib/utils/schemas';
+import { SSOSettingsSchema, GeneralSettingsSchema } from '$lib/utils/schemas';
import * as m from '$paraglide/messages';
import { fail, type Actions } from '@sveltejs/kit';
import { setFlash } from 'sveltekit-flash-message/server';
@@ -15,7 +15,7 @@ export const load: PageServerLoad = async ({ fetch }) => {
const selectOptions: Record = {};
const ssoMmodel = getModelInfo('sso-settings');
- const globalSettingsModel = getModelInfo('global-settings');
+ const generalSettingModel = getModelInfo('global-settings');
if (ssoMmodel.selectFields) {
for (const selectField of ssoMmodel.selectFields) {
@@ -37,25 +37,25 @@ export const load: PageServerLoad = async ({ fetch }) => {
ssoMmodel.selectOptions = selectOptions;
const ssoForm = await superValidate(settings, zod(SSOSettingsSchema), { errors: false });
- const globalSettingsForm = await superValidate(settings, zod(GlobalSettingsSchema), {
+ const generalSettingForm = await superValidate(settings, zod(GeneralSettingsSchema), {
errors: false
});
- return { settings, ssoForm, ssoMmodel, globalSettingsForm, globalSettingsModel };
+ return { settings, ssoForm, ssoMmodel, generalSettingForm, generalSettingModel };
};
export const actions: Actions = {
- global: async (event) => {
+ general: async (event) => {
const formData = await event.request.formData();
if (!formData) {
return fail(400, { form: null });
}
- const schema = GlobalSettingsSchema;
+ const schema = GeneralSettingsSchema;
const form = await superValidate(formData, zod(schema));
- const endpoint = `${BASE_API_URL}/settings/global/update/`;
+ const endpoint = `${BASE_API_URL}/settings/general/update/`;
const requestInitOptions: RequestInit = {
method: 'PATCH',
@@ -67,7 +67,7 @@ export const actions: Actions = {
if (!response.ok) return handleErrorResponse({ event, response, form });
// Make the translation
- // It must be called m.globalSettingsUpdated()
+ // It must be called m.generalSettingsUpdated()
setFlash({ type: 'success', message: m.ssoSettingsUpdated() }, event);
return { form };
diff --git a/frontend/src/routes/(app)/(internal)/settings/+page.svelte b/frontend/src/routes/(app)/(internal)/settings/+page.svelte
index 6bf4ad5930..867c59f864 100644
--- a/frontend/src/routes/(app)/(internal)/settings/+page.svelte
+++ b/frontend/src/routes/(app)/(internal)/settings/+page.svelte
@@ -18,7 +18,7 @@
Global Settings General Settings
@@ -31,10 +31,10 @@
{m.ssoSettingsDescription()}
{/if}