Hexagon Geospatial
MENU

Support WebGIS

Need a push in the right direction when configuring WebMap, Portal or SDI services? Looking for hints and tips, or just looking for Ideas and information? The WebGIS discussion board is where you start those discussions, connect and share information.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Frequent Contributor
Posts: 130
Registered: ‎08-10-2016
Accepted Solution

Geospatial Portal Forms Authentication timeout

Hi Everyone,

 

Am having a bit of a challenge with Forms Authentication in the Geospatial Portal. I need the portal to automatically redirect to the login page when the session times out. i.e when the portal remains idle for about 20 minutes.

 

The current  situation is that when there is a timeout the geospatial portal map window remains open but the maps do not reload when zooming in or out. I have to manually reload the whole portal so as to access the login page.

 

It would be nice to have it reload automatically and let the user user know their session/connection timed out. Is this possible without any custon code/scripts. But even if custom code is necessary, which file would i be looking at? Will i need to use the SDK for this?

 

 

Regards,

Elvon

Technical Evangelist
Posts: 790
Registered: ‎09-11-2015

Re: Geospatial Portal Forms Authentication timeout

Hi Elvon,

 

From the ASP.NET POV the session is invalid already but from the client side, it is driven mostly by JavaScript. I'm not sure if this could be altered by modifying the ASPX page header, likely not. But I can think of another solution. Use JavaScript/jQuery to watch the user activity, like this (source):

(function () {
   var idleTime = 0;
   $(document).ready(function () {
      //Increment the idle time counter every minute.
      var idleInterval = setInterval(timerIncrement, 60000); // 1 minute

      //Zero the idle timer on mouse movement.
      $(this).mousemove(function (e) {
         idleTime = 0;
      });
      $(this).keypress(function (e) {
         idleTime = 0;
      });
   });

   function timerIncrement() {
      idleTime++;
      if (idleTime > 19) { // 20 minutes
         window.location.replace("loginform.aspx");
      }
   }
})();

Create a JS file, e.g. Redirection.js, with that script inside <Portal_Instance>\js folder and reference it in all ASPX pages that you expect to be used with your portal (e.g. Full.aspx, ApolloPro.aspx, ...):

<asp:ScriptManager runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true">
   <Scripts>
      <asp:ScriptReference Path="js/MapConfig.js" />
      <asp:ScriptReference Path="js/LayoutHelper.js" />
      <asp:ScriptReference Path="js/API.min.js" />
      <asp:ScriptReference Path="js/StyleConfig.js" />
      <asp:ScriptReference Path="js/Redirection.js" />
   </Scripts>
</asp:ScriptManager>

Regards,

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Frequent Contributor
Posts: 130
Registered: ‎08-10-2016

Re: Geospatial Portal Forms Authentication timeout

Hi Jan,

 

Thanks, it worked. I also had to add reference for jquery as shown.

<asp:ScriptManager runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true">
        <Scripts>
            <asp:ScriptReference Path="js/MapConfig.js" />
            <asp:ScriptReference Path="js/LayoutHelper.js" />
            <asp:ScriptReference Path="js/API.min.js" />
            <asp:ScriptReference Path="js/StyleConfig.js" />
            <asp:ScriptReference Path="js/Scrollbar.js" /> 
	    <asp:ScriptReference Path="js/jquery.js" />
	<%--<asp:ScriptReference Path="js/CustomFeatureInfo.js" />--%>
	    <asp:ScriptReference Path="js/Redirection.js" />
        </Scripts>
    </asp:ScriptManager>

 

Regards,

Elvon

Technical Evangelist
Posts: 790
Registered: ‎09-11-2015

Re: Geospatial Portal Forms Authentication timeout

Ah, yeah, thanks for the correction. I also found pure JS version (on StackOverflow community) which doesn't need jQuery but for some reasons it didn't work well when I quickly tested it. So I settled with the jQuery.

 

Regards,

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Frequent Contributor
Posts: 159
Registered: ‎10-26-2015

Re: Geospatial Portal Forms Authentication timeout

I needed similar functionality for a customer project and can confirm this solution still works with Geospatail Portal 2016 EP04 however redirecting to loginform.aspx doesn't clear login credentials so it doesn't stop someone changing the URL back to the portal site and they are able to access the portal without entering credentials again.

 

Our customer is looking for a more secure session timeout where users will have to re-enter credentials once the timeout has occurred. Is this technically possible with Geospatial Portal?

Technical Evangelist
Posts: 790
Registered: ‎09-11-2015

Re: Geospatial Portal Forms Authentication timeout

Hi Colin,

 

You must align Forms and Session timeouts in order to remove the proper cookie.

 

For instance (timeout to 1 minute):

<system.web>
...
   <sessionState timeout="1" />
</system.web>
...
<authentication mode="Forms">
   <forms timeout="1" loginUrl="~/LoginForm.aspx" ... />
</authentication>

 

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Frequent Contributor
Posts: 159
Registered: ‎10-26-2015

Re: Geospatial Portal Forms Authentication timeout

Jan,

Thanks for the information about aligning all timeouts. With Forms, Sessions and Redirection.js all set to the same time limit the session is correctly timed out and I can't access the site again unless I provide credentials.

 

All I need now is a manual session log out function to allow a user to completely logout of the session manually. I've posted that over here http://community.hexagongeospatial.com/t5/Developer-Discussions/Geospatial-Portal-Log-Out-Function/t...

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.