Allow build-time config #392

Closed
opened 2026-10-21 05:34:45 +00:00 by jsheunis · 2 comments
Owner

Some existing features can pose a security risk, especially in the context of a multi-tenant-based approach. It makes sense that a tenant configures the user-facing aspects of their UI, but some config options (thinking specifically of security-related options) should remain under the sole control of the system administrator.

This, IMO, identifies the need to separate build-time configuration from runtime configuration. Runtime config is shacl-vue's current configuration approach: a config file is supplied (in one of several possible ways) and interpreted at app startup in the browser. In the tenant-based context, this config is supplied by the tenant. However, as the administrators we might want to have configurable security options (e.g. "allowed file types to fetch", "allowlist of domains", "maximum file size to fetch"...), with defaults.

shacl-vue already supports similar build time environment variables, in a vite-standard way. See e.g. https://cerebra.fz-juelich.de/service/mui/src/branch/main/.forgejo/workflows/publish.yml#L42-L46, where environment variables are set before the npm run build:app call. So my thought is to use a similar approach for security and other build-time config options. But since these options are often structured objects / arrays it'll be easier to provide them in json/yaml format rather than env strings. The latter is possible via a JSON string, but this is not useful for editing and tracking changes.

So I'm currently thinking of supporting a generic build time config approach. We want configured options to become available to the app (across html and vue files) in a way that is analogous or identical to how vite env variables are handled: export VITE_SOME_VARIABLE=123 => import.meta.env.VITE_SOME_VARIABLE in vue files, and <p>Some variable: %VITE_SOME_VARIABLE%</p> in html. Perhaps it is possible to just provide a build-time config file upfront and then in the vite.config.app.mjs file we read this and inject it into the standard vite env structure.

Some existing features can pose a security risk, especially in the context of a [multi-tenant-based approach](https://hub.psychoinformatics.de/orinoco/shacl-vue/issues/387). It makes sense that a tenant configures the user-facing aspects of their UI, but some config options (thinking specifically of security-related options) should remain under the sole control of the system administrator. This, IMO, identifies the need to separate build-time configuration from runtime configuration. Runtime config is `shacl-vue`'s current configuration approach: a config file is supplied (in one of several possible ways) and interpreted at app startup in the browser. In the tenant-based context, this config is supplied by the tenant. However, as the administrators we might want to have configurable security options (e.g. "allowed file types to fetch", "allowlist of domains", "maximum file size to fetch"...), with defaults. `shacl-vue` already supports similar build time environment variables, in a `vite`-standard way. See e.g. https://cerebra.fz-juelich.de/service/mui/src/branch/main/.forgejo/workflows/publish.yml#L42-L46, where environment variables are set before the `npm run build:app` call. So my thought is to use a similar approach for security and other build-time config options. But since these options are often structured objects / arrays it'll be easier to provide them in json/yaml format rather than env strings. The latter is possible via a JSON string, but this is not useful for editing and tracking changes. So I'm currently thinking of supporting a generic build time config approach. We want configured options to become available to the app (across html and vue files) in a way that is analogous or identical to how [vite env variables](https://vite.dev/guide/env-and-mode) are handled: `export VITE_SOME_VARIABLE=123 => import.meta.env.VITE_SOME_VARIABLE` in vue files, and `<p>Some variable: %VITE_SOME_VARIABLE%</p>` in html. Perhaps it is possible to just provide a build-time config file upfront and then in the `vite.config.app.mjs` file we read this and inject it into the standard vite env structure.
Author
Owner

This is now supported by 3ecb09d495

Still needs documentation

This is now supported by https://hub.psychoinformatics.de/orinoco/shacl-vue/commit/3ecb09d495c2cf2ed2a60e0ff50ddbb5e900ef05 Still needs documentation
Author
Owner

Added in #394

Added in https://hub.psychoinformatics.de/orinoco/shacl-vue/pulls/394
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
orinoco/shacl-vue#392
No description provided.