keycloakify 4.2.14-beta.1 → 4.2.14

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 CHANGED
@@ -1,3 +1,20 @@
1
+ ### **4.2.14** (2021-12-12)
2
+
3
+ - Merge pull request #65 from InseeFrLab/doge_ftl_errors
4
+
5
+ Prevent ftl errors in Keycloak log
6
+ - Encourage users to report errors in logs
7
+ - Fix ftl error related to url.loginAction in saml-post-form.ftl
8
+ - Ftl prevent error with updateProfileCtx
9
+ - Ftl prevent error with auth.attemptedUsername
10
+ - Fix ftl error as comment formatting
11
+ - Merge remote-tracking branch 'origin/main' into doge_ftl_errors
12
+ - Update README, remove all instruction about errors in logs
13
+ - Avoid error in Keycloak logs, fix long template loading time
14
+ - Add missing collon in README sample code
15
+
16
+ Add miss ','
17
+
1
18
  ### **4.2.13** (2021-12-08)
2
19
 
3
20
  - Fix broken link about how to import fonts #62
package/README.md CHANGED
@@ -20,10 +20,10 @@
20
20
  <img src="https://user-images.githubusercontent.com/6702424/110260457-a1c3d380-7fac-11eb-853a-80459b65626b.png">
21
21
  </p>
22
22
 
23
- **NEW in v4**
23
+ **NEW in 4.2.14**
24
24
 
