@beinformed/ui 1.27.2 → 1.27.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/esm/constants/Constants.js +5 -0
- package/esm/constants/Constants.js.map +1 -1
- package/esm/constants/Settings.js +6 -4
- package/esm/constants/Settings.js.map +1 -1
- package/esm/models/application/ApplicationModel.js +6 -3
- package/esm/models/application/ApplicationModel.js.map +1 -1
- package/esm/modularui/Authenticate.js +25 -13
- package/esm/modularui/Authenticate.js.map +1 -1
- package/esm/react/ErrorBoundaryFallback.js +3 -0
- package/esm/react/ErrorBoundaryFallback.js.map +1 -1
- package/esm/react-server/serverUtil.js +1 -0
- package/esm/react-server/serverUtil.js.map +1 -1
- package/lib/constants/Constants.js +7 -1
- package/lib/constants/Constants.js.flow +5 -0
- package/lib/constants/Constants.js.map +1 -1
- package/lib/constants/Settings.js +5 -3
- package/lib/constants/Settings.js.flow +7 -3
- package/lib/constants/Settings.js.map +1 -1
- package/lib/models/application/ApplicationModel.js +6 -3
- package/lib/models/application/ApplicationModel.js.flow +10 -5
- package/lib/models/application/ApplicationModel.js.map +1 -1
- package/lib/modularui/Authenticate.js +24 -12
- package/lib/modularui/Authenticate.js.flow +30 -13
- package/lib/modularui/Authenticate.js.map +1 -1
- package/lib/react/ErrorBoundaryFallback.js +3 -0
- package/lib/react/ErrorBoundaryFallback.js.flow +2 -0
- package/lib/react/ErrorBoundaryFallback.js.map +1 -1
- package/lib/react-server/serverUtil.js +1 -0
- package/lib/react-server/serverUtil.js.flow +2 -0
- package/lib/react-server/serverUtil.js.map +1 -1
- package/package.json +3 -3
- package/src/constants/Constants.js +5 -0
- package/src/constants/Settings.js +7 -3
- package/src/models/application/ApplicationModel.js +10 -5
- package/src/modularui/Authenticate.js +30 -13
- package/src/react/ErrorBoundaryFallback.js +2 -0
- package/src/react-server/serverUtil.js +2 -0
- package/types/constants/Constants.d.ts +5 -0
- package/types/modularui/Authenticate.d.ts +8 -1
|
@@ -3,6 +3,7 @@ import { isPlainObject, has } from "../utils/helpers/objects";
|
|
|
3
3
|
import { getRepositoryResourceUrl } from "../utils/helpers/repositoryResource";
|
|
4
4
|
import {
|
|
5
5
|
ALL_CONTENT_IN_DATA_SETTING,
|
|
6
|
+
INTERNAL_LOGIN_TYPE,
|
|
6
7
|
LOGIN_TYPE,
|
|
7
8
|
LOGIN_PATH_SETTING,
|
|
8
9
|
LOGIN_USERNAME_SETTING,
|
|
@@ -186,13 +187,16 @@ export const hasAllContentInData = (): boolean =>
|
|
|
186
187
|
|
|
187
188
|
/**
|
|
188
189
|
* Login type, only available when pac4j is configured
|
|
190
|
+
*
|
|
191
|
+
* Preview does not support pac4j, thus is probably not configured when started, which results in login type JAAS
|
|
189
192
|
*/
|
|
190
|
-
export const loginType = (): string =>
|
|
193
|
+
export const loginType = (): string =>
|
|
194
|
+
getSetting(LOGIN_TYPE, INTERNAL_LOGIN_TYPE.JAAS);
|
|
191
195
|
|
|
192
196
|
/**
|
|
193
197
|
*/
|
|
194
198
|
export const loginPath = (): string =>
|
|
195
|
-
getSetting(LOGIN_PATH_SETTING, "/
|
|
199
|
+
getSetting(LOGIN_PATH_SETTING, "/callback?client_name=FormClient");
|
|
196
200
|
/**
|
|
197
201
|
*/
|
|
198
202
|
export const loginUsernameField = (): string =>
|
|
@@ -204,7 +208,7 @@ export const loginPasswordField = (): string =>
|
|
|
204
208
|
/**
|
|
205
209
|
*/
|
|
206
210
|
export const logoutPath = (): string =>
|
|
207
|
-
getSetting(LOGOUT_PATH_SETTING, "/
|
|
211
|
+
getSetting(LOGOUT_PATH_SETTING, "/logout");
|
|
208
212
|
|
|
209
213
|
export const LOGIN_PATH: string = loginPath();
|
|
210
214
|
export const LOGOUT_PATH: string = logoutPath();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Settings.js","names":["serverBase","__CONTEXT_PATH__","defaultSettings","CONTEXT_PATH","window","contextPath","CACHE_CONTRIBUTIONS","DEBUG_I18N_MESSAGE_NOT_FOUND","HIDE_NOTIFICATION_TIMEOUT","ALWAYS_COMMIT_FORM","RENDER_QUESTION_LABELS","RENDER_MANDATORY_ATTRIBUTE_INDICATION","RENDER_OPTIONAL_ATTRIBUTE_INDICATION","AVAILABLE_LIST_VIEWS","USE_CLIENTSIDE_VALIDATION","USE_INSTANT_SERVER_VALIDATION","ENABLED_LOCALES","RENDER_GLOBAL_LOGIN_PAGE","RENDER_GLOBAL_LOGOUT_PAGE","RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE","LOGIN_PATH","ADMINISTRATOR_LOGIN_PATH","LOGOUT_PATH","RENDER_FORMS_IN_MODAL","SHOW_SUBMIT_WAIT_TIMEOUT","SWIM_LANE_DIAGRAM_CONFIGURATION","BUSINESS_SCENARIO_CONCEPT_TYPE","BUSINESS_SCENARIO_STEP_CONCEPT_TYPE","BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE","DATE_INPUT_FORMAT","DATE_READONLY_FORMAT","CALENDAR_WEEK_STARTS_ON","CALENDAR_FIRST_WEEK_CONTAINS_DATE","UI_PARAMETERS","ALLOW_HIDE_WHEN_EMPTY_ON_TABS","PAGE_RELOAD_ON_UNAUTHORIZED_ERROR","XHR_TIMEOUT_MS","HIDE_WHEN_EMPTY_IGNORE_TASKS","settings","setSettings","config","isPlainObject","getSetting","key","defaultValue","has","undefined","Error","setSetting","value","allSettings","cacheContributions","getBasePath","getUploadPath","UPLOAD_PATH","getCaptchaPath","CAPTCHA_PATH","hasAllContentInData","ALL_CONTENT_IN_DATA_SETTING","loginType","LOGIN_TYPE","loginPath","LOGIN_PATH_SETTING","loginUsernameField","LOGIN_USERNAME_SETTING","loginPasswordField","LOGIN_PASSWORD_SETTING","logoutPath","LOGOUT_PATH_SETTING","getSwimLaneDiagramConfiguration","configLocation","getRepositoryResourceUrl","BASE"],"sources":["../../src/constants/Settings.js"],"sourcesContent":["// @flow\nimport { isPlainObject, has } from \"../utils/helpers/objects\";\nimport { getRepositoryResourceUrl } from \"../utils/helpers/repositoryResource\";\nimport {\n ALL_CONTENT_IN_DATA_SETTING,\n LOGIN_TYPE,\n LOGIN_PATH_SETTING,\n LOGIN_USERNAME_SETTING,\n LOGIN_PASSWORD_SETTING,\n LOGOUT_PATH_SETTING,\n UPLOAD_PATH,\n CAPTCHA_PATH,\n} from \"./Constants\";\n\ntype Setting = boolean | string | number | Array<string>;\n\nconst serverBase =\n typeof __CONTEXT_PATH__ === \"undefined\" ? null : __CONTEXT_PATH__;\n\nconst defaultSettings: { [name: string]: Setting } = {\n // This uses contextPath set from property from server\n CONTEXT_PATH:\n serverBase ??\n (typeof window !== \"undefined\" && window.contextPath\n ? window.contextPath\n : \"/BeInformed\"),\n\n // Indicates if contributions should be cached\n CACHE_CONTRIBUTIONS: true,\n\n // Debug missing i18n messages in layout\n DEBUG_I18N_MESSAGE_NOT_FOUND: true,\n\n // Time to show the notification bar\n HIDE_NOTIFICATION_TIMEOUT: 5000,\n\n // Always commit form, does not show result pages for instruments\n ALWAYS_COMMIT_FORM: false,\n\n // Render instrument and event question labels on forms (might result in duplicate labels)\n RENDER_QUESTION_LABELS: true,\n\n // Render mandatory indications on attributes\n RENDER_MANDATORY_ATTRIBUTE_INDICATION: true,\n\n // Render optional indications on attributes\n RENDER_OPTIONAL_ATTRIBUTE_INDICATION: false,\n\n // Renders a toggle with supported list views, options are ListView and TableView\n AVAILABLE_LIST_VIEWS: [\"ListView\", \"TableView\"],\n\n // Toggle client side validation\n USE_CLIENTSIDE_VALIDATION: true,\n\n // Indicates if server validation should be used when a form field is changed\n USE_INSTANT_SERVER_VALIDATION: true,\n\n // Indicates which locales are enabled\n ENABLED_LOCALES: [\"en\", \"nl\"],\n\n // Renders the global log in page\n RENDER_GLOBAL_LOGIN_PAGE: false,\n\n // Renders the global log out page\n RENDER_GLOBAL_LOGOUT_PAGE: false,\n\n // Renders the login variants as option on the global logout page\n RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE: false,\n\n // Path to login page / component\n LOGIN_PATH: \"/signin\",\n\n // Path to administrator login page / component\n ADMINISTRATOR_LOGIN_PATH: \"\",\n\n // Path to logout page / component\n LOGOUT_PATH: \"/signout\",\n\n // Render forms in a modal\n RENDER_FORMS_IN_MODAL: true,\n\n // Wait timeout before rendering submit wait icon\n SHOW_SUBMIT_WAIT_TIMEOUT: 300,\n\n // Swim lane diagram configuration file\n SWIM_LANE_DIAGRAM_CONFIGURATION: \"/Library/Diagrams/Overviews.json\",\n\n // Business scenario concept types\n BUSINESS_SCENARIO_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/BusinessScenario\",\n ],\n BUSINESS_SCENARIO_STEP_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/ScenarioStep\",\n ],\n BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/Persona\",\n ],\n\n // Input format for dates. Without this setting having a value, the contributions format is used\n DATE_INPUT_FORMAT: \"\",\n\n // Readonly format for dates. Without this setting having a value, the contributions format is used\n DATE_READONLY_FORMAT: \"\",\n\n // indicates on what day the week starts (0 = Sunday)\n CALENDAR_WEEK_STARTS_ON: 1,\n\n // indicates which date indicates the first week of the year\n CALENDAR_FIRST_WEEK_CONTAINS_DATE: 1,\n\n // parameters that are added for the ui state, but should not be send to the modular ui\n UI_PARAMETERS: [],\n\n // disable hide-when-empty hint for layouts running on Be Informed versions older than 21.1\n ALLOW_HIDE_WHEN_EMPTY_ON_TABS: true,\n\n // reload the complete page on signout, usefull when third party authentication is in place\n PAGE_RELOAD_ON_UNAUTHORIZED_ERROR: false,\n\n XHR_TIMEOUT_MS: 300000,\n\n HIDE_WHEN_EMPTY_IGNORE_TASKS: false,\n};\n\nlet settings = defaultSettings;\n\n/**\n */\nexport const setSettings = (config: Object) => {\n if (isPlainObject(config)) {\n settings = Object.assign(defaultSettings, config);\n }\n};\n\n/**\n */\nexport const getSetting = (key: string, defaultValue?: any): any => {\n if (!has(settings, key) && defaultValue === undefined) {\n throw new Error(\n `Setting with name ${key} not found and no defaultValue given`\n );\n }\n\n return settings[key] ?? defaultValue;\n};\n\n/**\n */\nexport const setSetting = (key: string, value: any) => {\n settings[key] = value;\n};\n\n/**\n */\nexport const allSettings = (): { [name: string]: Setting } => settings;\n\n/**\n * Indicates if contributions must be cached\n */\nexport const cacheContributions = (): boolean =>\n getSetting(\"CACHE_CONTRIBUTIONS\", true);\n\n/**\n * Base path\n * This uses contextPath set from property from server\n * When requesting a remote server with CORS enabled, add the origin, for example:\n * export const BEINFORMED_PATH = 'http://192.168.128.61:8080/BeInformed';\n */\nexport const getBasePath = (): string =>\n getSetting(\"CONTEXT_PATH\", \"/BeInformed\");\n\n/**\n * Path to upload service\n */\nexport const getUploadPath = (): string => `${getBasePath()}${UPLOAD_PATH}`;\n\n/**\n * Path to captcha service\n */\nexport const getCaptchaPath = (): string => `${getBasePath()}${CAPTCHA_PATH}`;\n\n/**\n */\nexport const hasAllContentInData = (): boolean =>\n getSetting(ALL_CONTENT_IN_DATA_SETTING, true);\n\n/**\n * Login type, only available when pac4j is configured\n */\nexport const loginType = (): string => getSetting(LOGIN_TYPE, \"JAAS\");\n\n/**\n */\nexport const loginPath = (): string =>\n getSetting(LOGIN_PATH_SETTING, \"/j_security_check\");\n/**\n */\nexport const loginUsernameField = (): string =>\n getSetting(LOGIN_USERNAME_SETTING, \"j_username\");\n/**\n */\nexport const loginPasswordField = (): string =>\n getSetting(LOGIN_PASSWORD_SETTING, \"j_password\");\n/**\n */\nexport const logoutPath = (): string =>\n getSetting(LOGOUT_PATH_SETTING, \"/Logoff\");\n\nexport const LOGIN_PATH: string = loginPath();\nexport const LOGOUT_PATH: string = logoutPath();\n\n/**\n * Model overview swim lane configuration\n */\nexport const getSwimLaneDiagramConfiguration: Object = () => {\n let configLocation = getSetting(\n \"SWIM_LANE_DIAGRAM_CONFIGURATION\",\n \"/Library/Diagrams/Overviews.json\"\n );\n if (!configLocation.startsWith(\"/\")) {\n configLocation = `/${configLocation}`;\n }\n return getRepositoryResourceUrl(configLocation);\n};\n\n/**\n * Backwards compatible export of BASE constant\n */\nexport const BASE: string = getBasePath();\n"],"mappings":";;;;;;;;;AACA;AACA;AACA;AAaA,MAAMA,UAAU,GACd,OAAOC,gBAAgB,KAAK,WAAW,GAAG,IAAI,GAAGA,gBAAgB;AAEnE,MAAMC,eAA4C,GAAG;EACnD;EACAC,YAAY,EACVH,UAAU,KACT,OAAOI,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACC,WAAW,GAChDD,MAAM,CAACC,WAAW,GAClB,aAAa,CAAC;EAEpB;EACAC,mBAAmB,EAAE,IAAI;EAEzB;EACAC,4BAA4B,EAAE,IAAI;EAElC;EACAC,yBAAyB,EAAE,IAAI;EAE/B;EACAC,kBAAkB,EAAE,KAAK;EAEzB;EACAC,sBAAsB,EAAE,IAAI;EAE5B;EACAC,qCAAqC,EAAE,IAAI;EAE3C;EACAC,oCAAoC,EAAE,KAAK;EAE3C;EACAC,oBAAoB,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC;EAE/C;EACAC,yBAAyB,EAAE,IAAI;EAE/B;EACAC,6BAA6B,EAAE,IAAI;EAEnC;EACAC,eAAe,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;EAE7B;EACAC,wBAAwB,EAAE,KAAK;EAE/B;EACAC,yBAAyB,EAAE,KAAK;EAEhC;EACAC,wCAAwC,EAAE,KAAK;EAE/C;EACAC,UAAU,EAAE,SAAS;EAErB;EACAC,wBAAwB,EAAE,EAAE;EAE5B;EACAC,WAAW,EAAE,UAAU;EAEvB;EACAC,qBAAqB,EAAE,IAAI;EAE3B;EACAC,wBAAwB,EAAE,GAAG;EAE7B;EACAC,+BAA+B,EAAE,kCAAkC;EAEnE;EACAC,8BAA8B,EAAE,CAC9B,yDAAyD,CAC1D;EACDC,mCAAmC,EAAE,CACnC,qDAAqD,CACtD;EACDC,sCAAsC,EAA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CONTEXT_PATH__","defaultSettings","CONTEXT_PATH","window","contextPath","CACHE_CONTRIBUTIONS","DEBUG_I18N_MESSAGE_NOT_FOUND","HIDE_NOTIFICATION_TIMEOUT","ALWAYS_COMMIT_FORM","RENDER_QUESTION_LABELS","RENDER_MANDATORY_ATTRIBUTE_INDICATION","RENDER_OPTIONAL_ATTRIBUTE_INDICATION","AVAILABLE_LIST_VIEWS","USE_CLIENTSIDE_VALIDATION","USE_INSTANT_SERVER_VALIDATION","ENABLED_LOCALES","RENDER_GLOBAL_LOGIN_PAGE","RENDER_GLOBAL_LOGOUT_PAGE","RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE","LOGIN_PATH","ADMINISTRATOR_LOGIN_PATH","LOGOUT_PATH","RENDER_FORMS_IN_MODAL","SHOW_SUBMIT_WAIT_TIMEOUT","SWIM_LANE_DIAGRAM_CONFIGURATION","BUSINESS_SCENARIO_CONCEPT_TYPE","BUSINESS_SCENARIO_STEP_CONCEPT_TYPE","BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE","DATE_INPUT_FORMAT","DATE_READONLY_FORMAT","CALENDAR_WEEK_STARTS_ON","CALENDAR_FIRST_WEEK_CONTAINS_DATE","UI_PARAMETERS","ALLOW_HIDE_WHEN_EMPTY_ON_TABS","PAGE_RELOAD_ON_UNAUTHORIZED_ERROR","XHR_TIMEOUT_MS","HIDE_WHEN_EMPTY_IGNORE_TASKS","settings","setSettings","config","isPlainObject","getSetting","key","defaultValue","has","undefined","Error","setSetting","value","allSettings","cacheContributions","getBasePath","getUploadPath","UPLOAD_PATH","getCaptchaPath","CAPTCHA_PATH","hasAllContentInData","ALL_CONTENT_IN_DATA_SETTING","loginType","LOGIN_TYPE","INTERNAL_LOGIN_TYPE","JAAS","loginPath","LOGIN_PATH_SETTING","loginUsernameField","LOGIN_USERNAME_SETTING","loginPasswordField","LOGIN_PASSWORD_SETTING","logoutPath","LOGOUT_PATH_SETTING","getSwimLaneDiagramConfiguration","configLocation","getRepositoryResourceUrl","BASE"],"sources":["../../src/constants/Settings.js"],"sourcesContent":["// @flow\nimport { isPlainObject, has } from \"../utils/helpers/objects\";\nimport { getRepositoryResourceUrl } from \"../utils/helpers/repositoryResource\";\nimport {\n ALL_CONTENT_IN_DATA_SETTING,\n INTERNAL_LOGIN_TYPE,\n LOGIN_TYPE,\n LOGIN_PATH_SETTING,\n LOGIN_USERNAME_SETTING,\n LOGIN_PASSWORD_SETTING,\n LOGOUT_PATH_SETTING,\n UPLOAD_PATH,\n CAPTCHA_PATH,\n} from \"./Constants\";\n\ntype Setting = boolean | string | number | Array<string>;\n\nconst serverBase =\n typeof __CONTEXT_PATH__ === \"undefined\" ? null : __CONTEXT_PATH__;\n\nconst defaultSettings: { [name: string]: Setting } = {\n // This uses contextPath set from property from server\n CONTEXT_PATH:\n serverBase ??\n (typeof window !== \"undefined\" && window.contextPath\n ? window.contextPath\n : \"/BeInformed\"),\n\n // Indicates if contributions should be cached\n CACHE_CONTRIBUTIONS: true,\n\n // Debug missing i18n messages in layout\n DEBUG_I18N_MESSAGE_NOT_FOUND: true,\n\n // Time to show the notification bar\n HIDE_NOTIFICATION_TIMEOUT: 5000,\n\n // Always commit form, does not show result pages for instruments\n ALWAYS_COMMIT_FORM: false,\n\n // Render instrument and event question labels on forms (might result in duplicate labels)\n RENDER_QUESTION_LABELS: true,\n\n // Render mandatory indications on attributes\n RENDER_MANDATORY_ATTRIBUTE_INDICATION: true,\n\n // Render optional indications on attributes\n RENDER_OPTIONAL_ATTRIBUTE_INDICATION: false,\n\n // Renders a toggle with supported list views, options are ListView and TableView\n AVAILABLE_LIST_VIEWS: [\"ListView\", \"TableView\"],\n\n // Toggle client side validation\n USE_CLIENTSIDE_VALIDATION: true,\n\n // Indicates if server validation should be used when a form field is changed\n USE_INSTANT_SERVER_VALIDATION: true,\n\n // Indicates which locales are enabled\n ENABLED_LOCALES: [\"en\", \"nl\"],\n\n // Renders the global log in page\n RENDER_GLOBAL_LOGIN_PAGE: false,\n\n // Renders the global log out page\n RENDER_GLOBAL_LOGOUT_PAGE: false,\n\n // Renders the login variants as option on the global logout page\n RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE: false,\n\n // Path to login page / component\n LOGIN_PATH: \"/signin\",\n\n // Path to administrator login page / component\n ADMINISTRATOR_LOGIN_PATH: \"\",\n\n // Path to logout page / component\n LOGOUT_PATH: \"/signout\",\n\n // Render forms in a modal\n RENDER_FORMS_IN_MODAL: true,\n\n // Wait timeout before rendering submit wait icon\n SHOW_SUBMIT_WAIT_TIMEOUT: 300,\n\n // Swim lane diagram configuration file\n SWIM_LANE_DIAGRAM_CONFIGURATION: \"/Library/Diagrams/Overviews.json\",\n\n // Business scenario concept types\n BUSINESS_SCENARIO_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/BusinessScenario\",\n ],\n BUSINESS_SCENARIO_STEP_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/ScenarioStep\",\n ],\n BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/Persona\",\n ],\n\n // Input format for dates. Without this setting having a value, the contributions format is used\n DATE_INPUT_FORMAT: \"\",\n\n // Readonly format for dates. Without this setting having a value, the contributions format is used\n DATE_READONLY_FORMAT: \"\",\n\n // indicates on what day the week starts (0 = Sunday)\n CALENDAR_WEEK_STARTS_ON: 1,\n\n // indicates which date indicates the first week of the year\n CALENDAR_FIRST_WEEK_CONTAINS_DATE: 1,\n\n // parameters that are added for the ui state, but should not be send to the modular ui\n UI_PARAMETERS: [],\n\n // disable hide-when-empty hint for layouts running on Be Informed versions older than 21.1\n ALLOW_HIDE_WHEN_EMPTY_ON_TABS: true,\n\n // reload the complete page on signout, usefull when third party authentication is in place\n PAGE_RELOAD_ON_UNAUTHORIZED_ERROR: false,\n\n XHR_TIMEOUT_MS: 300000,\n\n HIDE_WHEN_EMPTY_IGNORE_TASKS: false,\n};\n\nlet settings = defaultSettings;\n\n/**\n */\nexport const setSettings = (config: Object) => {\n if (isPlainObject(config)) {\n settings = Object.assign(defaultSettings, config);\n }\n};\n\n/**\n */\nexport const getSetting = (key: string, defaultValue?: any): any => {\n if (!has(settings, key) && defaultValue === undefined) {\n throw new Error(\n `Setting with name ${key} not found and no defaultValue given`\n );\n }\n\n return settings[key] ?? defaultValue;\n};\n\n/**\n */\nexport const setSetting = (key: string, value: any) => {\n settings[key] = value;\n};\n\n/**\n */\nexport const allSettings = (): { [name: string]: Setting } => settings;\n\n/**\n * Indicates if contributions must be cached\n */\nexport const cacheContributions = (): boolean =>\n getSetting(\"CACHE_CONTRIBUTIONS\", true);\n\n/**\n * Base path\n * This uses contextPath set from property from server\n * When requesting a remote server with CORS enabled, add the origin, for example:\n * export const BEINFORMED_PATH = 'http://192.168.128.61:8080/BeInformed';\n */\nexport const getBasePath = (): string =>\n getSetting(\"CONTEXT_PATH\", \"/BeInformed\");\n\n/**\n * Path to upload service\n */\nexport const getUploadPath = (): string => `${getBasePath()}${UPLOAD_PATH}`;\n\n/**\n * Path to captcha service\n */\nexport const getCaptchaPath = (): string => `${getBasePath()}${CAPTCHA_PATH}`;\n\n/**\n */\nexport const hasAllContentInData = (): boolean =>\n getSetting(ALL_CONTENT_IN_DATA_SETTING, true);\n\n/**\n * Login type, only available when pac4j is configured\n *\n * Preview does not support pac4j, thus is probably not configured when started, which results in login type JAAS\n */\nexport const loginType = (): string =>\n getSetting(LOGIN_TYPE, INTERNAL_LOGIN_TYPE.JAAS);\n\n/**\n */\nexport const loginPath = (): string =>\n getSetting(LOGIN_PATH_SETTING, \"/callback?client_name=FormClient\");\n/**\n */\nexport const loginUsernameField = (): string =>\n getSetting(LOGIN_USERNAME_SETTING, \"j_username\");\n/**\n */\nexport const loginPasswordField = (): string =>\n getSetting(LOGIN_PASSWORD_SETTING, \"j_password\");\n/**\n */\nexport const logoutPath = (): string =>\n getSetting(LOGOUT_PATH_SETTING, \"/logout\");\n\nexport const LOGIN_PATH: string = loginPath();\nexport const LOGOUT_PATH: string = logoutPath();\n\n/**\n * Model overview swim lane configuration\n */\nexport const getSwimLaneDiagramConfiguration: Object = () => {\n let configLocation = getSetting(\n \"SWIM_LANE_DIAGRAM_CONFIGURATION\",\n \"/Library/Diagrams/Overviews.json\"\n );\n if (!configLocation.startsWith(\"/\")) {\n configLocation = `/${configLocation}`;\n }\n return getRepositoryResourceUrl(configLocation);\n};\n\n/**\n * Backwards compatible export of BASE constant\n */\nexport const BASE: string = getBasePath();\n"],"mappings":";;;;;;;;;AACA;AACA;AACA;AAcA,MAAMA,UAAU,GACd,OAAOC,gBAAgB,KAAK,WAAW,GAAG,IAAI,GAAGA,gBAAgB;AAEnE,MAAMC,eAA4C,GAAG;EACnD;EACAC,YAAY,EACVH,UAAU,KACT,OAAOI,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACC,WAAW,GAChDD,MAAM,CAACC,WAAW,GAClB,aAAa,CAAC;EAEpB;EACAC,mBAAmB,EAAE,IAAI;EAEzB;EACAC,4BAA4B,EAAE,IAAI;EAElC;EACAC,yBAAyB,EAAE,IAAI;EAE/B;EACAC,kBAAkB,EAAE,KAAK;EAEzB;EACAC,sBAAsB,EAAE,IAAI;EAE5B;EACAC,qCAAqC,EAAE,IAAI;EAE3C;EACAC,oCAAoC,EAAE,KAAK;EAE3C;EACAC,oBAAoB,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC;EAE/C;EACAC,yBAAyB,EAAE,IAAI;EAE/B;EACAC,6BAA6B,EAAE,IAAI;EAEnC;EACAC,eAAe,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;EAE7B;EACAC,wBAAwB,EAAE,KAAK;EAE/B;EACAC,yBAAyB,EAAE,KAAK;EAEhC;EACAC,wCAAwC,EAAE,KAAK;EAE/C;EACAC,UAAU,EAAE,SAAS;EAErB;EACAC,wBAAwB,EAAE,EAAE;EAE5B;EACAC,WAAW,EAAE,UAAU;EAEvB;EACAC,qBAAqB,EAAE,IAAI;EA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AAc,GAAI,IAAGA,cAAe,EAAC;EACvC;EACA,OAAO,IAAAC,4CAAwB,EAACD,cAAc,CAAC;AACjD,CAAC;;AAED;AACA;AACA;AAFA;AAGO,MAAME,IAAY,GAAGtB,WAAW,EAAE;AAAC"}
|
|
@@ -70,10 +70,13 @@ class ApplicationModel extends _ResourceModel.default {
|
|
|
70
70
|
*/
|
|
71
71
|
get authenticationTypes() {
|
|
72
72
|
const authenticationTypes = this.getContribution("security", [_constants.DEFAULT_AUTHENTICATION_TYPE]);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
if (authenticationTypes) {
|
|
74
|
+
//put primary first
|
|
75
|
+
return authenticationTypes?.sort((a, b) => a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1);
|
|
76
|
+
}
|
|
77
|
+
return [_constants.DEFAULT_AUTHENTICATION_TYPE];
|
|
76
78
|
}
|
|
79
|
+
|
|
77
80
|
/**
|
|
78
81
|
* Getting the tab links
|
|
79
82
|
*/
|
|
@@ -80,12 +80,17 @@ export default class ApplicationModel extends ResourceModel {
|
|
|
80
80
|
DEFAULT_AUTHENTICATION_TYPE,
|
|
81
81
|
]);
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
(
|
|
86
|
-
a
|
|
87
|
-
|
|
83
|
+
if (authenticationTypes) {
|
|
84
|
+
//put primary first
|
|
85
|
+
return authenticationTypes?.sort(
|
|
86
|
+
(a: AuthenticationType, b: AuthenticationType) =>
|
|
87
|
+
a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return [DEFAULT_AUTHENTICATION_TYPE];
|
|
88
92
|
}
|
|
93
|
+
|
|
89
94
|
/**
|
|
90
95
|
* Getting the tab links
|
|
91
96
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationModel.js","names":["ApplicationModel","ResourceModel","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","userService","links","getLinkByKey","href","path","NotAllowedUriException","setChildModels","models","userServiceModel","model","userServices","label","getContribution","authenticationTypes","DEFAULT_AUTHENTICATION_TYPE","sort","a","b","isPrimary","tabs","getLinksByGroup","modelcatalog","LinkModel","create","_userServices","UserServicesModel","isLoggedIn","userHref","userLink"],"sources":["../../../src/models/application/ApplicationModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport { DEFAULT_AUTHENTICATION_TYPE } from \"../../constants\";\n\nimport type { ModularUIModel, AuthenticationType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ApplicationModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\"\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\"\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the authentication types of the application\n */\n get authenticationTypes(): Array<AuthenticationType> {\n const authenticationTypes = this.getContribution(\"security\", [\n DEFAULT_AUTHENTICATION_TYPE,\n ]);\n\n //put primary first\n
|
|
1
|
+
{"version":3,"file":"ApplicationModel.js","names":["ApplicationModel","ResourceModel","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","userService","links","getLinkByKey","href","path","NotAllowedUriException","setChildModels","models","userServiceModel","model","userServices","label","getContribution","authenticationTypes","DEFAULT_AUTHENTICATION_TYPE","sort","a","b","isPrimary","tabs","getLinksByGroup","modelcatalog","LinkModel","create","_userServices","UserServicesModel","isLoggedIn","userHref","userLink"],"sources":["../../../src/models/application/ApplicationModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport { DEFAULT_AUTHENTICATION_TYPE } from \"../../constants\";\n\nimport type { ModularUIModel, AuthenticationType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ApplicationModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\"\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\"\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the authentication types of the application\n */\n get authenticationTypes(): Array<AuthenticationType> {\n const authenticationTypes = this.getContribution(\"security\", [\n DEFAULT_AUTHENTICATION_TYPE,\n ]);\n\n if (authenticationTypes) {\n //put primary first\n return authenticationTypes?.sort(\n (a: AuthenticationType, b: AuthenticationType) =>\n a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1\n );\n }\n\n return [DEFAULT_AUTHENTICATION_TYPE];\n }\n\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\"modelcatalog\", \"/modelcatalog\", \"Model catalog\");\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Indicates if the user is logged in\n */\n get isLoggedIn(): boolean {\n return this.userServices?.isLoggedIn ?? false;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices != null && this.userServices.userLink != null) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n}\n"],"mappings":";;;;;;;;;AACA;AACA;AACA;AAEA;AAEA;AAOA;AACA;AACA;AACe,MAAMA,gBAAgB,SAASC,sBAAa,CAAC;EAAA;IAAA;IAAA;EAAA;EAG1D;AACF;AACA;EACE,IAAIC,IAAI,GAAW;IACjB,OAAO,aAAa;EACtB;;EAEA;AACF;EACE,WAAWC,SAAS,GAAW;IAC7B,OAAO,kBAAkB;EAC3B;;EAEA;AACF;EACE,OAAOC,iBAAiB,CAACC,IAAuB,EAAW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,eAAe,CAAC,KAAK,CAAC;EAC1C;;EAEA;AACF;AACA;EACE,IAAIC,YAAY,GAAc;IAC5B,OAAOC,kBAAS,CAACC,MAAM,CAAC,cAAc,EAAE,eAAe,EAAE,eAAe,CAAC;EAC3E;;EAEA;AACF;AACA;EACE,IAAIb,YAAY,CAACD,KAAsB,EAAE;IACvC,IAAI,CAACe,aAAa,GAAGf,KAAK,YAAYgB,0BAAiB,GAAGhB,KAAK,GAAG,IAAI;EACxE;;EAEA;AACF;AACA;EACE,IAAIC,YAAY,GAAuB;IACrC,OAAO,IAAI,CAACc,aAAa,GAAG,IAAI,CAACA,aAAa,GAAG,IAAI;EACvD;;EAEA;AACF;AACA;EACE,IAAIE,UAAU,GAAY;IACxB,OAAO,IAAI,CAAChB,YAAY,EAAEgB,UAAU,IAAI,KAAK;EAC/C;;EAEA;AACF;AACA;AACA;EACE,IAAIC,QAAQ,GAAgB;IAC1B,IAAI,IAAI,CAACjB,YAAY,IAAI,IAAI,IAAI,IAAI,CAACA,YAAY,CAACkB,QAAQ,IAAI,IAAI,EAAE;MACnE,OAAO,IAAI,CAAClB,YAAY,CAACkB,QAAQ,CAACzB,IAAI;IACxC;IAEA,OAAO,IAAI;EACb;AACF;AAAC"}
|
|
@@ -27,13 +27,13 @@ class Authenticate {
|
|
|
27
27
|
*/
|
|
28
28
|
get authenticationType() {
|
|
29
29
|
const type = (0, _constants.loginType)();
|
|
30
|
-
if (!type || type ===
|
|
31
|
-
return
|
|
30
|
+
if (!type || type === _constants.INTERNAL_LOGIN_TYPE.JAAS) {
|
|
31
|
+
return _constants.INTERNAL_LOGIN_TYPE.JAAS;
|
|
32
32
|
}
|
|
33
33
|
if ((0, _includes.default)(type).call(type, "FormClient")) {
|
|
34
|
-
return
|
|
34
|
+
return _constants.INTERNAL_LOGIN_TYPE.PAC4J_FORM;
|
|
35
35
|
} else if ((0, _includes.default)(type).call(type, "BasicClient")) {
|
|
36
|
-
return
|
|
36
|
+
return _constants.INTERNAL_LOGIN_TYPE.PAC4J_BASIC;
|
|
37
37
|
}
|
|
38
38
|
throw new Error(`Unsupported login type found: ${type}`);
|
|
39
39
|
}
|
|
@@ -41,7 +41,7 @@ class Authenticate {
|
|
|
41
41
|
/**
|
|
42
42
|
*/
|
|
43
43
|
get isBasicAuthentication() {
|
|
44
|
-
return this._isBasic || this.authenticationType ===
|
|
44
|
+
return this._isBasic || this.authenticationType === _constants.INTERNAL_LOGIN_TYPE.PAC4J_BASIC;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
@@ -84,9 +84,9 @@ class Authenticate {
|
|
|
84
84
|
*/
|
|
85
85
|
login(username, password) {
|
|
86
86
|
switch (this.authenticationType) {
|
|
87
|
-
case
|
|
87
|
+
case _constants.INTERNAL_LOGIN_TYPE.PAC4J_FORM:
|
|
88
88
|
return this.doFormLogin(username, password);
|
|
89
|
-
case
|
|
89
|
+
case _constants.INTERNAL_LOGIN_TYPE.PAC4J_BASIC:
|
|
90
90
|
return this.doBasicAuthentication(username, password);
|
|
91
91
|
default:
|
|
92
92
|
return this.doJaasAuthentication(username, password);
|
|
@@ -97,8 +97,8 @@ class Authenticate {
|
|
|
97
97
|
*/
|
|
98
98
|
getFormLoginUrl() {
|
|
99
99
|
switch (this.authenticationType) {
|
|
100
|
-
case
|
|
101
|
-
case
|
|
100
|
+
case _constants.INTERNAL_LOGIN_TYPE.PAC4J_BASIC:
|
|
101
|
+
case _constants.INTERNAL_LOGIN_TYPE.PAC4J_FORM:
|
|
102
102
|
return `${(0, _constants.getBasePath)()}${(0, _constants.loginPath)()}`;
|
|
103
103
|
default:
|
|
104
104
|
return `${(0, _constants.getBasePath)()}/j_security_check`;
|
|
@@ -111,8 +111,8 @@ class Authenticate {
|
|
|
111
111
|
const encodedUsername = encodeURIComponent(username);
|
|
112
112
|
const encodedPassword = encodeURIComponent(password);
|
|
113
113
|
switch (this.authenticationType) {
|
|
114
|
-
case
|
|
115
|
-
case
|
|
114
|
+
case _constants.INTERNAL_LOGIN_TYPE.PAC4J_BASIC:
|
|
115
|
+
case _constants.INTERNAL_LOGIN_TYPE.PAC4J_FORM:
|
|
116
116
|
return `${(0, _constants.loginUsernameField)()}=${encodedUsername}&${(0, _constants.loginPasswordField)()}=${encodedPassword}`;
|
|
117
117
|
default:
|
|
118
118
|
return `j_username=${encodedUsername}&j_password=${encodedPassword}`;
|
|
@@ -151,11 +151,23 @@ class Authenticate {
|
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
/**
|
|
155
|
+
*/
|
|
156
|
+
getLogoutUrl() {
|
|
157
|
+
switch (this.authenticationType) {
|
|
158
|
+
case _constants.INTERNAL_LOGIN_TYPE.PAC4J_BASIC:
|
|
159
|
+
case _constants.INTERNAL_LOGIN_TYPE.PAC4J_FORM:
|
|
160
|
+
return `${(0, _constants.getBasePath)()}${(0, _constants.logoutPath)()}`;
|
|
161
|
+
default:
|
|
162
|
+
return `${(0, _constants.getBasePath)()}/Logoff`;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
154
166
|
/**
|
|
155
167
|
*/
|
|
156
168
|
logout() {
|
|
157
169
|
return (0, _universalFetch.default)({
|
|
158
|
-
url:
|
|
170
|
+
url: this.getLogoutUrl()
|
|
159
171
|
}).then(response => {
|
|
160
172
|
// clear cache because of cached contributions
|
|
161
173
|
_Cache.default.clear();
|
|
@@ -6,6 +6,7 @@ import Cache from "../utils/browser/Cache";
|
|
|
6
6
|
|
|
7
7
|
import { UnauthorizedException } from "../exceptions";
|
|
8
8
|
import {
|
|
9
|
+
INTERNAL_LOGIN_TYPE,
|
|
9
10
|
loginType,
|
|
10
11
|
loginPath,
|
|
11
12
|
loginPasswordField,
|
|
@@ -27,16 +28,17 @@ class Authenticate {
|
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
*/
|
|
30
|
-
get authenticationType():
|
|
31
|
+
get authenticationType(): $Keys<typeof INTERNAL_LOGIN_TYPE> {
|
|
31
32
|
const type = loginType();
|
|
32
33
|
|
|
33
|
-
if (!type || type ===
|
|
34
|
-
return
|
|
34
|
+
if (!type || type === INTERNAL_LOGIN_TYPE.JAAS) {
|
|
35
|
+
return INTERNAL_LOGIN_TYPE.JAAS;
|
|
35
36
|
}
|
|
37
|
+
|
|
36
38
|
if (type.includes("FormClient")) {
|
|
37
|
-
return
|
|
39
|
+
return INTERNAL_LOGIN_TYPE.PAC4J_FORM;
|
|
38
40
|
} else if (type.includes("BasicClient")) {
|
|
39
|
-
return
|
|
41
|
+
return INTERNAL_LOGIN_TYPE.PAC4J_BASIC;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
throw new Error(`Unsupported login type found: ${type}`);
|
|
@@ -45,7 +47,10 @@ class Authenticate {
|
|
|
45
47
|
/**
|
|
46
48
|
*/
|
|
47
49
|
get isBasicAuthentication(): boolean {
|
|
48
|
-
return
|
|
50
|
+
return (
|
|
51
|
+
this._isBasic ||
|
|
52
|
+
this.authenticationType === INTERNAL_LOGIN_TYPE.PAC4J_BASIC
|
|
53
|
+
);
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
/**
|
|
@@ -90,9 +95,9 @@ class Authenticate {
|
|
|
90
95
|
*/
|
|
91
96
|
login(username: string, password: string): Promise<any> {
|
|
92
97
|
switch (this.authenticationType) {
|
|
93
|
-
case
|
|
98
|
+
case INTERNAL_LOGIN_TYPE.PAC4J_FORM:
|
|
94
99
|
return this.doFormLogin(username, password);
|
|
95
|
-
case
|
|
100
|
+
case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:
|
|
96
101
|
return this.doBasicAuthentication(username, password);
|
|
97
102
|
default:
|
|
98
103
|
return this.doJaasAuthentication(username, password);
|
|
@@ -103,8 +108,8 @@ class Authenticate {
|
|
|
103
108
|
*/
|
|
104
109
|
getFormLoginUrl(): string {
|
|
105
110
|
switch (this.authenticationType) {
|
|
106
|
-
case
|
|
107
|
-
case
|
|
111
|
+
case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:
|
|
112
|
+
case INTERNAL_LOGIN_TYPE.PAC4J_FORM:
|
|
108
113
|
return `${getBasePath()}${loginPath()}`;
|
|
109
114
|
default:
|
|
110
115
|
return `${getBasePath()}/j_security_check`;
|
|
@@ -118,8 +123,8 @@ class Authenticate {
|
|
|
118
123
|
const encodedPassword = encodeURIComponent(password);
|
|
119
124
|
|
|
120
125
|
switch (this.authenticationType) {
|
|
121
|
-
case
|
|
122
|
-
case
|
|
126
|
+
case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:
|
|
127
|
+
case INTERNAL_LOGIN_TYPE.PAC4J_FORM:
|
|
123
128
|
return `${loginUsernameField()}=${encodedUsername}&${loginPasswordField()}=${encodedPassword}`;
|
|
124
129
|
default:
|
|
125
130
|
return `j_username=${encodedUsername}&j_password=${encodedPassword}`;
|
|
@@ -158,11 +163,23 @@ class Authenticate {
|
|
|
158
163
|
});
|
|
159
164
|
}
|
|
160
165
|
|
|
166
|
+
/**
|
|
167
|
+
*/
|
|
168
|
+
getLogoutUrl(): string {
|
|
169
|
+
switch (this.authenticationType) {
|
|
170
|
+
case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:
|
|
171
|
+
case INTERNAL_LOGIN_TYPE.PAC4J_FORM:
|
|
172
|
+
return `${getBasePath()}${logoutPath()}`;
|
|
173
|
+
default:
|
|
174
|
+
return `${getBasePath()}/Logoff`;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
161
178
|
/**
|
|
162
179
|
*/
|
|
163
180
|
logout(): Promise<any> {
|
|
164
181
|
return universalFetch({
|
|
165
|
-
url:
|
|
182
|
+
url: this.getLogoutUrl(),
|
|
166
183
|
}).then((response) => {
|
|
167
184
|
// clear cache because of cached contributions
|
|
168
185
|
Cache.clear();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Authenticate.js","names":["Authenticate","constructor","_isBasic","authenticationType","type","loginType","Error","isBasicAuthentication","requestLogin","universalFetch","url","getBasePath","method","HTTP_METHODS","GET","headers","Accept","initLogin","resolve","catch","error","UnauthorizedException","login","username","password","doFormLogin","doBasicAuthentication","doJaasAuthentication","getFormLoginUrl","loginPath","getFormLoginData","encodedUsername","encodeURIComponent","encodedPassword","loginUsernameField","loginPasswordField","POST","data","Cache","addItem","btoa","then","
|
|
1
|
+
{"version":3,"file":"Authenticate.js","names":["Authenticate","constructor","_isBasic","authenticationType","type","loginType","INTERNAL_LOGIN_TYPE","JAAS","PAC4J_FORM","PAC4J_BASIC","Error","isBasicAuthentication","requestLogin","universalFetch","url","getBasePath","method","HTTP_METHODS","GET","headers","Accept","initLogin","resolve","catch","error","UnauthorizedException","login","username","password","doFormLogin","doBasicAuthentication","doJaasAuthentication","getFormLoginUrl","loginPath","getFormLoginData","encodedUsername","encodeURIComponent","encodedPassword","loginUsernameField","loginPasswordField","POST","data","Cache","addItem","btoa","then","getLogoutUrl","logoutPath","logout","response","clear"],"sources":["../../src/modularui/Authenticate.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS } from \"../constants/Constants\";\n\nimport universalFetch from \"../utils/fetch/universalFetch\";\nimport Cache from \"../utils/browser/Cache\";\n\nimport { UnauthorizedException } from \"../exceptions\";\nimport {\n INTERNAL_LOGIN_TYPE,\n loginType,\n loginPath,\n loginPasswordField,\n loginUsernameField,\n logoutPath,\n getBasePath,\n} from \"../constants\";\n\n/**\n */\nclass Authenticate {\n _isBasic: boolean;\n\n /**\n */\n constructor() {\n this._isBasic = false;\n }\n\n /**\n */\n get authenticationType(): $Keys<typeof INTERNAL_LOGIN_TYPE> {\n const type = loginType();\n\n if (!type || type === INTERNAL_LOGIN_TYPE.JAAS) {\n return INTERNAL_LOGIN_TYPE.JAAS;\n }\n\n if (type.includes(\"FormClient\")) {\n return INTERNAL_LOGIN_TYPE.PAC4J_FORM;\n } else if (type.includes(\"BasicClient\")) {\n return INTERNAL_LOGIN_TYPE.PAC4J_BASIC;\n }\n\n throw new Error(`Unsupported login type found: ${type}`);\n }\n\n /**\n */\n get isBasicAuthentication(): boolean {\n return (\n this._isBasic ||\n this.authenticationType === INTERNAL_LOGIN_TYPE.PAC4J_BASIC\n );\n }\n\n /**\n */\n set isBasicAuthentication(isBasicAuthentication: boolean) {\n this._isBasic = isBasicAuthentication;\n }\n\n /**\n */\n requestLogin(): Promise<any> {\n return universalFetch({\n url: `${getBasePath()}/login`,\n method: HTTP_METHODS.GET,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n });\n }\n\n /**\n */\n initLogin(initLogin: boolean): Promise<any> {\n if (this.isBasicAuthentication || !initLogin) {\n return Promise.resolve(true);\n }\n\n return this.requestLogin().catch((error) => {\n // when an unauthorizedexception is received on a request to the login service,\n // this indicates a basic authorization scenario\n // in case of form based authentication other exceptions are thrown\n if (error instanceof UnauthorizedException) {\n this.isBasicAuthentication = true;\n }\n\n return Promise.resolve({});\n });\n }\n\n /**\n */\n login(username: string, password: string): Promise<any> {\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return this.doFormLogin(username, password);\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n return this.doBasicAuthentication(username, password);\n default:\n return this.doJaasAuthentication(username, password);\n }\n }\n\n /**\n */\n getFormLoginUrl(): string {\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return `${getBasePath()}${loginPath()}`;\n default:\n return `${getBasePath()}/j_security_check`;\n }\n }\n\n /**\n */\n getFormLoginData(username: string, password: string): string {\n const encodedUsername = encodeURIComponent(username);\n const encodedPassword = encodeURIComponent(password);\n\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return `${loginUsernameField()}=${encodedUsername}&${loginPasswordField()}=${encodedPassword}`;\n default:\n return `j_username=${encodedUsername}&j_password=${encodedPassword}`;\n }\n }\n\n /**\n */\n doFormLogin(username: string, password: string): Promise<any> {\n return universalFetch({\n url: this.getFormLoginUrl(),\n method: HTTP_METHODS.POST,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n data: this.getFormLoginData(username, password),\n });\n }\n\n /**\n */\n doBasicAuthentication(username: string, password: string): Promise<any> {\n Cache.addItem(\"basic\", btoa(`${username}:${password}`));\n return this.requestLogin();\n }\n\n /**\n */\n doJaasAuthentication(username: string, password: string): Promise<any> {\n return this.initLogin(true).then(() => {\n if (this.isBasicAuthentication) {\n return this.doBasicAuthentication(username, password);\n }\n return this.doFormLogin(username, password);\n });\n }\n\n /**\n */\n getLogoutUrl(): string {\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return `${getBasePath()}${logoutPath()}`;\n default:\n return `${getBasePath()}/Logoff`;\n }\n }\n\n /**\n */\n logout(): Promise<any> {\n return universalFetch({\n url: this.getLogoutUrl(),\n }).then((response) => {\n // clear cache because of cached contributions\n Cache.clear();\n return response;\n });\n }\n}\n\nexport default Authenticate;\n"],"mappings":";;;;;;;;;;AACA;AAEA;AACA;AAEA;AACA;AAUA;AACA;AACA,MAAMA,YAAY,CAAC;EAGjB;AACF;EACEC,WAAW,GAAG;IAAA;IACZ,IAAI,CAACC,QAAQ,GAAG,KAAK;EACvB;;EAEA;AACF;EACE,IAAIC,kBAAkB,GAAsC;IAC1D,MAAMC,IAAI,GAAG,IAAAC,oBAAS,GAAE;IAExB,IAAI,CAACD,IAAI,IAAIA,IAAI,KAAKE,8BAAmB,CAACC,IAAI,EAAE;MAC9C,OAAOD,8BAAmB,CAACC,IAAI;IACjC;IAEA,IAAI,uBAAAH,IAAI,OAAJA,IAAI,EAAU,YAAY,CAAC,EAAE;MAC/B,OAAOE,8BAAmB,CAACE,UAAU;IACvC,CAAC,MAAM,IAAI,uBAAAJ,IAAI,OAAJA,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EACJ;;EAEA;AACF;EACEE,qBAAqB,CAACH,QAAgB,EAAEC,QAAgB,EAAgB;IACtEc,cAAK,CAACC,OAAO,CAAC,OAAO,EAAEC,IAAI,CAAE,GAAEjB,QAAS,IAAGC,QAAS,EAAC,CAAC,CAAC;IACvD,OAAO,IAAI,CAAChB,YAAY,EAAE;EAC5B;;EAEA;AACF;EACEmB,oBAAoB,CAACJ,QAAgB,EAAEC,QAAgB,EAAgB;IACrE,OAAO,IAAI,CAACP,SAAS,CAAC,IAAI,CAAC,CAACwB,IAAI,CAAC,MAAM;MACrC,IAAI,IAAI,CAAClC,qBAAqB,EAAE;QAC9B,OAAO,IAAI,CAACmB,qBAAqB,CAACH,QAAQ,EAAEC,QAAQ,CAAC;MACvD;MACA,OAAO,IAAI,CAACC,WAAW,CAACF,QAAQ,EAAEC,QAAQ,CAAC;IAC7C,CAAC,CAAC;EACJ;;EAEA;AACF;EACEkB,YAAY,GAAW;IACrB,QAAQ,IAAI,CAAC3C,kBAAkB;MAC7B,KAAKG,8BAAmB,CAACG,WAAW;MACpC,KAAKH,8BAAmB,CAACE,UAAU;QACjC,OAAQ,GAAE,IAAAO,sBAAW,GAAG,GAAE,IAAAgC,qBAAU,GAAG,EAAC;MAC1C;QACE,OAAQ,GAAE,IAAAhC,sBAAW,GAAG,SAAQ;IAAC;EAEvC;;EAEA;AACF;EACEiC,MAAM,GAAiB;IACrB,OAAO,IAAAnC,uBAAc,EAAC;MACpBC,GAAG,EAAE,IAAI,CAACgC,YAAY;IACxB,CAAC,CAAC,CAACD,IAAI,CAAEI,QAAQ,IAAK;MACpB;MACAP,cAAK,CAACQ,KAAK,EAAE;MACb,OAAOD,QAAQ;IACjB,CAAC,CAAC;EACJ;AACF;AAAC,eAEcjD,YAAY;AAAA"}
|
|
@@ -8,9 +8,12 @@ exports.default = void 0;
|
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
9
|
var _spacers = require("../react-theme/utils/spacers");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
// $FlowFixMe
|
|
11
12
|
const StyledBoundary = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
12
13
|
componentId: "sc-xsbtpo-0"
|
|
13
14
|
})(["padding:", ";margin-bottom:", ";background-color:#e9ecef;border-radius:0.3em;"], (0, _spacers.spacers)(2, 1), (0, _spacers.spacer)(2));
|
|
15
|
+
|
|
16
|
+
// $FlowFixMe
|
|
14
17
|
const StyledStack = /*#__PURE__*/_styledComponents.default.pre.withConfig({
|
|
15
18
|
componentId: "sc-xsbtpo-1"
|
|
16
19
|
})(["display:block;font-size:87.5%;color:#212529;font-style:italic;"]);
|
|
@@ -12,6 +12,7 @@ export type Props = {
|
|
|
12
12
|
+error: Error,
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
// $FlowFixMe
|
|
15
16
|
const StyledBoundary: StyledComponent<{}, Theme, *> = styled.div`
|
|
16
17
|
padding: ${spacers(2, 1)};
|
|
17
18
|
margin-bottom: ${spacer(2)};
|
|
@@ -19,6 +20,7 @@ const StyledBoundary: StyledComponent<{}, Theme, *> = styled.div`
|
|
|
19
20
|
border-radius: 0.3em;
|
|
20
21
|
`;
|
|
21
22
|
|
|
23
|
+
// $FlowFixMe
|
|
22
24
|
const StyledStack = styled.pre`
|
|
23
25
|
display: block;
|
|
24
26
|
font-size: 87.5%;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBoundaryFallback.js","names":["StyledBoundary","styled","div","spacers","spacer","StyledStack","pre","ErrorBoundaryFallback","className","componentStack","error","toString","displayName"],"sources":["../../src/react/ErrorBoundaryFallback.js"],"sourcesContent":["// @flow\nimport styled from \"styled-components\";\nimport { spacers, spacer } from \"../react-theme/utils/spacers\";\n\nimport type { StyledComponent } from \"styled-components\";\nimport type { Theme } from \"../react-theme/types\";\nimport type { Node } from \"react\";\n\nexport type Props = {\n +className?: string,\n +componentStack: string,\n +error: Error,\n};\n\nconst StyledBoundary: StyledComponent<{}, Theme, *> = styled.div`\n padding: ${spacers(2, 1)};\n margin-bottom: ${spacer(2)};\n background-color: #e9ecef;\n border-radius: 0.3em;\n`;\n\nconst StyledStack = styled.pre`\n display: block;\n font-size: 87.5%;\n color: #212529;\n font-style: italic;\n`;\n\n/**\n */\nconst ErrorBoundaryFallback = ({\n className,\n componentStack,\n error,\n}: Props): Node => (\n <StyledBoundary className={className}>\n <h2>{error.toString()}</h2>\n <StyledStack className=\"debug\">{componentStack}</StyledStack>\n </StyledBoundary>\n);\n\nErrorBoundaryFallback.displayName = \"BI.ErrorBoundaryFallback\";\n\nexport default ErrorBoundaryFallback;\n"],"mappings":";;;;;;;AACA;AACA;AAA+D;AAY/D,MAAMA,cAA6C,gBAAGC,yBAAM,CAACC,GAAG;EAAA;AAAA,sFACnD,IAAAC,gBAAO,EAAC,CAAC,EAAE,CAAC,CAAC,EACP,IAAAC,eAAM,EAAC,CAAC,CAAC,CAG3B;
|
|
1
|
+
{"version":3,"file":"ErrorBoundaryFallback.js","names":["StyledBoundary","styled","div","spacers","spacer","StyledStack","pre","ErrorBoundaryFallback","className","componentStack","error","toString","displayName"],"sources":["../../src/react/ErrorBoundaryFallback.js"],"sourcesContent":["// @flow\nimport styled from \"styled-components\";\nimport { spacers, spacer } from \"../react-theme/utils/spacers\";\n\nimport type { StyledComponent } from \"styled-components\";\nimport type { Theme } from \"../react-theme/types\";\nimport type { Node } from \"react\";\n\nexport type Props = {\n +className?: string,\n +componentStack: string,\n +error: Error,\n};\n\n// $FlowFixMe\nconst StyledBoundary: StyledComponent<{}, Theme, *> = styled.div`\n padding: ${spacers(2, 1)};\n margin-bottom: ${spacer(2)};\n background-color: #e9ecef;\n border-radius: 0.3em;\n`;\n\n// $FlowFixMe\nconst StyledStack = styled.pre`\n display: block;\n font-size: 87.5%;\n color: #212529;\n font-style: italic;\n`;\n\n/**\n */\nconst ErrorBoundaryFallback = ({\n className,\n componentStack,\n error,\n}: Props): Node => (\n <StyledBoundary className={className}>\n <h2>{error.toString()}</h2>\n <StyledStack className=\"debug\">{componentStack}</StyledStack>\n </StyledBoundary>\n);\n\nErrorBoundaryFallback.displayName = \"BI.ErrorBoundaryFallback\";\n\nexport default ErrorBoundaryFallback;\n"],"mappings":";;;;;;;AACA;AACA;AAA+D;AAY/D;AACA,MAAMA,cAA6C,gBAAGC,yBAAM,CAACC,GAAG;EAAA;AAAA,sFACnD,IAAAC,gBAAO,EAAC,CAAC,EAAE,CAAC,CAAC,EACP,IAAAC,eAAM,EAAC,CAAC,CAAC,CAG3B;;AAED;AACA,MAAMC,WAAW,gBAAGJ,yBAAM,CAACK,GAAG;EAAA;AAAA,sEAK7B;;AAED;AACA;AACA,MAAMC,qBAAqB,GAAG;EAAA,IAAC;IAC7BC,SAAS;IACTC,cAAc;IACdC;EACK,CAAC;EAAA,oBACN,sBAAC,cAAc;IAAC,SAAS,EAAEF,SAAU;IAAA,wBACnC;MAAA,UAAKE,KAAK,CAACC,QAAQ;IAAE,EAAM,eAC3B,qBAAC,WAAW;MAAC,SAAS,EAAC,OAAO;MAAA,UAAEF;IAAc,EAAe;EAAA,EAC9C;AAAA,CAClB;AAEDF,qBAAqB,CAACK,WAAW,GAAG,0BAA0B;AAAC,eAEhDL,qBAAqB;AAAA"}
|
|
@@ -141,6 +141,7 @@ const setApplication = store => {
|
|
|
141
141
|
const application = new _ModularUIRequest.default("/", {
|
|
142
142
|
locale: locale
|
|
143
143
|
}).fetchSync();
|
|
144
|
+
application.connectKey = `application(/)(${locale})`;
|
|
144
145
|
store.dispatch((0, _redux.initModels)([{
|
|
145
146
|
key: `application(/)(${locale})`,
|
|
146
147
|
model: application
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverUtil.js","names":["createReduxStore","requestHref","customReducers","initialState","history","createMemoryHistory","initialEntries","toString","store","configureStore","setI18n","locales","request","Array","isArray","IllegalArgumentException","mergedLocales","availableLocales","locale","code","customLocale","custLocale","deepmerge","forEach","some","push","enabledLocales","getSetting","localesInstance","Locales","preferredLocale","getPreferredLocale","dispatch","setLocales","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreference","setServerPreferences","setAllContentInDataSetting","setLoginPreferences","preferencesProvider","isStudioContext","setPreference","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","dataFetcher","fetch","setThemePreference","Error","setApplication","getLocale","getState","application","ModularUIRequest","fetchSync","initModels","key","model","e","console","info","handleErrors","state","error","shouldThrowOnServer","has","dehydrate","modularui","status","lastModification","undefined","filteredState","replace","createHead","sheet","UUID","helmetContext","style","getStyleTags","meta","helmet"],"sources":["../../src/react-server/serverUtil.js"],"sourcesContent":["// @flow\nimport { createMemoryHistory } from \"history\";\nimport { has } from \"../utils/helpers/objects\";\nimport deepmerge from \"deepmerge\";\n\nimport configureStore from \"../redux/store/configureStore\";\n\nimport { availableLocales } from \"../i18n/Locales\";\nimport Locales from \"../i18n/Locales\";\n\nimport { getPreferredLocale } from \"./requestInformation\";\nimport { setLocales } from \"../redux/_i18n/I18nActions\";\n\nimport {\n setServerPreference,\n setThemePreference,\n setPreference,\n setAllContentInDataSetting,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\n\nimport { getSetting } from \"../constants/Settings\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport { initModels } from \"../redux\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { ReduxState, ReduxStore } from \"../redux/types\";\nimport type Href from \"../models/href/Href\";\nimport type { RouterHistory } from \"react-router\";\n\nexport type PreferenceValue = {\n name: string,\n defaultValue?: string | null,\n type?: string,\n};\n\n/**\n */\nconst createReduxStore = (\n requestHref: Href,\n customReducers: Object,\n initialState?: $Shape<ReduxState>\n): ReduxStore => {\n // $FlowExpectedError\n const history: RouterHistory = createMemoryHistory({\n initialEntries: [requestHref.toString()],\n });\n\n const { store } = configureStore(history, customReducers, initialState);\n\n return store;\n};\n\n/**\n */\nconst setI18n = (\n store: ReduxStore,\n locales: Array<LocaleConfiguration> = [],\n request: HttpServletRequestJava\n) => {\n if (!Array.isArray(locales)) {\n throw new IllegalArgumentException(\"locales must be an array of objects\");\n }\n if (!request) {\n throw new IllegalArgumentException(\"missing request argument\");\n }\n\n const mergedLocales = availableLocales.map((locale) => {\n const code = locale.code;\n const customLocale = locales.find((custLocale) => custLocale.code === code);\n\n if (customLocale) {\n return deepmerge(locale, customLocale);\n }\n\n return locale;\n });\n\n locales.forEach((customLocale) => {\n if (!mergedLocales.some((locale) => locale.code === customLocale.code)) {\n mergedLocales.push(customLocale);\n }\n });\n\n const enabledLocales = mergedLocales.filter((locale: LocaleConfiguration) =>\n getSetting(\"ENABLED_LOCALES\").includes(locale.code)\n );\n\n const localesInstance = new Locales(enabledLocales);\n const preferredLocale = getPreferredLocale(request, localesInstance);\n store.dispatch(setLocales(localesInstance, preferredLocale ?? \"en\"));\n};\n\nconst setServerPreferencesFromArray = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>\n) => {\n serverPreferences.forEach((serverPreference) => {\n if (typeof serverPreference === \"object\") {\n const { name, defaultValue, type } = serverPreference;\n store.dispatch(setServerPreference(name, defaultValue, type));\n } else {\n store.dispatch(setServerPreference(serverPreference, null));\n }\n });\n};\n\n/**\n * Server preferences can be suplied by an array of preference names,\n * or an array of objects which has the name, an optional default value and an optional type.<br>\n * When the type is set to string, a comma separated value is not converted to an array:\n *\n * @example\n * // value becomes an array [default1, default2]\n * { name: \"prefName\", defaultValue: \"default1, default2\" }\n * // value remains a string \"default1, default2\"\n * { name: \"prefName\", defaultValue: \"default1, default2\", type: \"string\" }\n *\n * @param store\n * @param serverPreferences\n */\nconst setServerPreferences = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>\n) => {\n if (Array.isArray(serverPreferences)) {\n setServerPreferencesFromArray(store, serverPreferences);\n }\n\n store.dispatch(setAllContentInDataSetting());\n store.dispatch(setLoginPreferences());\n\n if (\n preferencesProvider &&\n preferencesProvider.isStudioContext &&\n preferencesProvider.isStudioContext()\n ) {\n store.dispatch(setPreference(\"isStudioContext\", true));\n }\n};\n\n/**\n */\nconst setConfigurationTheme = (store: ReduxStore) => {\n let configTheme = null;\n\n const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();\n if (typeof configFileLocation === \"string\") {\n const configFilePath = configFileLocation.startsWith(\"/\")\n ? `/resource${configFileLocation}`\n : `/resource/${configFileLocation}`;\n\n configTheme = dataFetcher.fetch(configFilePath);\n\n if (configTheme) {\n store.dispatch(setThemePreference(configTheme));\n } else {\n throw new Error(\n `Could not read theme configuration file from: ${configFilePath}`\n );\n }\n }\n};\n\n/**\n */\nconst setApplication = (store: ReduxStore) => {\n try {\n const locale = getLocale(store.getState());\n const application = new ModularUIRequest(\"/\", {\n locale: locale,\n }).fetchSync();\n\n store.dispatch(\n initModels([\n {\n key: `application(/)(${locale})`,\n model: application,\n },\n ])\n );\n } catch (e) {\n // eslint-disable-next-line no-console\n console.info(\"Could not load webapplication on server\");\n }\n};\n\n/**\n */\nconst handleErrors = (store: ReduxStore) => {\n const state = store.getState();\n\n if (\n state.error &&\n (state.error.shouldThrowOnServer ||\n !has(state.error, \"shouldThrowOnServer\"))\n ) {\n throw state.error;\n }\n};\n\n/**\n */\nconst dehydrate = (store: ReduxStore): string => {\n const state = store.getState();\n\n const modularui: {\n [key: string]: { status: string, lastModification: number, model: ?Object },\n } = {};\n\n for (const key in state.modularui) {\n const { status, model, lastModification } = state.modularui[key];\n\n if (model) {\n modularui[key] = {\n status,\n lastModification,\n model: model.dehydrate(),\n };\n } else {\n modularui[key] = {\n status,\n lastModification,\n model: undefined,\n };\n }\n }\n\n const filteredState = {\n ...state,\n modularui,\n };\n\n return JSON.stringify(filteredState).replace(/</g, \"\\\\u003c\");\n};\n\n/**\n */\nconst createHead = (\n sheet: any,\n UUID: string,\n helmetContext?: Object\n): Object => {\n const style = sheet.getStyleTags();\n const meta = helmetContext ? [...helmetContext.helmet.meta] : [];\n\n if (helmetContext) {\n return {\n ...helmetContext.helmet,\n style,\n meta,\n };\n }\n\n return {\n style,\n meta,\n };\n};\n\nexport {\n createReduxStore,\n setI18n,\n setApplication,\n setServerPreferences,\n setConfigurationTheme,\n createHead,\n handleErrors,\n dehydrate,\n};\n"],"mappings":";;;;;;;;;;;;;;;AACA;AACA;AACA;AAEA;AAEA;AAGA;AACA;AAEA;AAQA;AAEA;AAEA;AACA;AAEA;AAA6D;AAAA;AAa7D;AACA;AACA,MAAMA,gBAAgB,GAAG,CACvBC,WAAiB,EACjBC,cAAsB,EACtBC,YAAiC,KAClB;EACf;EACA,MAAMC,OAAsB,GAAG,IAAAC,4BAAmB,EAAC;IACjDC,cAAc,EAAE,CAACL,WAAW,CAACM,QAAQ,EAAE;EACzC,CAAC,CAAC;EAEF,MAAM;IAAEC;EAAM,CAAC,GAAG,IAAAC,uBAAc,EAACL,OAAO,EAAEF,cAAc,EAAEC,YAAY,CAAC;EAEvE,OAAOK,KAAK;AACd,CAAC;;AAED;AACA;AADA;AAEA,MAAME,OAAO,GAAG,UACdF,KAAiB,EAGd;EAAA,IAFHG,OAAmC,uEAAG,EAAE;EAAA,IACxCC,OAA+B;EAE/B,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,OAAO,CAAC,EAAE;IAC3B,MAAM,IAAII,oCAAwB,CAAC,qCAAqC,CAAC;EAC3E;EACA,IAAI,CAACH,OAAO,EAAE;IACZ,MAAM,IAAIG,oCAAwB,CAAC,0BAA0B,CAAC;EAChE;EAEA,MAAMC,aAAa,GAAG,kBAAAC,yBAAgB,OAAhBA,yBAAgB,EAAMC,MAAM,IAAK;IACrD,MAAMC,IAAI,GAAGD,MAAM,CAACC,IAAI;IACxB,MAAMC,YAAY,GAAG,mBAAAT,OAAO,OAAPA,OAAO,EAAOU,UAAU,IAAKA,UAAU,CAACF,IAAI,KAAKA,IAAI,CAAC;IAE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CAAC,MAAM;MACLC,SAAS,CAACX,GAAG,CAAC,GAAG;QACfY,MAAM;QACNC,gBAAgB;QAChBZ,KAAK,EAAEa;MACT,CAAC;IACH;EACF;EAEA,MAAMC,aAAa,GAAG;IACpB,GAAGT,KAAK;IACRK;EACF,CAAC;EAED,OAAO,wBAAeI,aAAa,CAAC,CAACC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;AAC/D,CAAC;;AAED;AACA;AADA;AAEA,MAAMC,UAAU,GAAG,CACjBC,KAAU,EACVC,IAAY,EACZC,aAAsB,KACX;EACX,MAAMC,KAAK,GAAGH,KAAK,CAACI,YAAY,EAAE;EAClC,MAAMC,IAAI,GAAGH,aAAa,GAAG,CAAC,GAAGA,aAAa,CAACI,MAAM,CAACD,IAAI,CAAC,GAAG,EAAE;EAEhE,IAAIH,aAAa,EAAE;IACjB,OAAO;MACL,GAAGA,aAAa,CAACI,MAAM;MACvBH,KAAK;MACLE;IACF,CAAC;EACH;EAEA,OAAO;IACLF,KAAK;IACLE;EACF,CAAC;AACH,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"file":"serverUtil.js","names":["createReduxStore","requestHref","customReducers","initialState","history","createMemoryHistory","initialEntries","toString","store","configureStore","setI18n","locales","request","Array","isArray","IllegalArgumentException","mergedLocales","availableLocales","locale","code","customLocale","custLocale","deepmerge","forEach","some","push","enabledLocales","getSetting","localesInstance","Locales","preferredLocale","getPreferredLocale","dispatch","setLocales","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreference","setServerPreferences","setAllContentInDataSetting","setLoginPreferences","preferencesProvider","isStudioContext","setPreference","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","dataFetcher","fetch","setThemePreference","Error","setApplication","getLocale","getState","application","ModularUIRequest","fetchSync","connectKey","initModels","key","model","e","console","info","handleErrors","state","error","shouldThrowOnServer","has","dehydrate","modularui","status","lastModification","undefined","filteredState","replace","createHead","sheet","UUID","helmetContext","style","getStyleTags","meta","helmet"],"sources":["../../src/react-server/serverUtil.js"],"sourcesContent":["// @flow\nimport { createMemoryHistory } from \"history\";\nimport { has } from \"../utils/helpers/objects\";\nimport deepmerge from \"deepmerge\";\n\nimport configureStore from \"../redux/store/configureStore\";\n\nimport { availableLocales } from \"../i18n/Locales\";\nimport Locales from \"../i18n/Locales\";\n\nimport { getPreferredLocale } from \"./requestInformation\";\nimport { setLocales } from \"../redux/_i18n/I18nActions\";\n\nimport {\n setServerPreference,\n setThemePreference,\n setPreference,\n setAllContentInDataSetting,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\n\nimport { getSetting } from \"../constants/Settings\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport { initModels } from \"../redux\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { ReduxState, ReduxStore } from \"../redux/types\";\nimport type Href from \"../models/href/Href\";\nimport type { RouterHistory } from \"react-router\";\n\nexport type PreferenceValue = {\n name: string,\n defaultValue?: string | null,\n type?: string,\n};\n\n/**\n */\nconst createReduxStore = (\n requestHref: Href,\n customReducers: Object,\n initialState?: $Shape<ReduxState>\n): ReduxStore => {\n // $FlowExpectedError\n const history: RouterHistory = createMemoryHistory({\n initialEntries: [requestHref.toString()],\n });\n\n const { store } = configureStore(history, customReducers, initialState);\n\n return store;\n};\n\n/**\n */\nconst setI18n = (\n store: ReduxStore,\n locales: Array<LocaleConfiguration> = [],\n request: HttpServletRequestJava\n) => {\n if (!Array.isArray(locales)) {\n throw new IllegalArgumentException(\"locales must be an array of objects\");\n }\n if (!request) {\n throw new IllegalArgumentException(\"missing request argument\");\n }\n\n const mergedLocales = availableLocales.map((locale) => {\n const code = locale.code;\n const customLocale = locales.find((custLocale) => custLocale.code === code);\n\n if (customLocale) {\n return deepmerge(locale, customLocale);\n }\n\n return locale;\n });\n\n locales.forEach((customLocale) => {\n if (!mergedLocales.some((locale) => locale.code === customLocale.code)) {\n mergedLocales.push(customLocale);\n }\n });\n\n const enabledLocales = mergedLocales.filter((locale: LocaleConfiguration) =>\n getSetting(\"ENABLED_LOCALES\").includes(locale.code)\n );\n\n const localesInstance = new Locales(enabledLocales);\n const preferredLocale = getPreferredLocale(request, localesInstance);\n store.dispatch(setLocales(localesInstance, preferredLocale ?? \"en\"));\n};\n\nconst setServerPreferencesFromArray = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>\n) => {\n serverPreferences.forEach((serverPreference) => {\n if (typeof serverPreference === \"object\") {\n const { name, defaultValue, type } = serverPreference;\n store.dispatch(setServerPreference(name, defaultValue, type));\n } else {\n store.dispatch(setServerPreference(serverPreference, null));\n }\n });\n};\n\n/**\n * Server preferences can be suplied by an array of preference names,\n * or an array of objects which has the name, an optional default value and an optional type.<br>\n * When the type is set to string, a comma separated value is not converted to an array:\n *\n * @example\n * // value becomes an array [default1, default2]\n * { name: \"prefName\", defaultValue: \"default1, default2\" }\n * // value remains a string \"default1, default2\"\n * { name: \"prefName\", defaultValue: \"default1, default2\", type: \"string\" }\n *\n * @param store\n * @param serverPreferences\n */\nconst setServerPreferences = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>\n) => {\n if (Array.isArray(serverPreferences)) {\n setServerPreferencesFromArray(store, serverPreferences);\n }\n\n store.dispatch(setAllContentInDataSetting());\n store.dispatch(setLoginPreferences());\n\n if (\n preferencesProvider &&\n preferencesProvider.isStudioContext &&\n preferencesProvider.isStudioContext()\n ) {\n store.dispatch(setPreference(\"isStudioContext\", true));\n }\n};\n\n/**\n */\nconst setConfigurationTheme = (store: ReduxStore) => {\n let configTheme = null;\n\n const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();\n if (typeof configFileLocation === \"string\") {\n const configFilePath = configFileLocation.startsWith(\"/\")\n ? `/resource${configFileLocation}`\n : `/resource/${configFileLocation}`;\n\n configTheme = dataFetcher.fetch(configFilePath);\n\n if (configTheme) {\n store.dispatch(setThemePreference(configTheme));\n } else {\n throw new Error(\n `Could not read theme configuration file from: ${configFilePath}`\n );\n }\n }\n};\n\n/**\n */\nconst setApplication = (store: ReduxStore) => {\n try {\n const locale = getLocale(store.getState());\n const application = new ModularUIRequest(\"/\", {\n locale: locale,\n }).fetchSync();\n\n application.connectKey = `application(/)(${locale})`;\n\n store.dispatch(\n initModels([\n {\n key: `application(/)(${locale})`,\n model: application,\n },\n ])\n );\n } catch (e) {\n // eslint-disable-next-line no-console\n console.info(\"Could not load webapplication on server\");\n }\n};\n\n/**\n */\nconst handleErrors = (store: ReduxStore) => {\n const state = store.getState();\n\n if (\n state.error &&\n (state.error.shouldThrowOnServer ||\n !has(state.error, \"shouldThrowOnServer\"))\n ) {\n throw state.error;\n }\n};\n\n/**\n */\nconst dehydrate = (store: ReduxStore): string => {\n const state = store.getState();\n\n const modularui: {\n [key: string]: { status: string, lastModification: number, model: ?Object },\n } = {};\n\n for (const key in state.modularui) {\n const { status, model, lastModification } = state.modularui[key];\n\n if (model) {\n modularui[key] = {\n status,\n lastModification,\n model: model.dehydrate(),\n };\n } else {\n modularui[key] = {\n status,\n lastModification,\n model: undefined,\n };\n }\n }\n\n const filteredState = {\n ...state,\n modularui,\n };\n\n return JSON.stringify(filteredState).replace(/</g, \"\\\\u003c\");\n};\n\n/**\n */\nconst createHead = (\n sheet: any,\n UUID: string,\n helmetContext?: Object\n): Object => {\n const style = sheet.getStyleTags();\n const meta = helmetContext ? [...helmetContext.helmet.meta] : [];\n\n if (helmetContext) {\n return {\n ...helmetContext.helmet,\n style,\n meta,\n };\n }\n\n return {\n style,\n meta,\n };\n};\n\nexport {\n createReduxStore,\n setI18n,\n setApplication,\n setServerPreferences,\n setConfigurationTheme,\n createHead,\n handleErrors,\n dehydrate,\n};\n"],"mappings":";;;;;;;;;;;;;;;AACA;AACA;AACA;AAEA;AAEA;AAGA;AACA;AAEA;AAQA;AAEA;AAEA;AACA;AAEA;AAA6D;AAAA;AAa7D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,GAAG,CACjBC,KAAU,EACVC,IAAY,EACZC,aAAsB,KACX;EACX,MAAMC,KAAK,GAAGH,KAAK,CAACI,YAAY,EAAE;EAClC,MAAMC,IAAI,GAAGH,aAAa,GAAG,CAAC,GAAGA,aAAa,CAACI,MAAM,CAACD,IAAI,CAAC,GAAG,EAAE;EAEhE,IAAIH,aAAa,EAAE;IACjB,OAAO;MACL,GAAGA,aAAa,CAACI,MAAM;MACvBH,KAAK;MACLE;IACF,CAAC;EACH;EAEA,OAAO;IACLF,KAAK;IACLE;EACF,CAAC;AACH,CAAC;AAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.27.
|
|
3
|
+
"version": "1.27.3",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "http://support.beinformed.com",
|
|
@@ -125,11 +125,11 @@
|
|
|
125
125
|
"eslint-plugin-ft-flow": "^2.0.3",
|
|
126
126
|
"eslint-plugin-import": "^2.27.5",
|
|
127
127
|
"eslint-plugin-jest": "^27.2.1",
|
|
128
|
-
"eslint-plugin-jsdoc": "^39.
|
|
128
|
+
"eslint-plugin-jsdoc": "^39.8.0",
|
|
129
129
|
"eslint-plugin-react": "^7.32.2",
|
|
130
130
|
"eslint-plugin-react-hooks": "^4.5.0",
|
|
131
131
|
"eslint-plugin-you-dont-need-lodash-underscore": "^6.12.0",
|
|
132
|
-
"flow-bin": "^0.
|
|
132
|
+
"flow-bin": "^0.199.1",
|
|
133
133
|
"flow-copy-source": "^2.0.9",
|
|
134
134
|
"flow-typed": "^3.8.0",
|
|
135
135
|
"glob": "^8.1.0",
|
|
@@ -156,6 +156,11 @@ export const ATTRIBUTE_WIDTH = {
|
|
|
156
156
|
|
|
157
157
|
export const ALL_CONTENT_IN_DATA_SETTING = "hasAllContentInData";
|
|
158
158
|
|
|
159
|
+
export const INTERNAL_LOGIN_TYPE = {
|
|
160
|
+
JAAS: "JAAS",
|
|
161
|
+
PAC4J_FORM: "PAC4J_FORM",
|
|
162
|
+
PAC4J_BASIC: "PAC4J_BASIC",
|
|
163
|
+
};
|
|
159
164
|
export const LOGIN_TYPE = "security.clients";
|
|
160
165
|
export const LOGIN_PATH_SETTING = "FormClient.login_url";
|
|
161
166
|
export const LOGIN_USERNAME_SETTING = "FormClient.username_field_name";
|
|
@@ -3,6 +3,7 @@ import { isPlainObject, has } from "../utils/helpers/objects";
|
|
|
3
3
|
import { getRepositoryResourceUrl } from "../utils/helpers/repositoryResource";
|
|
4
4
|
import {
|
|
5
5
|
ALL_CONTENT_IN_DATA_SETTING,
|
|
6
|
+
INTERNAL_LOGIN_TYPE,
|
|
6
7
|
LOGIN_TYPE,
|
|
7
8
|
LOGIN_PATH_SETTING,
|
|
8
9
|
LOGIN_USERNAME_SETTING,
|
|
@@ -186,13 +187,16 @@ export const hasAllContentInData = (): boolean =>
|
|
|
186
187
|
|
|
187
188
|
/**
|
|
188
189
|
* Login type, only available when pac4j is configured
|
|
190
|
+
*
|
|
191
|
+
* Preview does not support pac4j, thus is probably not configured when started, which results in login type JAAS
|
|
189
192
|
*/
|
|
190
|
-
export const loginType = (): string =>
|
|
193
|
+
export const loginType = (): string =>
|
|
194
|
+
getSetting(LOGIN_TYPE, INTERNAL_LOGIN_TYPE.JAAS);
|
|
191
195
|
|
|
192
196
|
/**
|
|
193
197
|
*/
|
|
194
198
|
export const loginPath = (): string =>
|
|
195
|
-
getSetting(LOGIN_PATH_SETTING, "/
|
|
199
|
+
getSetting(LOGIN_PATH_SETTING, "/callback?client_name=FormClient");
|
|
196
200
|
/**
|
|
197
201
|
*/
|
|
198
202
|
export const loginUsernameField = (): string =>
|
|
@@ -204,7 +208,7 @@ export const loginPasswordField = (): string =>
|
|
|
204
208
|
/**
|
|
205
209
|
*/
|
|
206
210
|
export const logoutPath = (): string =>
|
|
207
|
-
getSetting(LOGOUT_PATH_SETTING, "/
|
|
211
|
+
getSetting(LOGOUT_PATH_SETTING, "/logout");
|
|
208
212
|
|
|
209
213
|
export const LOGIN_PATH: string = loginPath();
|
|
210
214
|
export const LOGOUT_PATH: string = logoutPath();
|