Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Commit

Permalink
Renamed Timeout to SlidingTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodejunkie committed Nov 27, 2012
1 parent 023e2b7 commit 7fb1456
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
14 changes: 10 additions & 4 deletions src/Nancy/Diagnostics/DiagnosticsConfiguration.cs
Expand Up @@ -29,7 +29,7 @@ public DiagnosticsConfiguration(CryptographyConfiguration cryptographyConfigurat
this.CookieName = "__ncd";
this.CryptographyConfiguration = cryptographyConfiguration;
this.Path = "/_Nancy";
this.Timeout = 15;
this.SlidingTimeout = 15;
}

/// <summary>
Expand All @@ -56,17 +56,23 @@ public DiagnosticsConfiguration(CryptographyConfiguration cryptographyConfigurat
public string Path { get; set; }

/// <summary>
/// The number of minutes that you stay logged into the diagnostics dashboard.
/// The number of minutes that expiry of the diagnostics dashboard will be extended each time it is used.
/// </summary>
/// <remarks>The default is 15 minutes.</remarks>
public int Timeout { get; set; }
public int SlidingTimeout { get; set; }

/// <summary>
/// Gets a value indicating whether the configuration is valid
/// </summary>
public bool Valid
{
get { return !string.IsNullOrWhiteSpace(this.Password); }
get
{
return !string.IsNullOrWhiteSpace(this.Password) &&
!string.IsNullOrWhiteSpace(this.CookieName) &&
!string.IsNullOrWhiteSpace(this.Path) &&
this.SlidingTimeout != 0;
}
}
}
}
8 changes: 4 additions & 4 deletions src/Nancy/Diagnostics/DiagnosticsHook.cs
Expand Up @@ -151,7 +151,7 @@ private static void AddUpdateSessionCookie(DiagnosticsSession session, NancyCont
return;
}

session.Expiry = DateTime.Now.AddMinutes(diagnosticsConfiguration.Timeout);
session.Expiry = DateTime.Now.AddMinutes(diagnosticsConfiguration.SlidingTimeout);
var serializedSession = serializer.Serialize(session);

var encryptedSession = diagnosticsConfiguration.CryptographyConfiguration.EncryptionProvider.Encrypt(serializedSession);
Expand Down Expand Up @@ -227,16 +227,16 @@ private static DiagnosticsSession ProcessLogin(NancyContext context, Diagnostics
{
Hash = hash,
Salt = salt,
Expiry = DateTime.Now.AddMinutes(diagnosticsConfiguration.Timeout)
Expiry = DateTime.Now.AddMinutes(diagnosticsConfiguration.SlidingTimeout)
};

return session;
}

private static bool IsLoginRequest(NancyContext context, DiagnosticsConfiguration diagnosticsConfiguration)
{
return context.Request.Method == "POST" &&
context.Request.Path == diagnosticsConfiguration.Path;
return context.Request.Method == "POST" &&
context.Request.Path.TrimEnd(new[] { '/' }) == diagnosticsConfiguration.Path;
}

private static void ExecuteRoutePreReq(NancyContext context, Func<NancyContext, Response> resolveResultPreReq)
Expand Down

0 comments on commit 7fb1456

Please sign in to comment.