Showing the changes to Source/Libraries/GSF.Web/SecurityModule.cs (1 of 3 files). Show all
Unified · Split
| @@ -256,35 +256,48 @@ namespace GSF.Web · 255 unmodified lines | ||
| 256 | 256 | return false; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | + /// <summary> | |
| 260 | + /// Determines if access to the requested <paramref name="resource"/> is to be secured. | |
| 261 | + /// </summary> | |
| 262 | + /// <param name="resource">Name of the resource being requested.</param> | |
| 263 | + /// <returns>True if access to the resource is to be secured, otherwise False.</returns> | |
| 264 | + protected virtual bool IsAccessSecured(string resource) | |
| 265 | + { | |
| 266 | + return SecurityProviderUtility.IsResourceSecurable(GetResourceName()); | |
| 267 | + } | |
| 268 | + | |
| 259 | 269 | private void Application_PostMapRequestHandler(object sender, EventArgs e) |
| 260 | 270 | { |
| 261 | − if (!SecurityProviderUtility.IsResourceSecurable(GetResourceName())) | |
| 271 | + // Check if access to resource is to be secured. | |
| 272 | + if (!IsAccessSecured(GetResourceName())) | |
| 262 | 273 | return; |
| 263 | 274 | |
| 264 | 275 | if (m_application.Context.Handler is IReadOnlySessionState || |
| 265 | 276 | m_application.Context.Handler is IRequiresSessionState) |
| 266 | − // no need to replace the current handler | |
| 277 | + // No need to replace the current handler | |
| 267 | 278 | return; |
| 268 | 279 | |
| 269 | − // swap the current handler | |
| 280 | + // Swap the current handler | |
| 270 | 281 | m_application.Context.Handler = new SessionEnabledHandler(m_application.Context.Handler); |
| 271 | 282 | } |
| 272 | 283 | |
| 273 | 284 | private void Application_PostAcquireRequestState(object sender, EventArgs e) |
| 274 | 285 | { |
| 275 | − if (!SecurityProviderUtility.IsResourceSecurable(GetResourceName())) | |
| 286 | + // Check if access to resource is to be secured. | |
| 287 | + if (!IsAccessSecured(GetResourceName())) | |
| 276 | 288 | return; |
| 277 | 289 | |
| 278 | 290 | SessionEnabledHandler handler = HttpContext.Current.Handler as SessionEnabledHandler; |
| 279 | 291 | if (handler != null) |
| 280 | − // set the original handler back | |
| 292 | + // Set the original handler back | |
| 281 | 293 | HttpContext.Current.Handler = handler.OriginalHandler; |
| 282 | 294 | } |
| 283 | 295 | |
| 284 | 296 | private void Application_PreRequestHandlerExecute(object sender, EventArgs e) |
| 285 | 297 | { |
| 298 | + // Check if access to resource is to be secured. | |
| 286 | 299 | string resource = GetResourceName(); |
| 287 | − if (!SecurityProviderUtility.IsResourceSecurable(resource)) | |
| 300 | + if (!IsAccessSecured(resource)) | |
| 288 | 301 | return; |
| 289 | 302 | |
| 290 | 303 | if (SecurityProviderCache.CurrentProvider == null) |