[#1103] Add upgrade step syncing missing ScriptingService sub-configurations - #1104
Open
vharseko wants to merge 1 commit into
Open
[#1103] Add upgrade step syncing missing ScriptingService sub-configurations#1104vharseko wants to merge 1 commit into
vharseko wants to merge 1 commit into
Conversation
…gService sub-configurations Script contexts and default global scripts defined in the scripting.xml <Configuration> section are only registered by the SMS when the whole service is new, so instances upgraded from a version that already contained the Scripting Service were left without the OAUTH2_ACCESS_TOKEN_MODIFICATION context and its default global script introduced in 16.1.1 (OpenIdentityPlatform#1034). The dangling default of forgerock-oauth2-provider-access-token-modification-script then failed single_choice validation and broke the Global Services page with a 500. - UpgradeScriptingSubConfigsStep adds any global sub-configurations present in the bundled scripting.xml but missing from the config store (script contexts with engine configurations, default global scripts) - ScriptingServiceHelper keeps the script context choice values of the ScriptingService schema in sync with the service definition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1103.
PR #1034 (16.1.1) introduced the
OAUTH2_ACCESS_TOKEN_MODIFICATIONscript context and its default global script in the<Configuration>section ofscripting.xml. The SMS only registers that section when the whole service is new, and the upgrade framework (UpgradeServiceSchemaStep→ServiceSchemaModifications) diffs<Schema>only. As a result, instances upgraded from a version that already contained the Scripting Service (e.g. 16.0.6 → 16.1.1) are left without:scriptContext=OAUTH2_ACCESS_TOKEN_MODIFICATIONsub-configuration (incl. itsengineConfigurationwhitelist),globalScripts/d22f9a0c-426a-4466-b95e-d0f125b0d5fadefault global script,ScriptingServiceschema (attribute modifications are only applied when anUpgradeHelperis registered for the service, andScriptingServicehad none).Meanwhile the new OAuth2 Provider attribute
forgerock-oauth2-provider-access-token-modification-scriptis added on upgrade (viaOAuth2ProviderUpgradeHelper) with its default pointing at the missing script. Reading/json/global-config/services?_action=nextdescendentsthen failssingle_choicevalidation (ScriptChoiceValuesfinds no script of that context) and the whole Global Services page returns 500.Changes
UpgradeScriptingSubConfigsStep(new, depends onUpgradeServiceSchemaStep): reads the tag-swapped bundledscripting.xmlviaUpgradeServiceUtils.getServiceDefinitions, recursively compares its<GlobalConfiguration>sub-configurations with the Scripting Service global config in the data store, and creates any missing ones. Existing sub-configurations are left untouched (user-tuned engine whitelists are not overwritten). The generic diff also self-heals installations already upgraded to 16.1.1/16.1.2 on their next upgrade, and automatically covers any script contexts added in future versions. Follows theUpgradeEntitlementSubConfigsSteppattern.ScriptingServiceHelper(new, registered inserverupgrade.properties): syncs the script context choice values ofdefaultScriptContextandscriptConfiguration.contextwith the service definition.UpgradeServiceUtils.getServiceDefinitionswidened topublicso the step in thesteps.scriptingsub-package can reuse it.amUpgrade.properties.Creation order is safe: the
defaultScriptattribute ofscriptContextvalidates against theScriptConstants.GlobalScriptenum (GlobalOnly=true), not against the data store.Testing
Includes the new
UpgradeScriptingSubConfigsStepTest(+test-scripting.xmlresource) verifying that a missing script context (with engine configuration) and a missing default global script are created with the expected attributes, and that the step is not applicable when everything is already configured. The generatedupgradesteps.propertiesorders the new step afterUpgradeServiceSchemaStepandScriptingSchemaStep.