@@ -528,4 +528,28 @@ function logAction(req, url, activity) {
528
528
} ) ;
529
529
}
530
530
531
+ /**
532
+ * This method will trigger a REST HTTP call to the AppID server logoutSSO endpoint.
533
+ * Bare in mind that SSO feature must be activated in the server side.
534
+ * Calling the server SSO APIs will do nothing if you forgot to enable SSO in the server (tenant) configuration.
535
+ * Once you enabled SSO login in the server side you can try the logout in the client side:
536
+ * If you use the sample application , add a logout SSO UI widget , add to the app.js an express routing such as
537
+ * app.get("/logoutSSO", function(req, res, next) {
538
+ * res.clearCookie("refreshToken");
539
+ * webAppStrategy.logoutSSO(req,res, { redirect_uri: "http://localhost:3000/niceGoodbyePage" , all_sessions: false });
540
+ * });
541
+ * @param req - the HTTP request
542
+ * @param res - the HTTP response object (will be used to redirect)
543
+ * @param options - need to contain at least the redirect_uri. all_sessions can logout all the users sessions at once.
544
+ */
545
+ WebAppStrategy . prototype . logoutSSO = function ( req , res , options = { } ) {
546
+ options . client_id = this . serviceConfig . getClientId ( ) ;
547
+ let queryParams = Object . keys ( options ) . map ( e => encodeURIComponent ( e ) + '=' + encodeURIComponent ( options [ e ] ) ) . join ( '&' ) ;
548
+ let oauthServerUrl = this . serviceConfig . getOAuthServerUrl ( ) ;
549
+ let url = `${ oauthServerUrl } /cloud_directory/sso/logout?${ queryParams } ` ;
550
+ logger . debug ( 'cleaning client session and calling server url:' + url ) ;
551
+ WebAppStrategy . logout ( req ) ; // without logging to activity tracker since the server will be reporting it .
552
+ res . redirect ( url ) ;
553
+ } ;
554
+
531
555
module . exports = WebAppStrategy ;
0 commit comments