defsetting
should be aware of enterprise restrictions
#23414
Labels
.Epic
Feature Implementation or Project
defsetting
should be aware of enterprise restrictions
#23414
Settings for enterprise can be surprisingly difficult. There are largely two classes of enterprise settings
Whole feature
Settings that are required from a whole enterprise feature that is optionally on the classpath.
Things like sso and ldap. These settings are required and used from whole enterprise namespaces. Thus the calling code just requires the namespace as normal, and the code only executes (and the setting value accessed) in the case that the feature/token is checked.
A concrete example is
These settings typically have no use outside of the encapsulated enterprise feature and token checks around the feature ensure that the setting is meaningless unless the code is on the classpath and the enterprise feature is active.
Some subtleties to this strategy: depending on how the enterprise code is required, these settings might or might not be registered. If the code is required top-level then the setting is registered and you can change its value. If the code is conditionally required then the setting is not registered and you cannot change its value. But due to the way these settings are used and thus changing values even when the feature is not enabled will not have any effect.
Again the impact of a setting being registered or not impacts the setting being able to be set by the api. But these settings will not affect product functionality since the entire feature is correctly behind enterprise feature flags.
Enterprise allows modification of OSS behavior
This other class of enterprise setting lives inside of the OSS app. Concrete examples are application colors, soon-to-be reply-to header for emails, and other settings which modify the default OSS behavior of the app. Two concrete examples are
These settings are registered in OSS (and thus can be set) and are directly used in OSS code. The way we attempt to lock down this functionality is by only exposing the UI to set them in enterprise frontend code. But this means that they can be set by the api and they will then affect application behavior without the enterprise features. For instance,
(public-settings/application-colors)
is used inmetabase.pulse.render.body
for static-viz.Some code jumps through hoops to try to enforce that the setting's value is only used/set if the token is active.
And here the individual implementation has to do two things:
All of this leads to lots of problems. Doing this correctly is a pain. It is so easy to forget to add these checks (like colors and font), and then if you do remember to add these checks, your reward is a painful experience. Further, forgetting these checks and putting the settings in
metabase.public-settings
obscures which settings are intended to be enterprise settings. Then the source of that lives in which ones are editable from enterprise admin panes in the frontend.Solutions
Annotate with feature
Allow the setting to be defined in
public-settings
or any other OSS namespace. Extend thedefsetting
macro to understand an enterprise flag or set of flags.This would add the necessary checks on get/set (see
metabase.public-settings.premium-features
for some related work). We can also send this information over to the frontend.The text was updated successfully, but these errors were encountered: