dash-button-web 0.0.1 → 0.0.2

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.
@@ -6,7 +6,7 @@ const index = require('./index-8282b36b.js');
6
6
 
7
7
  const defineCustomElements = (win, options) => {
8
8
  if (typeof window === 'undefined') return undefined;
9
- return index.bootstrapLazy([["dash-button.cjs",[[1,"dash-button",{"showPostLoginText":[4,"show-post-login-text"],"silentCheckSso":[4,"silent-check-sso"],"redirectUri":[1,"redirect-uri"],"keycloakUri":[1,"keycloak-uri"],"realm":[1],"clientId":[1,"client-id"],"keycloak":[32],"isAuth":[32],"givenName":[32],"silentCheckSsoRedirectUri":[32]}]]]], options);
9
+ return index.bootstrapLazy([["dash-button.cjs",[[1,"dash-button",{"showPostLoginText":[4,"show-post-login-text"],"silentCheckSso":[4,"silent-check-sso"],"redirectUri":[1,"redirect-uri"],"authMethod":[1,"auth-method"],"keycloakUri":[1,"keycloak-uri"],"realm":[1],"clientId":[1,"client-id"],"keycloak":[32],"isAuth":[32],"givenName":[32],"silentCheckSsoRedirectUri":[32]}]]]], options);
10
10
  };
11
11
 
12
12
  exports.setNonce = index.setNonce;
@@ -17,7 +17,7 @@ const patchBrowser = () => {
17
17
  };
18
18
 
19
19
  patchBrowser().then(options => {
20
- return index.bootstrapLazy([["dash-button.cjs",[[1,"dash-button",{"showPostLoginText":[4,"show-post-login-text"],"silentCheckSso":[4,"silent-check-sso"],"redirectUri":[1,"redirect-uri"],"keycloakUri":[1,"keycloak-uri"],"realm":[1],"clientId":[1,"client-id"],"keycloak":[32],"isAuth":[32],"givenName":[32],"silentCheckSsoRedirectUri":[32]}]]]], options);
20
+ return index.bootstrapLazy([["dash-button.cjs",[[1,"dash-button",{"showPostLoginText":[4,"show-post-login-text"],"silentCheckSso":[4,"silent-check-sso"],"redirectUri":[1,"redirect-uri"],"authMethod":[1,"auth-method"],"keycloakUri":[1,"keycloak-uri"],"realm":[1],"clientId":[1,"client-id"],"keycloak":[32],"isAuth":[32],"givenName":[32],"silentCheckSsoRedirectUri":[32]}]]]], options);
21
21
  });
22
22
 
23
23
  exports.setNonce = index.setNonce;
