@beinformed/ui 1.63.4 → 1.63.6
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 +16 -0
- package/esm/constants/Constants.js +2 -1
- package/esm/constants/Constants.js.flow +1 -0
- package/esm/constants/Constants.js.map +1 -1
- package/esm/constants/Settings.js +2 -4
- package/esm/constants/Settings.js.flow +2 -4
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/__tests__/useAuthentication.spec.js.flow +2 -1
- package/esm/hooks/useAuthentication.js +3 -1
- package/esm/hooks/useAuthentication.js.flow +5 -1
- package/esm/hooks/useAuthentication.js.map +1 -1
- package/esm/models/concepts/ConceptDetailModel.js +5 -1
- package/esm/models/concepts/ConceptDetailModel.js.flow +6 -0
- package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
- package/esm/models/concepts/SourceReferenceCollection.js +9 -2
- package/esm/models/concepts/SourceReferenceCollection.js.flow +12 -4
- package/esm/models/concepts/SourceReferenceCollection.js.map +1 -1
- package/esm/models/concepts/SourceReferenceModel.js +6 -0
- package/esm/models/concepts/SourceReferenceModel.js.flow +6 -0
- package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
- package/esm/modularui/Authenticate.js +9 -3
- package/esm/modularui/Authenticate.js.flow +9 -4
- package/esm/modularui/Authenticate.js.map +1 -1
- package/lib/constants/Constants.js +2 -1
- package/lib/constants/Constants.js.map +1 -1
- package/lib/constants/Settings.js +2 -4
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/useAuthentication.js +3 -1
- package/lib/hooks/useAuthentication.js.map +1 -1
- package/lib/models/concepts/ConceptDetailModel.js +5 -1
- package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
- package/lib/models/concepts/SourceReferenceCollection.js +9 -2
- package/lib/models/concepts/SourceReferenceCollection.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.js +6 -0
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/modularui/Authenticate.js +9 -3
- package/lib/modularui/Authenticate.js.map +1 -1
- package/package.json +7 -7
- package/src/constants/Constants.js +1 -0
- package/src/constants/Settings.js +2 -4
- package/src/hooks/__tests__/useAuthentication.spec.js +2 -1
- package/src/hooks/useAuthentication.js +5 -1
- package/src/models/concepts/ConceptDetailModel.js +6 -0
- package/src/models/concepts/SourceReferenceCollection.js +12 -4
- package/src/models/concepts/SourceReferenceModel.js +6 -0
- package/src/modularui/Authenticate.js +9 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Authenticate.js","names":["_Constants","require","_universalFetch","_interopRequireDefault","_Cache","_exceptions","_constants","Authenticate","constructor","_defineProperty2","default","_isBasic","authenticationType","type","loginType","INTERNAL_LOGIN_TYPE","JAAS","_includes","call","PAC4J_FORM","PAC4J_BASIC","Error","isBasicAuthentication","requestLogin","universalFetch","url","getBasePath","method","HTTP_METHODS","GET","headers","Accept","initLogin","_promise","resolve","catch","error","UnauthorizedException","login","username","password","doFormLogin","doBasicAuthentication","doJaasAuthentication","getFormLoginUrl","loginPath","getFormLoginData","encodedUsername","encodeURIComponent","encodedPassword","loginUsernameField","loginPasswordField","POST","data","Cache","addItem","btoa","then","removeItem","getLogoutUrl","logoutPath","logout","response","clear","_default","exports"],"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 return `${getBasePath()}${loginPath(\"DirectBasicAuthClient\")}`;\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return `${getBasePath()}${loginPath(\"FormClient\")}`;\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 Cache.removeItem(\"basic-ok\");\n return this.doBasicAuthentication(username, password).then(() => {\n Cache.addItem(\"basic-ok\", true);\n });\n }\n return this.doFormLogin(username, password);\n });\n }\n\n /**\n */\n getLogoutUrl(): string {\n const type = loginType();\n\n if (!type || type === INTERNAL_LOGIN_TYPE.JAAS) {\n return `${getBasePath()}/Logoff`;\n }\n\n return `${getBasePath()}${logoutPath()}`;\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,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;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AC;QAC5B,OAAO,IAAI,CAAChB,qBAAqB,CAACH,QAAQ,EAAEC,QAAQ,CAAC,CAACiB,IAAI,CAAC,MAAM;UAC/DH,cAAK,CAACC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC;QACjC,CAAC,CAAC;MACJ;MACA,OAAO,IAAI,CAACd,WAAW,CAACF,QAAQ,EAAEC,QAAQ,CAAC;IAC7C,CAAC,CAAC;EACJ;;EAEA;AACF;EACEmB,YAAYA,CAAA,EAAW;IACrB,MAAM9C,IAAI,GAAG,IAAAC,oBAAS,EAAC,CAAC;IAExB,IAAI,CAACD,IAAI,IAAIA,IAAI,KAAKE,8BAAmB,CAACC,IAAI,EAAE;MAC9C,OAAO,GAAG,IAAAU,sBAAW,EAAC,CAAC,SAAS;IAClC;IAEA,OAAO,GAAG,IAAAA,sBAAW,EAAC,CAAC,GAAG,IAAAkC,qBAAU,EAAC,CAAC,EAAE;EAC1C;;EAEA;AACF;EACEC,MAAMA,CAAA,EAAiB;IACrB,OAAO,IAAArC,uBAAc,EAAC;MACpBC,GAAG,EAAE,IAAI,CAACkC,YAAY,CAAC;IACzB,CAAC,CAAC,CAACF,IAAI,CAAEK,QAAQ,IAAK;MACpB;MACAR,cAAK,CAACS,KAAK,CAAC,CAAC;MACb,OAAOD,QAAQ;IACjB,CAAC,CAAC;EACJ;AACF;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAvD,OAAA,GAEcH,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Authenticate.js","names":["_Constants","require","_universalFetch","_interopRequireDefault","_Cache","_exceptions","_constants","Authenticate","constructor","_defineProperty2","default","_isBasic","authenticationType","type","loginType","INTERNAL_LOGIN_TYPE","JAAS","_includes","call","PAC4J_FORM","PAC4J_BASIC","PAC4J_INDIRECT","isBasicAuthentication","requestLogin","universalFetch","url","getBasePath","method","HTTP_METHODS","GET","headers","Accept","initLogin","_promise","resolve","catch","error","UnauthorizedException","login","username","password","doFormLogin","doBasicAuthentication","doJaasAuthentication","getFormLoginUrl","loginPath","getFormLoginData","encodedUsername","encodeURIComponent","encodedPassword","loginUsernameField","loginPasswordField","POST","data","Cache","addItem","btoa","then","removeItem","getLogoutUrl","logoutPath","logout","response","clear","_default","exports"],"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 return INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT;\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 case INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT:\n // pac4j should handle this\n return Promise.resolve();\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 return `${getBasePath()}${loginPath(\"DirectBasicAuthClient\")}`;\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return `${getBasePath()}${loginPath(\"FormClient\")}`;\n case INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT:\n //pac4j should handle this\n return \"\";\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 Cache.removeItem(\"basic-ok\");\n return this.doBasicAuthentication(username, password).then(() => {\n Cache.addItem(\"basic-ok\", true);\n });\n }\n return this.doFormLogin(username, password);\n });\n }\n\n /**\n */\n static getLogoutUrl(): string {\n const type = loginType();\n\n if (!type || type === INTERNAL_LOGIN_TYPE.JAAS) {\n return `${getBasePath()}/Logoff`;\n }\n\n return `${getBasePath()}${logoutPath()}`;\n }\n\n /**\n */\n logout(): Promise<any> {\n return universalFetch({\n url: Authenticate.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,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AAUA;AACA;AACA,MAAMM,YAAY,CAAC;EAGjB;AACF;EACEC,WAAWA,CAAA,EAAG;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IACZ,IAAI,CAACC,QAAQ,GAAG,KAAK;EACvB;;EAEA;AACF;EACE,IAAIC,kBAAkBA,CAAA,EAAsC;IAC1D,MAAMC,IAAI,GAAG,IAAAC,oBAAS,EAAC,CAAC;IAExB,IAAI,CAACD,IAAI,IAAIA,IAAI,KAAKE,8BAAmB,CAACC,IAAI,EAAE;MAC9C,OAAOD,8BAAmB,CAACC,IAAI;IACjC;IAEA,IAAI,IAAAC,SAAA,CAAAP,OAAA,EAAAG,IAAI,EAAAK,IAAA,CAAJL,IAAI,EAAU,YAAY,CAAC,EAAE;MAC/B,OAAOE,8BAAmB,CAACI,UAA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AExB,IAAI,CAACD,IAAI,IAAIA,IAAI,KAAKE,8BAAmB,CAACC,IAAI,EAAE;MAC9C,OAAO,GAAG,IAAAU,sBAAW,EAAC,CAAC,SAAS;IAClC;IAEA,OAAO,GAAG,IAAAA,sBAAW,EAAC,CAAC,GAAG,IAAAkC,qBAAU,EAAC,CAAC,EAAE;EAC1C;;EAEA;AACF;EACEC,MAAMA,CAAA,EAAiB;IACrB,OAAO,IAAArC,uBAAc,EAAC;MACpBC,GAAG,EAAElB,YAAY,CAACoD,YAAY,CAAC;IACjC,CAAC,CAAC,CAACF,IAAI,CAAEK,QAAQ,IAAK;MACpB;MACAR,cAAK,CAACS,KAAK,CAAC,CAAC;MACb,OAAOD,QAAQ;IACjB,CAAC,CAAC;EACJ;AACF;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAvD,OAAA,GAEcH,YAAY","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.63.
|
|
3
|
+
"version": "1.63.6",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "https://support.beinformed.com",
|
|
@@ -89,15 +89,15 @@
|
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@babel/cli": "^7.28.3",
|
|
92
|
-
"@babel/core": "^7.28.
|
|
93
|
-
"@babel/eslint-parser": "^7.28.
|
|
92
|
+
"@babel/core": "^7.28.5",
|
|
93
|
+
"@babel/eslint-parser": "^7.28.5",
|
|
94
94
|
"@babel/eslint-plugin": "^7.27.1",
|
|
95
95
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
96
96
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
97
|
-
"@babel/plugin-transform-runtime": "^7.28.
|
|
98
|
-
"@babel/preset-env": "^7.28.
|
|
97
|
+
"@babel/plugin-transform-runtime": "^7.28.5",
|
|
98
|
+
"@babel/preset-env": "^7.28.5",
|
|
99
99
|
"@babel/preset-flow": "^7.27.1",
|
|
100
|
-
"@babel/preset-react": "^7.
|
|
100
|
+
"@babel/preset-react": "^7.28.5",
|
|
101
101
|
"@commitlint/cli": "^19.8.1",
|
|
102
102
|
"@commitlint/config-conventional": "^19.8.1",
|
|
103
103
|
"@testing-library/dom": "^10.4.1",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"redux": "^4.2.1",
|
|
142
142
|
"redux-mock-store": "^1.5.5",
|
|
143
143
|
"redux-thunk": "^2.4.2",
|
|
144
|
-
"rimraf": "^6.0
|
|
144
|
+
"rimraf": "^6.1.0",
|
|
145
145
|
"styled-components": "^5.3.11",
|
|
146
146
|
"typescript": "^5.9.3",
|
|
147
147
|
"xhr-mock": "^2.5.1"
|
|
@@ -176,6 +176,7 @@ export const INTERNAL_LOGIN_TYPE = {
|
|
|
176
176
|
JAAS: "JAAS",
|
|
177
177
|
PAC4J_FORM: "PAC4J_FORM",
|
|
178
178
|
PAC4J_BASIC: "PAC4J_BASIC",
|
|
179
|
+
PAC4J_INDIRECT: "PAC4J_INDIRECT",
|
|
179
180
|
};
|
|
180
181
|
export const LOGIN_TYPE = "security.clients";
|
|
181
182
|
export const LOGIN_PATH_SETTING = "FormClient.login_url";
|
|
@@ -166,7 +166,7 @@ export const cacheContributions = (): boolean =>
|
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
168
|
* The context path is retrieved on the server using the context path property as set in the runtime properties
|
|
169
|
-
* This can be manually
|
|
169
|
+
* This can be manually overriden by setting the UI setting 'CONTEXT_PATH'
|
|
170
170
|
*/
|
|
171
171
|
export const getBasePath = (): string =>
|
|
172
172
|
getSetting("CONTEXT_PATH", "/BeInformed");
|
|
@@ -215,9 +215,7 @@ export const getEnabledLocales = (): Array<string> =>
|
|
|
215
215
|
getSetting("ENABLED_LOCALES", ["en"]);
|
|
216
216
|
|
|
217
217
|
/**
|
|
218
|
-
* Login type
|
|
219
|
-
*
|
|
220
|
-
* Preview does not support pac4j, thus is probably not configured when started, which results in login type JAAS
|
|
218
|
+
* Login type
|
|
221
219
|
*/
|
|
222
220
|
export const loginType = (): string =>
|
|
223
221
|
getSetting(LOGIN_TYPE, INTERNAL_LOGIN_TYPE.JAAS);
|
|
@@ -76,7 +76,7 @@ describe("authentication hooks", () => {
|
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
it("useLogout", async () => {
|
|
79
|
-
expect.assertions(
|
|
79
|
+
expect.assertions(7);
|
|
80
80
|
|
|
81
81
|
xhrMock.get("/BeInformed/Logoff", (req, res) => {
|
|
82
82
|
expect(req.header("accept")).toBe(JSON_TYPE);
|
|
@@ -99,6 +99,7 @@ describe("authentication hooks", () => {
|
|
|
99
99
|
|
|
100
100
|
expect(result.current.isAuthenticated).toBe(false);
|
|
101
101
|
expect(typeof result.current.logout).toBe("function");
|
|
102
|
+
expect(result.current.logoutUrl).toBe("/BeInformed/Logoff");
|
|
102
103
|
|
|
103
104
|
await result.current.logout();
|
|
104
105
|
|
|
@@ -10,10 +10,12 @@ import {
|
|
|
10
10
|
getBasePathServer,
|
|
11
11
|
logoutPath,
|
|
12
12
|
} from "../constants";
|
|
13
|
+
import { IllegalStateException } from "../exceptions";
|
|
14
|
+
import { Authenticate } from "../modularui";
|
|
13
15
|
|
|
14
16
|
import type { ResetAuthErrorsAction } from "../redux/types";
|
|
15
17
|
import type { AuthenticationType } from "../models/types";
|
|
16
|
-
|
|
18
|
+
|
|
17
19
|
type LoginHook = {
|
|
18
20
|
isAuthenticated: boolean,
|
|
19
21
|
authenticationTypes: Array<AuthenticationType>,
|
|
@@ -26,6 +28,7 @@ type LogoutHook = {
|
|
|
26
28
|
isAuthenticated: boolean,
|
|
27
29
|
authenticationTypes: Array<AuthenticationType>,
|
|
28
30
|
logout: () => void,
|
|
31
|
+
logoutUrl: string,
|
|
29
32
|
};
|
|
30
33
|
|
|
31
34
|
/**
|
|
@@ -94,5 +97,6 @@ export const useLogout = (): LogoutHook => {
|
|
|
94
97
|
return dispatch(logout());
|
|
95
98
|
}
|
|
96
99
|
},
|
|
100
|
+
logoutUrl: Authenticate.getLogoutUrl(),
|
|
97
101
|
};
|
|
98
102
|
};
|
|
@@ -271,8 +271,14 @@ export default class ConceptDetailModel extends ResourceModel {
|
|
|
271
271
|
availableLocales: Array<string> = [],
|
|
272
272
|
): SourceReferenceCollection {
|
|
273
273
|
if (!this._sourceReferences) {
|
|
274
|
+
let sectionReferenceTypes = [];
|
|
275
|
+
if (this.conceptType && this.conceptType.sectionReferenceTypes) {
|
|
276
|
+
sectionReferenceTypes = this.conceptType.sectionReferenceTypes;
|
|
277
|
+
}
|
|
278
|
+
|
|
274
279
|
this._sourceReferences = new SourceReferenceCollection(
|
|
275
280
|
this.getSourceReferencesForCurrentLanguage(availableLocales),
|
|
281
|
+
sectionReferenceTypes,
|
|
276
282
|
this.entryDate,
|
|
277
283
|
this.modelOptions,
|
|
278
284
|
);
|
|
@@ -11,16 +11,24 @@ export default class SourceReferenceCollection extends BaseCollection<SourceRefe
|
|
|
11
11
|
*/
|
|
12
12
|
constructor(
|
|
13
13
|
sourceReferences: Array<Object> = [],
|
|
14
|
+
sectionReferenceTypes: Array<Object> = [],
|
|
14
15
|
entryDate: ?ISO_DATE = null,
|
|
15
16
|
modelOptions?: ModelOptions,
|
|
16
17
|
) {
|
|
17
18
|
super();
|
|
18
19
|
|
|
19
20
|
this.collection = sourceReferences
|
|
20
|
-
? sourceReferences.map(
|
|
21
|
-
(
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
? sourceReferences.map((sourceReference) => {
|
|
22
|
+
const sectionReferenceType = sectionReferenceTypes.find(
|
|
23
|
+
(sectionReferenceType) =>
|
|
24
|
+
sectionReferenceType._id === sourceReference.type,
|
|
25
|
+
);
|
|
26
|
+
return new SourceReferenceModel(
|
|
27
|
+
{ typeLabel: sectionReferenceType?.label, ...sourceReference },
|
|
28
|
+
entryDate,
|
|
29
|
+
modelOptions,
|
|
30
|
+
);
|
|
31
|
+
})
|
|
24
32
|
: [];
|
|
25
33
|
}
|
|
26
34
|
|
|
@@ -40,8 +40,7 @@ class Authenticate {
|
|
|
40
40
|
} else if (type.includes("BasicClient")) {
|
|
41
41
|
return INTERNAL_LOGIN_TYPE.PAC4J_BASIC;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
throw new Error(`Unsupported login type found: ${type}`);
|
|
43
|
+
return INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
/**
|
|
@@ -99,6 +98,9 @@ class Authenticate {
|
|
|
99
98
|
return this.doFormLogin(username, password);
|
|
100
99
|
case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:
|
|
101
100
|
return this.doBasicAuthentication(username, password);
|
|
101
|
+
case INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT:
|
|
102
|
+
// pac4j should handle this
|
|
103
|
+
return Promise.resolve();
|
|
102
104
|
default:
|
|
103
105
|
return this.doJaasAuthentication(username, password);
|
|
104
106
|
}
|
|
@@ -112,6 +114,9 @@ class Authenticate {
|
|
|
112
114
|
return `${getBasePath()}${loginPath("DirectBasicAuthClient")}`;
|
|
113
115
|
case INTERNAL_LOGIN_TYPE.PAC4J_FORM:
|
|
114
116
|
return `${getBasePath()}${loginPath("FormClient")}`;
|
|
117
|
+
case INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT:
|
|
118
|
+
//pac4j should handle this
|
|
119
|
+
return "";
|
|
115
120
|
default:
|
|
116
121
|
return `${getBasePath()}/j_security_check`;
|
|
117
122
|
}
|
|
@@ -169,7 +174,7 @@ class Authenticate {
|
|
|
169
174
|
|
|
170
175
|
/**
|
|
171
176
|
*/
|
|
172
|
-
getLogoutUrl(): string {
|
|
177
|
+
static getLogoutUrl(): string {
|
|
173
178
|
const type = loginType();
|
|
174
179
|
|
|
175
180
|
if (!type || type === INTERNAL_LOGIN_TYPE.JAAS) {
|
|
@@ -183,7 +188,7 @@ class Authenticate {
|
|
|
183
188
|
*/
|
|
184
189
|
logout(): Promise<any> {
|
|
185
190
|
return universalFetch({
|
|
186
|
-
url:
|
|
191
|
+
url: Authenticate.getLogoutUrl(),
|
|
187
192
|
}).then((response) => {
|
|
188
193
|
// clear cache because of cached contributions
|
|
189
194
|
Cache.clear();
|