History

TVA.Web - Added new IgnoreServicesSecurityModule security module that can be used for securing ASP.NET application that also hosts WCF services that are secured using WCF authorization policy.

pinalcpatel committed 12 years ago

Commit e69cefd1 parent ec380663 files · +68 −6Browse files

Showing the changes to Source/Libraries/GSF.Web/SecurityModule.cs (1 of 3 files). Show all

Unified · Split

Source/Libraries/GSF.Web/SecurityModule.cs+19−6
@@ -256,35 +256,48 @@ namespace GSF.Web · 255 unmodified lines
256256 return false;
257257 }
258258
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+
259269 private void Application_PostMapRequestHandler(object sender, EventArgs e)
260270 {
261− if (!SecurityProviderUtility.IsResourceSecurable(GetResourceName()))
271+ // Check if access to resource is to be secured.
272+ if (!IsAccessSecured(GetResourceName()))
262273 return;
263274
264275 if (m_application.Context.Handler is IReadOnlySessionState ||
265276 m_application.Context.Handler is IRequiresSessionState)
266− // no need to replace the current handler
277+ // No need to replace the current handler
267278 return;
268279
269− // swap the current handler
280+ // Swap the current handler
270281 m_application.Context.Handler = new SessionEnabledHandler(m_application.Context.Handler);
271282 }
272283
273284 private void Application_PostAcquireRequestState(object sender, EventArgs e)
274285 {
275− if (!SecurityProviderUtility.IsResourceSecurable(GetResourceName()))
286+ // Check if access to resource is to be secured.
287+ if (!IsAccessSecured(GetResourceName()))
276288 return;
277289
278290 SessionEnabledHandler handler = HttpContext.Current.Handler as SessionEnabledHandler;
279291 if (handler != null)
280− // set the original handler back
292+ // Set the original handler back
281293 HttpContext.Current.Handler = handler.OriginalHandler;
282294 }
283295
284296 private void Application_PreRequestHandlerExecute(object sender, EventArgs e)
285297 {
298+ // Check if access to resource is to be secured.
286299 string resource = GetResourceName();
287− if (!SecurityProviderUtility.IsResourceSecurable(resource))
300+ if (!IsAccessSecured(resource))
288301 return;
289302
290303 if (SecurityProviderCache.CurrentProvider == null)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t