@@ -5,6 +5,7 @@ export class DashButtonComponent {
5
5
  this.showPostLoginText = false;
6
6
  this.silentCheckSso = false;
7
7
  this.redirectUri = undefined;
8
+ this.authMethod = "check-sso";
8
9
  this.keycloakUri = "http://localhost:8080";
9
10
  this.realm = "";
10
11
  this.clientId = "";
@@ -20,13 +21,14 @@ export class DashButtonComponent {
20
21
  ;
21
22
  connectedCallback() {
22
23
  this.keycloak.init({
23
- onLoad: 'check-sso',
24
+ onLoad: this.authMethod,
24
25
  checkLoginIframe: false,
25
26
  silentCheckSsoRedirectUri: this.silentCheckSso ? this.silentCheckSsoRedirectUri : '',
26
27
  }).then(res => {
27
28
  if (res) {
28
29
  this.isAuth = true;
29
30
  localStorage.setItem("keycloak", JSON.stringify(this.keycloak));
31
+ document.cookie = "ZDZW_cookie=" + JSON.parse(localStorage.getItem('keycloak')).token;
30
32
  this.givenName = JSON.parse(localStorage.getItem('keycloak')).idTokenParsed.given_name;
31
33
  }
32
34
  });
@@ -36,6 +38,7 @@ export class DashButtonComponent {
36
38
  }
37
39
  logout() {
38
40
  localStorage.removeItem("keycloak");
41
+ document.cookie = "ZDZW_cookie=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
39
42
  this.keycloak.logout();
40
43
  }
41
44
  showModal() {
@@ -47,7 +50,7 @@ export class DashButtonComponent {
47
50
  appModal.style.display = "none";
48
51
  }
49
52
  render() {
50
- return h("div", { key: '29a7944051bce29ea8ff3f1db8f2b44b5a157e84' }, h("div", { key: 'a44011e412f06a00bca1a6de134391cc1eb248c2' }, (() => {
53
+ return h("div", { key: '46065686f61e27894acf13494d479f8e14ae440a' }, h("div", { key: 'fb795b6cab0e9a57ee9ddfc6a6ab69796de02d94' }, (() => {
51
54
  if (this.isAuth && this.showPostLoginText) {
52
55
  return (h("a", { href: this.redirectUri, id: "login-btn", class: "button button-link" }, h("span", { class: "button-text button-text-full-width" }, "Go to Dashboard")));
53
56
  }
@@ -57,7 +60,7 @@ export class DashButtonComponent {
57
60
  else {
58
61
  return (h("button", { onClick: this.login.bind(this), id: "login-btn", type: "button", class: "button" }, h("span", { class: "button-text" }, "Login")));
59
62
  }
60
- })()), h("div", { key: '475cbe51090c78848032e9044c9f11e460969121', id: "appListModal", class: "modal" }, h("div", { key: 'e0a2a1ffa3de0d45001f40fb46d258ade64dc933', class: "modal-content" }, h("span", { key: '5fa70d2fcac6816d9a9ee41c329bd9c787014cbb', onClick: this.closeModal.bind(this), class: "close" }, "\u00D7"), h("h3", { key: 'de74b78ba75d815758e0d7c68474d7cdb7673ae7' }, "Applications"), h("div", { key: '1ed88b256cb82aef902f08179e24cbd0be810bd9', class: "modal-app" }, "App 1"), h("div", { key: 'e3e32a260fa06452fb38e64e4593cae1d8530c7b', class: "modal-app" }, "App 2"))));
63
+ })()), h("div", { key: 'f64fc2082e07f576df4cff7d71453c8f18a4347e', id: "appListModal", class: "modal" }, h("div", { key: '9753fff951bd9719bb39db00cf99861dc1caeb2e', class: "modal-content" }, h("span", { key: 'f1a1ba93614473a498cf7f43d1ed1d2814a77df3', onClick: this.closeModal.bind(this), class: "close" }, "\u00D7"), h("h3", { key: '14a85f33052086fb9597a507789d145bec9cd076' }, "Applications"), h("div", { key: 'd323ba9ca8504ac36668c78c6c23c53dd695a6ac', class: "modal-app" }, "App 1"), h("div", { key: 'c1391a3b447aec37d81a723821ea28922a2cbaa4', class: "modal-app" }, "App 2"))));
61
64
  }
62
65
  static get is() { return "dash-button"; }
63
66
  static get encapsulation() { return "shadow"; }
@@ -126,6 +129,24 @@ export class DashButtonComponent {
126
129
  "attribute": "redirect-uri",
127
130
  "reflect": false
128
131
  },
132
+ "authMethod": {
133
+ "type": "string",
134
+ "mutable": false,
135
+ "complexType": {
136
+ "original": "string",
137
+ "resolved": "string",
138
+ "references": {}
139
+ },
140
+ "required": false,
141
+ "optional": false,
142
+ "docs": {
143
+ "tags": [],
144
+ "text": ""
145
+ },
146
+ "attribute": "auth-method",
147
+ "reflect": false,
148
+ "defaultValue": "\"check-sso\""
149
+ },
129
150
  "keycloakUri": {
130
151
  "type": "string",
131
152
  "mutable": false,
@@ -1 +1 @@
1
- {"version":3,"file":"dash-button.js","sourceRoot":"","sources":["../../../src/components/my-component/dash-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,QAAQ,MAAM,aAAa,CAAC;AAQnC,MAAM,OAAO,mBAAmB;;iCAIO,KAAK;8BACR,KAAK;;2BAGT,uBAAuB;qBAC7B,EAAE;wBACC,EAAE;wBAEJ,IAAI,QAAQ,CAAC;YACpC,GAAG,EAAE,IAAI,CAAC,WAAW;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;sBAEgB,KAAK;yBACM,EAAE;yCACe,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,4BAA4B;;IAJhG,CAAC;IAMJ,iBAAiB;QACb,IAAI,CAAC,QAAQ,CAAC,IAAI,CAChB;YACI,MAAM,EAAE,WAAW;YACnB,gBAAgB,EAAE,KAAK;YACvB,yBAAyB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE;SACvF,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACZ,IAAG,GAAG,EAAE,CAAC;gBACP,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;gBAClB,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAEhE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC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\n\n@Component({\n tag: 'dash-button',\n styleUrl: 'dash-button.css',\n shadow: true,\n})\nexport class DashButtonComponent {\n\n @Element() el;\n \n @Prop() showPostLoginText: boolean = false;\n @Prop() silentCheckSso: boolean = false;\n @Prop() redirectUri: string;\n\n @Prop() keycloakUri: string = \"http://localhost:8080\";\n @Prop() realm: string = \"\";\n @Prop() clientId: string = \"\";\n\n @State() keycloak: any = new Keycloak({\n url: this.keycloakUri,\n realm: this.realm,\n clientId: this.clientId,\n });;\n\n @State() isAuth = false;\n @State() givenName: string = \"\";\n @State() silentCheckSsoRedirectUri: string = window.location.origin + '/assets/verificar-sso.html';\n\n connectedCallback() {\n this.keycloak.init(\n {\n onLoad: 'check-sso',\n checkLoginIframe: false,\n silentCheckSsoRedirectUri: this.silentCheckSso ? this.silentCheckSsoRedirectUri : '',\n }).then(res => {\n if(res) {\n this.isAuth = true\n localStorage.setItem(\"keycloak\", JSON.stringify(this.keycloak));\n\n this.givenName = JSON.parse(localStorage.getItem('keycloak')).idTokenParsed.given_name\n } \n \n });\n\n }\n\n login() { \n this.keycloak.login() \n }\n\n logout() {\n localStorage.removeItem(\"keycloak\");\n this.keycloak.logout() \n } \n\n showModal() {\n const appModal = this.el.shadowRoot.querySelector('#appListModal');\n appModal.style.display = \"block\";\n }\n\n closeModal() {\n const appModal = this.el.shadowRoot.querySelector('#appListModal');\n appModal.style.display = \"none\";\n }\n\n render() {\n return <div>\n <div>\n {\n (() => {\n if(this.isAuth && this.showPostLoginText) {\n return (\n <a href={this.redirectUri} id=\"login-btn\" class=\"button button-link\">\n <span class=\"button-text button-text-full-width\">Go to Dashboard</span>\n </a>\n )\n } else if (this.isAuth) {\n return (\n <div id=\"profile-btn\" class=\"dropdown\">\n <button type=\"button\" class=\"button\">\n <span class=\"button-profile\">\n <img src=\"https://i.pravatar.cc/100?img=32\" alt=\"\"/>\n </span>\n <span id=\"given-name\" class=\"button-text\">{this.givenName}</span>\n <div class=\"button-icon\">\n <span class=\"gg-menu-grid-r\"></span>\n </div>\n </button>\n <div class=\"dropdown-content\">\n <a onClick={this.showModal.bind(this)} id=\"applications-btn\">Applications</a>\n <a onClick={this.logout.bind(this)} id=\"logout-btn\">Logout</a>\n </div>\n </div>\n )\n } else {\n return (\n <button onClick={this.login.bind(this)} id=\"login-btn\" type=\"button\" class=\"button\">\n <span class=\"button-text\">Login</span>\n </button>\n )\n }\n })() \n } \n </div>\n \n <div id=\"appListModal\" class=\"modal\">\n \n <div class=\"modal-content\">\n <span onClick={this.closeModal.bind(this)} class=\"close\">&times;</span>\n <h3>Applications</h3>\n <div class=\"modal-app\">App 1</div>\n <div class=\"modal-app\">App 2</div>\n </div>\n \n </div>\n </div>;\n }\n}\n"]}
1
+ {"version":3,"file":"dash-button.js","sourceRoot":"","sources":["../../../src/components/my-component/dash-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,QAAQ,MAAM,aAAa,CAAC;AAQnC,MAAM,OAAO,mBAAmB;;iCAIO,KAAK;8BACR,KAAK;;0BAEV,WAAW;2BAEV,uBAAuB;qBAC7B,EAAE;wBACC,EAAE;wBAEJ,IAAI,QAAQ,CAAC;YACpC,GAAG,EAAE,IAAI,CAAC,WAAW;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;sBAEgB,KAAK;yBACM,EAAE;yCACe,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,4BAA4B;;IAJhG,CAAC;IAMJ,iBAAiB;QACb,IAAI,CAAC,QAAQ,CAAC,IAAI,CAChB;YACI,MAAM,EAAE,IAAI,CAAC,UAAU;YACvB,gBAAgB,EAAE,KAAK;YACvB,yBAAyB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE;SACv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AAC,eAAe;oBACxB,6DAAM,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAC,OAAO,aAAe;oBACvE,4EAAqB;oBACrB,4DAAK,KAAK,EAAC,WAAW,YAAY;oBAClC,4DAAK,KAAK,EAAC,WAAW,YAAY,CAC9B,CAEF,CACF,CAAC;IACP,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, State, h, Element } from '@stencil/core';\nimport Keycloak from \"keycloak-js\";\n\n\n@Component({\n tag: 'dash-button',\n styleUrl: 'dash-button.css',\n shadow: true,\n})\nexport class DashButtonComponent {\n\n @Element() el;\n \n @Prop() showPostLoginText: boolean = false;\n @Prop() silentCheckSso: boolean = false;\n @Prop() redirectUri: string;\n @Prop() authMethod: string = \"check-sso\";\n\n @Prop() keycloakUri: string = \"http://localhost:8080\";\n @Prop() realm: string = \"\";\n @Prop() clientId: string = \"\";\n\n @State() keycloak: any = new Keycloak({\n url: this.keycloakUri,\n realm: this.realm,\n clientId: this.clientId,\n });;\n\n @State() isAuth = false;\n @State() givenName: string = \"\";\n @State() silentCheckSsoRedirectUri: string = window.location.origin + '/assets/verificar-sso.html';\n\n connectedCallback() {\n this.keycloak.init(\n {\n onLoad: this.authMethod,\n checkLoginIframe: false,\n silentCheckSsoRedirectUri: this.silentCheckSso ? this.silentCheckSsoRedirectUri : '',\n }).then(res => {\n if(res) {\n this.isAuth = true\n localStorage.setItem(\"keycloak\", JSON.stringify(this.keycloak));\n document.cookie = \"ZDZW_cookie=\" + JSON.parse(localStorage.getItem('keycloak')).token;\n\n this.givenName = JSON.parse(localStorage.getItem('keycloak')).idTokenParsed.given_name\n } \n \n });\n\n }\n\n login() { \n this.keycloak.login() \n }\n\n logout() {\n localStorage.removeItem(\"keycloak\");\n document.cookie = \"ZDZW_cookie=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;\";\n this.keycloak.logout() \n } \n\n showModal() {\n const appModal = this.el.shadowRoot.querySelector('#appListModal');\n appModal.style.display = \"block\";\n }\n\n closeModal() {\n const appModal = this.el.shadowRoot.querySelector('#appListModal');\n appModal.style.display = \"none\";\n }\n\n render() {\n return <div>\n <div>\n {\n (() => {\n if(this.isAuth && this.showPostLoginText) {\n return (\n <a href={this.redirectUri} id=\"login-btn\" class=\"button button-link\">\n <span class=\"button-text button-text-full-width\">Go to Dashboard</span>\n </a>\n )\n } else if (this.isAuth) {\n return (\n <div id=\"profile-btn\" class=\"dropdown\">\n <button type=\"button\" class=\"button\">\n <span class=\"button-profile\">\n <img src=\"https://i.pravatar.cc/100?img=32\" alt=\"\"/>\n </span>\n <span id=\"given-name\" class=\"button-text\">{this.givenName}</span>\n <div class=\"button-icon\">\n <span class=\"gg-menu-grid-r\"></span>\n </div>\n </button>\n <div class=\"dropdown-content\">\n <a onClick={this.showModal.bind(this)} id=\"applications-btn\">Applications</a>\n <a onClick={this.logout.bind(this)} id=\"logout-btn\">Logout</a>\n </div>\n </div>\n )\n } else {\n return (\n <button onClick={this.login.bind(this)} id=\"login-btn\" type=\"button\" class=\"button\">\n <span class=\"button-text\">Login</span>\n </button>\n )\n }\n })() \n } \n </div>\n \n <div id=\"appListModal\" class=\"modal\">\n \n <div class=\"modal-content\">\n <span onClick={this.closeModal.bind(this)} class=\"close\">&times;</span>\n <h3>Applications</h3>\n <div class=\"modal-app\">App 1</div>\n <div class=\"modal-app\">App 2</div>\n </div>\n \n </div>\n </div>;\n }\n}\n"]}
@@ -2484,6 +2484,7 @@ const DashButtonComponent = /*@__PURE__*/ proxyCustomElement(class DashButtonCom
2484
2484
  this.showPostLoginText = false;
2485
2485
  this.silentCheckSso = false;
2486
2486
  this.redirectUri = undefined;
2487
+ this.authMethod = "check-sso";
2487
2488
  this.keycloakUri = "http://localhost:8080";
2488
2489
  this.realm = "";
2489
2490
  this.clientId = "";
@@ -2499,13 +2500,14 @@ const DashButtonComponent = /*@__PURE__*/ proxyCustomElement(class DashButtonCom
2499
2500
  ;
2500
2501
  connectedCallback() {
2501
2502
  this.keycloak.init({
2502
- onLoad: 'check-sso',
2503
+ onLoad: this.authMethod,
2503
2504
  checkLoginIframe: false,
2504
2505
  silentCheckSsoRedirectUri: this.silentCheckSso ? this.silentCheckSsoRedirectUri : '',
2505
2506
  }).then(res => {
2506
2507
  if (res) {
2507
2508
  this.isAuth = true;
2508
2509
  localStorage.setItem("keycloak", JSON.stringify(this.keycloak));
2510
+ document.cookie = "ZDZW_cookie=" + JSON.parse(localStorage.getItem('keycloak')).token;
2509
2511
  this.givenName = JSON.parse(localStorage.getItem('keycloak')).idTokenParsed.given_name;
2510
2512
  }
2511
2513
  });
@@ -2515,6 +2517,7 @@ const DashButtonComponent = /*@__PURE__*/ proxyCustomElement(class DashButtonCom
2515
2517
  }
2516
2518
  logout() {
2517
2519
  localStorage.removeItem("keycloak");
2520
+ document.cookie = "ZDZW_cookie=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
2518
2521
  this.keycloak.logout();
2519
2522
  }
2520
2523
  showModal() {
@@ -2526,7 +2529,7 @@ const DashButtonComponent = /*@__PURE__*/ proxyCustomElement(class DashButtonCom
2526
2529
  appModal.style.display = "none";
2527
2530
  }
2528
2531
  render() {
2529
- return h("div", { key: '29a7944051bce29ea8ff3f1db8f2b44b5a157e84' }, h("div", { key: 'a44011e412f06a00bca1a6de134391cc1eb248c2' }, (() => {
2532
+ return h("div", { key: '46065686f61e27894acf13494d479f8e14ae440a' }, h("div", { key: 'fb795b6cab0e9a57ee9ddfc6a6ab69796de02d94' }, (() => {
2530
2533
  if (this.isAuth && this.showPostLoginText) {
2531
2534
  return (h("a", { href: this.redirectUri, id: "login-btn", class: "button button-link" }, h("span", { class: "button-text button-text-full-width" }, "Go to Dashboard")));
2532
2535
  }
@@ -2536,7 +2539,7 @@ const DashButtonComponent = /*@__PURE__*/ proxyCustomElement(class DashButtonCom
2536
2539
  else {
2537
2540
  return (h("button", { onClick: this.login.bind(this), id: "login-btn", type: "button", class: "button" }, h("span", { class: "button-text" }, "Login")));
2538
2541
  }
2539
- })()), h("div", { key: '475cbe51090c78848032e9044c9f11e460969121', id: "appListModal", class: "modal" }, h("div", { key: 'e0a2a1ffa3de0d45001f40fb46d258ade64dc933', class: "modal-content" }, h("span", { key: '5fa70d2fcac6816d9a9ee41c329bd9c787014cbb', onClick: this.closeModal.bind(this), class: "close" }, "\u00D7"), h("h3", { key: 'de74b78ba75d815758e0d7c68474d7cdb7673ae7' }, "Applications"), h("div", { key: '1ed88b256cb82aef902f08179e24cbd0be810bd9', class: "modal-app" }, "App 1"), h("div", { key: 'e3e32a260fa06452fb38e64e4593cae1d8530c7b', class: "modal-app" }, "App 2"))));
2542
+ })()), h("div", { key: 'f64fc2082e07f576df4cff7d71453c8f18a4347e', id: "appListModal", class: "modal" }, h("div", { key: '9753fff951bd9719bb39db00cf99861dc1caeb2e', class: "modal-content" }, h("span", { key: 'f1a1ba93614473a498cf7f43d1ed1d2814a77df3', onClick: this.closeModal.bind(this), class: "close" }, "\u00D7"), h("h3", { key: '14a85f33052086fb9597a507789d145bec9cd076' }, "Applications"), h("div", { key: 'd323ba9ca8504ac36668c78c6c23c53dd695a6ac', class: "modal-app" }, "App 1"), h("div", { key: 'c1391a3b447aec37d81a723821ea28922a2cbaa4', class: "modal-app" }, "App 2"))));
2540
2543
  }
2541
2544
  get el() { return this; }
2542
2545
  static get style() { return DashButtonStyle0; }
@@ -2544,6 +2547,7 @@ const DashButtonComponent = /*@__PURE__*/ proxyCustomElement(class DashButtonCom
2544
2547
  "showPostLoginText": [4, "show-post-login-text"],
2545
2548
  "silentCheckSso": [4, "silent-check-sso"],
2546
2549
  "redirectUri": [1, "redirect-uri"],
2550
+ "authMethod": [1, "auth-method"],
2547
2551
  "keycloakUri": [1, "keycloak-uri"],
2548
2552
  "realm": [1],
2549
2553
  "clientId": [1, "client-id"],