25
- - Out of the box [frontend form validation](#user-profile-and-frontend-form-validation) 🥳
26
- - Improvements (and breaking changes in `import { useKcMessage } from "keycloakify"`.
25
+ - No more error in Keycloak logs 🍾
26
+ - Templates now load in fraction of a second 🏎
27
27
 
28
28
  # Motivations
29
29
 
@@ -71,13 +71,12 @@ If you already have a Keycloak custom theme, it can be easily ported to Keycloak
71
71
  - [GitHub Actions](#github-actions)
72
72
  - [Limitations](#limitations)
73
73
  - [`process.env.PUBLIC_URL` not supported.](#processenvpublic_url-not-supported)
74
- - [`@font-face` importing fonts from the `src/` dir](#font-face-importing-fonts-from-thesrc-dir)
74
+ - [`@font-face` importing fonts from the `src/` dir](#font-face-importing-fonts-from-the-src-dir)
75
75
  - [Example of setup that **won't** work](#example-of-setup-that-wont-work)
76
76
  - [Possible workarounds](#possible-workarounds)
77
77
  - [Implement context persistence (optional)](#implement-context-persistence-optional)
78
78
  - [Kickstart video](#kickstart-video)
79
- - [About the errors related to `objectToJson` in Keycloak logs. (problem soon to be fixed)](#about-the-errors-related-to-objecttojson-in-keycloak-logs)
80
- - [The pages take too long to load ? (soon to be fixed too)](#the-pages-take-too-long-to-load-)
79
+ - [FTL errors related to `ftl_object_to_js_code_declaring_an_object` in Keycloak logs.](#ftl-errors-related-to-ftl_object_to_js_code_declaring_an_object-in-keycloak-logs)
81
80
  - [Adding custom message (to `i18n/useKcMessage.tsx`)](#adding-custom-message-to-i18nusekcmessagetsx)
82
81
  - [Email domain whitelist](#email-domain-whitelist)
83
82
  - [Changelog highlights](#changelog-highlights)
@@ -354,7 +353,7 @@ the building and publishing of the theme (the .jar file).
354
353
  You won't be able to [import things from your public directory **in your JavaScript code**](https://create-react-app.dev/docs/using-the-public-folder/#adding-assets-outside-of-the-module-system).
355
354
  (This isn't recommended anyway).
356
355
 
357
- ## `@font-face` importing fonts from the `src/` dir
356
+ ## `@font-face` importing fonts from the `src/` dir
358
357
 
359
358
  If you are building the theme with [--external-assets](#enable-loading-in-a-blink-of-a-eye-of-login-pages-)
360
359
  this limitation doesn't apply, you can import fonts however you see fit.
@@ -438,35 +437,22 @@ flash of the blank html before the js bundle have been evaluated
438
437
  _NOTE: keycloak-react-theming was renamed keycloakify since this video was recorded_
439
438
  [![kickstart_video](https://user-images.githubusercontent.com/6702424/108877866-f146ee80-75ff-11eb-8120-003b3c5f6dd8.png)](https://youtu.be/xTz0Rj7i2v8)
440
439
 
441
- # About the errors related to `objectToJson` in Keycloak logs.
440
+ # FTL errors related to `ftl_object_to_js_code_declaring_an_object` in Keycloak logs.
442
441
 
443
- The logs of your keycloak server will always show this kind of errors every time a client request a page:
442
+ If you ever encounter one of these errors:
444
443
 
445
444
  ```log
446
445
  FTL stack trace ("~" means nesting-related):
447
- - Failed at: #local value = object[key] [in template "login.ftl" in macro "objectToJson_please_ignore_errors" at line 70, column 21]
448
- - Reached through: @compress [in template "login.ftl" in macro "objectToJson_please_ignore_errors" at line 36, column 5]
449
- - Reached through: @objectToJson_please_ignore_errors object=value depth=(dep... [in template "login.ftl" in macro "objectToJson_please_ignore_errors" at line 81, column 27]
450
- - Reached through: @compress [in template "login.ftl" in macro "objectToJson_please_ignore_errors" at line 36, column 5]
451
- - Reached through: @objectToJson_please_ignore_errors object=(.data_model) de... [in template "login.ftl" at line 163, column 43]
446
+ - Failed at: #local value = object[key] [in template "login.ftl" in macro "ftl_object_to_js_code_declaring_an_object" at line 70, column 21]
447
+ - Reached through: @compress [in template "login.ftl" in macro "ftl_object_to_js_code_declaring_an_object" at line 36, column 5]
448
+ - Reached through: @ftl_object_to_js_code_declaring_an_object object=value depth=(dep... [in template "login.ftl" in macro "ftl_object_to_js_code_declaring_an_object" at line 81, column 27]
449
+ - Reached through: @compress [in template "login.ftl" in macro "ftl_object_to_js_code_declaring_an_object" at line 36, column 5]
450
+ - Reached through: @ftl_object_to_js_code_declaring_an_object object=(.data_model) de... [in template "login.ftl" at line 163, column 43]
452
451
  ```
453
452
 
454
- Theses are expected to show up in the log.
455
- Unfortunately, there is nothing I know of that can be done to avoid them or even mute them.
456
- They can be, however, safely ignored.
457
-
458
- To [converts the `.ftl` values into a JavaScript object](https://github.com/InseeFrLab/keycloakify/blob/main/src/bin/build-keycloak-theme/generateFtl/common.ftl)
459
- without making assumptions on the `.data_model` we have to do things that throws.
460
- It's all-right because every statement that can fail is inside an `<#attempt><#recorver>` block but it results in errors being printed to the logs.
461
-
462
- # The pages take too long to load ?
463
-
464
- The problem of templates taking a long time to load only happens in the test environment, when you have a console logging all the above-mentioned `.ftl` warnings in real time. Logging all those warnings is what takes time. Once in production page load is way faster.
465
-
466
- If you run the docker container locally we acknowledge that the loading time is getting out of hand.
467
- We are [in the process](https://github.com/InseeFrLab/keycloakify/pull/63) of resolving this issue.
468
-
469
- In the meantime we recommend [to run the docker container as a background task](https://youtu.be/F29Z1GaH-jk).
453
+ It's just noise, they can be safely ignored.
454
+ You can, however, and are encouraged to, report any that you would spot.
455
+ Just open an issue about it and I will release a patched version of Keycloakify in the better delays.
470
456
 
471
457
  # Adding custom message (to `i18n/useKcMessage.tsx`)
472
458
 
@@ -1,4 +1,5 @@
1
1
  <script>const _=
2
+ <#assign pageId="PAGE_ID_xIgLsPgGId9D8e">
2
3
  (()=>{
3
4
 
4
5
  const out =
@@ -76,9 +77,11 @@ ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc};
76
77
  }
77
78
  };
78
79
 
80
+ out["pageId"] = "${pageId}";
81
+
79
82
  return out;
80
83
 
81
- })();
84
+ })()
82
85
  <#function ftl_object_to_js_code_declaring_an_object object path>
83
86
 
84
87
  <#local isHash = "">
@@ -112,13 +115,35 @@ ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc};
112
115
  </#if>
113
116
 
114
117
  <#if
115
- ["loginUpdatePasswordUrl", "loginUpdateProfileUrl", "loginUsernameReminderUrl", "loginUpdateTotpUrl"]?seq_contains(key) &&
116
- path?map(x -> x?is_number?string("_index_",x))?join("°") == ["url"]?join("°")
118
+ (
119
+ ["loginUpdatePasswordUrl", "loginUpdateProfileUrl", "loginUsernameReminderUrl", "loginUpdateTotpUrl"]?seq_contains(key) &&
120
+ are_same_path(path, ["url"])
121
+ ) || (
122
+ key == "updateProfileCtx" &&
123
+ are_same_path(path, [])
124
+ ) || (
125
+ <#-- https://github.com/InseeFrLab/keycloakify/pull/65#issuecomment-991896344 -->
126
+ key == "loginAction" &&
127
+ are_same_path(path, ["url"]) &&
128
+ pageId == "saml-post-form.ftl"
129
+ )
117
130
  >
118
- <#local out_seq += ["/*If you need" + key + " please submit an issue to the Keycloakify repo*/"]>
131
+ <#local out_seq += ["/*If you need '" + key + "' on " + pageId + ", please submit an issue to the Keycloakify repo*/"]>
119
132
  <#continue>
120
133
  </#if>
121
134
 
135
+ <#if key == "attemptedUsername" && are_same_path(path, ["auth"])>
136
+
137
+ <#attempt>
138
+ <#-- https://github.com/keycloak/keycloak/blob/3a2bf0c04bcde185e497aaa32d0bb7ab7520cf4a/themes/src/main/resources/theme/base/login/template.ftl#L63 -->
139
+ <#if !(auth?has_content && auth.showUsername() && !auth.showResetCredentials())>
140
+ <#continue>
141
+ </#if>
142
+ <#recover>
143
+ </#attempt>
144
+
145
+ </#if>
146
+
122
147
  <#attempt>
123
148
  <#if !object[key]??>
124
149
  <#continue>
@@ -226,5 +251,40 @@ ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc};
226
251
 
227
252
  <#return "ABORT: Couldn't convert into string non hash, non method, non boolean, non enumerable object">
228
253
 
254
+ </#function>
255
+ <#function are_same_path path searchedPath>
256
+
257
+ <#if path?size != path?size>
258
+ <#return false>
259
+ </#if>
260
+
261
+ <#local i=0>
262
+
263
+ <#list path as property>
264
+
265
+ <#local searchedProperty=searchedPath[i]>
266
+
267
+ <#if searchedProperty?is_string && searchedProperty == "*">
268
+ <#continue>
269
+ </#if>
270
+
271
+ <#if searchedProperty?is_string && !property?is_string>
272
+ <#return false>
273
+ </#if>
274
+
275
+ <#if searchedProperty?is_number && !property?is_number>
276
+ <#return false>
277
+ </#if>
278
+
279
+ <#if searchedProperty?string != property?string>
280
+ <#return false>
281
+ </#if>
282
+
283
+ <#local i+= 1>
284
+
285
+ </#list>
286
+
287
+ <#return true>
288
+
229
289
  </#function>
230
290
  </script>
@@ -121,7 +121,6 @@ function generateFtlFilesCodeFactory(params) {
121
121
  "</#if>",
122
122
  ].join("\n"),
123
123
  };
124
- var pageIdSearchValue = "PAGE_ID_xIgLsPgGId9D8e";
125
124
  $("head").prepend(__spreadArray(__spreadArray([], __read((Object.keys(cssGlobalsToDefine).length === 0
126
125
  ? []
127
126
  : [
@@ -136,18 +135,18 @@ function generateFtlFilesCodeFactory(params) {
136
135
  ])), false), [
137
136
  "<script>",
138
137
  " window." + ftlValuesGlobalName_1.ftlValuesGlobalName + "= " + (0, objectKeys_1.objectKeys)(replaceValueBySearchValue)[0] + ";",
139
- " window." + ftlValuesGlobalName_1.ftlValuesGlobalName + "[\"pageId\"]= \"" + pageIdSearchValue + "\";",
140
138
  "</script>",
141
139
  "",
142
140
  (0, objectKeys_1.objectKeys)(replaceValueBySearchValue)[1],
143
141
  ], false).join("\n"));
144
142
  var partiallyFixedIndexHtmlCode = $.html();
145
143
  function generateFtlFilesCode(params) {
146
- var _a;
147
144
  var pageId = params.pageId;
148
145
  var $ = cheerio_1.default.load(partiallyFixedIndexHtmlCode);
149
146
  var ftlCode = $.html();
150
- Object.entries(__assign(__assign({}, replaceValueBySearchValue), (_a = {}, _a[pageIdSearchValue] = pageId, _a))).map(function (_a) {
147
+ Object.entries(__assign(__assign({}, replaceValueBySearchValue), {
148
+ //If updated, don't forget to change in the ftl script as well.
149
+ "PAGE_ID_xIgLsPgGId9D8e": pageId })).map(function (_a) {
151
150
  var _b = __read(_a, 2), searchValue = _b[0], replaceValue = _b[1];
152
151
  return (ftlCode = ftlCode.replace(searchValue, replaceValue));
153
152
  });
@@ -1 +1 @@
1
- {"version":3,"file":"generateFtl.js","sourceRoot":"","sources":["../../../src/bin/build-keycloak-theme/generateFtl/generateFtl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA8B;AAC9B,sEAA6I;AAC7I,0CAAoB;AACpB,6BAAwC;AACxC,+CAA8C;AAC9C,8DAA6D;AAEhD,QAAA,OAAO,GAAG;IACnB,WAAW;IACX,cAAc;IACd,2BAA2B;IAC3B,UAAU;IACV,WAAW;IACX,0BAA0B;IAC1B,wBAAwB;IACxB,WAAW;IACX,eAAe;IACf,0BAA0B;IAC1B,4BAA4B;CACtB,CAAC;AAIX,SAAgB,2BAA2B,CAAC,MAK3C;IACW,IAAA,kBAAkB,GAA4C,MAAM,mBAAlD,EAAE,aAAa,GAA6B,MAAM,cAAnC,EAAE,WAAW,GAAgB,MAAM,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
- "version": "4.2.14-beta.1",
3
+ "version": "4.2.14",
4
4
  "description": "Keycloak theme generator for Reacts app",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,4 +1,5 @@
1
1
  <script>const _=
2
+ <#assign pageId="PAGE_ID_xIgLsPgGId9D8e">
2
3
  (()=>{
3
4
 
4
5
  const out =
@@ -76,9 +77,11 @@ ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc};
76
77
  }
77
78
  };
78
79
 
80
+ out["pageId"] = "${pageId}";
81
+
79
82
  return out;
80
83
 
81
- })();
84
+ })()
82
85
  <#function ftl_object_to_js_code_declaring_an_object object path>
83
86
 
84
87
  <#local isHash = "">
@@ -112,13 +115,35 @@ ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc};
112
115
  </#if>
113
116
 
114
117
  <#if
115
- ["loginUpdatePasswordUrl", "loginUpdateProfileUrl", "loginUsernameReminderUrl", "loginUpdateTotpUrl"]?seq_contains(key) &&
116
- path?map(x -> x?is_number?string("_index_",x))?join("°") == ["url"]?join("°")
118
+ (
119
+ ["loginUpdatePasswordUrl", "loginUpdateProfileUrl", "loginUsernameReminderUrl", "loginUpdateTotpUrl"]?seq_contains(key) &&
120
+ are_same_path(path, ["url"])
121
+ ) || (
122
+ key == "updateProfileCtx" &&
123
+ are_same_path(path, [])
124
+ ) || (
125
+ <#-- https://github.com/InseeFrLab/keycloakify/pull/65#issuecomment-991896344 -->
126
+ key == "loginAction" &&
127
+ are_same_path(path, ["url"]) &&
128
+ pageId == "saml-post-form.ftl"
129
+ )
117
130
  >
118
- <#local out_seq += ["/*If you need" + key + " please submit an issue to the Keycloakify repo*/"]>
131
+ <#local out_seq += ["/*If you need '" + key + "' on " + pageId + ", please submit an issue to the Keycloakify repo*/"]>
119
132
  <#continue>
120
133
  </#if>
121
134
 
135
+ <#if key == "attemptedUsername" && are_same_path(path, ["auth"])>
136
+
137
+ <#attempt>
138
+ <#-- https://github.com/keycloak/keycloak/blob/3a2bf0c04bcde185e497aaa32d0bb7ab7520cf4a/themes/src/main/resources/theme/base/login/template.ftl#L63 -->
139
+ <#if !(auth?has_content && auth.showUsername() && !auth.showResetCredentials())>
140
+ <#continue>
141
+ </#if>
142
+ <#recover>
143
+ </#attempt>
144
+
145
+ </#if>
146
+
122
147
  <#attempt>
123
148
  <#if !object[key]??>
124
149
  <#continue>
@@ -226,5 +251,40 @@ ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc};
226
251
 
227
252
  <#return "ABORT: Couldn't convert into string non hash, non method, non boolean, non enumerable object">
228
253
 
254
+ </#function>
255
+ <#function are_same_path path searchedPath>
256
+
257
+ <#if path?size != path?size>
258
+ <#return false>
259
+ </#if>
260
+
261
+ <#local i=0>
262
+
263
+ <#list path as property>
264
+
265
+ <#local searchedProperty=searchedPath[i]>
266
+
267
+ <#if searchedProperty?is_string && searchedProperty == "*">
268
+ <#continue>
269
+ </#if>
270
+
271
+ <#if searchedProperty?is_string && !property?is_string>
272
+ <#return false>
273
+ </#if>
274
+
275
+ <#if searchedProperty?is_number && !property?is_number>
276
+ <#return false>
277
+ </#if>
278
+
279
+ <#if searchedProperty?string != property?string>
280
+ <#return false>
281
+ </#if>
282
+
283
+ <#local i+= 1>
284
+
285
+ </#list>
286
+
287
+ <#return true>
288
+
229
289
  </#function>
230
290
  </script>
@@ -87,8 +87,6 @@ export function generateFtlFilesCodeFactory(params: {
87
87
  ].join("\n"),
88
88
  };
89
89
 
90
- const pageIdSearchValue = "PAGE_ID_xIgLsPgGId9D8e";
91
-
92
90
  $("head").prepend(
93
91
  [
94
92
  ...(Object.keys(cssGlobalsToDefine).length === 0
@@ -105,7 +103,6 @@ export function generateFtlFilesCodeFactory(params: {
105
103
  ]),
106
104
  "<script>",
107
105
  ` window.${ftlValuesGlobalName}= ${objectKeys(replaceValueBySearchValue)[0]};`,
108
- ` window.${ftlValuesGlobalName}["pageId"]= "${pageIdSearchValue}";`,
109
106
  "</script>",
110
107
  "",
111
108
  objectKeys(replaceValueBySearchValue)[1],
@@ -125,7 +122,8 @@ export function generateFtlFilesCodeFactory(params: {
125
122
 
126
123
  Object.entries({
127
124
  ...replaceValueBySearchValue,
128
- [pageIdSearchValue]: pageId,
125
+ //If updated, don't forget to change in the ftl script as well.
126
+ "PAGE_ID_xIgLsPgGId9D8e": pageId,
129
127
  }).map(([searchValue, replaceValue]) => (ftlCode = ftlCode.replace(searchValue, replaceValue)));
130
128
 
131
129
  return { ftlCode };