Skip to content

Commit

Permalink
Merge pull request #822 from opencb/TASK-5096
Browse files Browse the repository at this point in the history
TASK-5096 - IVA issue when logout from CAS
  • Loading branch information
jmjuanes authored Oct 19, 2023
2 parents b2a4ab3 + fad455b commit 3ff7a71
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
7 changes: 5 additions & 2 deletions src/core/clients/opencga/opencga-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export class OpenCGAClient {
prefix: ""
// expirationTime: ""
},
sso: false,
sso: {
active: false,
cookie: "JSESSIONID",
},
};
}

Expand All @@ -80,7 +83,7 @@ export class OpenCGAClient {
console.error(e);
// Josemi NOTE 20230324 Terrible hack to prevent displaying OpenCGA host not available error
// when iva starts, as the /meta/about is restricted when SSO is enabled
if (!this._config.sso) {
if (!this._config?.sso?.active) {
globalEvent("signingInError", {value: "Opencga host not available."});
globalEvent("hostInit", {host: "opencga", value: "NOT AVAILABLE"});
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/clients/opencga/opencga-parent-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class OpenCGAParentClass {
}

// Enable credentials
_options.includeCredentials = !!this._config.sso;
_options.includeCredentials = !!this._config?.sso?.active;

// console.log(`OpenCGA client calling to ${url}`);
// if the URL query fails we try with next host
Expand Down Expand Up @@ -83,7 +83,7 @@ export default class OpenCGAParentClass {
}

// Enable credentials
_options.includeCredentials = !!this._config.sso;
_options.includeCredentials = !!this._config?.sso?.active;

return this.restClient.call(url, _options, k);
}
Expand All @@ -106,7 +106,7 @@ export default class OpenCGAParentClass {
// _options.body = _params.body;

// Enable credentials
_options.includeCredentials = !!this._config.sso;
_options.includeCredentials = !!this._config?.sso?.active;

return this.restClient.call(url, _options, k);
}
Expand Down
9 changes: 6 additions & 3 deletions src/sites/iva/iva-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,10 @@ class IvaApp extends LitElement {
active: true,
prefix: opencgaPrefix,
},
sso: opencgaSsoActive,
sso: {
active: opencgaSsoActive,
cookie: opencgaSsoCookie,
},
});

this.reactomeClient = new ReactomeClient();
Expand Down Expand Up @@ -638,9 +641,9 @@ class IvaApp extends LitElement {
await this.opencgaClient.logout();

// Check if sso is active: we will redirect to 'meta/sso/logout' endpoint
if (this.opencgaClient?._config?.sso) {
if (this.opencgaClient?._config?.sso?.active) {
// eslint-disable-next-line no-undef
Cookies.expire("JSESSIONID");
Cookies.expire(this.opencgaClient._config.sso.cookie);

const config = this.opencgaClient._config;
const ivaUrl = window.location;
Expand Down
28 changes: 15 additions & 13 deletions src/webcomponents/commons/layouts/custom-landing.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,20 +242,22 @@ export default class CustomLanding extends LitElement {
` : null}
<!-- Landing login -->
<div class="landing-login">
${this.opencgaSession?.opencgaClient?._config?.sso ? html`
${this.opencgaSession?.opencgaClient?._config?.sso?.active ? html`
<div>
<a class="btn-group" role="group" href="${this.getSSOUrl()}">
<button type="button" class="btn btn-primary btn-lg" style="">
<i class="fas fa-user"></i>
</button>
<button type="button" class="btn btn-primary btn-lg">
<strong style="color:white;">Login with SSO</strong>
</button>
</a>
</div>
<div class="landing-login-sso-helper">
By clicking on the <b>Login with SSO</b> button you will be redirected to your SSO login
page.
<div align="center">
<a class="btn-group" role="group" href="${this.getSSOUrl()}">
<button type="button" class="btn btn-primary btn-lg" style="">
<i class="fas fa-user"></i>
</button>
<button type="button" class="btn btn-primary btn-lg">
<strong style="color:white;">Login with SSO</strong>
</button>
</a>
</div>
<div class="landing-login-sso-helper">
By clicking on the <b>Login with SSO</b> button you will be redirected to your SSO login
page.
</div>
</div>
` : html`
<user-login
Expand Down

0 comments on commit 3ff7a71

Please sign in to comment.