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
256 return false;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 private void Application_PostMapRequestHandler(object sender, EventArgs e)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 return;273 return;
263 274
264 if (m_application.Context.Handler is IReadOnlySessionState ||275 if (m_application.Context.Handler is IReadOnlySessionState ||
265 m_application.Context.Handler is IRequiresSessionState)276 m_application.Context.Handler is IRequiresSessionState)
266 // no need to replace the current handler 277 // No need to replace the current handler
267 return;278 return;
268 279
269 // swap the current handler 280 // Swap the current handler
270 m_application.Context.Handler = new SessionEnabledHandler(m_application.Context.Handler);281 m_application.Context.Handler = new SessionEnabledHandler(m_application.Context.Handler);
271 }282 }
272 283
273 private void Application_PostAcquireRequestState(object sender, EventArgs e)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 return;288 return;
277 289
278 SessionEnabledHandler handler = HttpContext.Current.Handler as SessionEnabledHandler;290 SessionEnabledHandler handler = HttpContext.Current.Handler as SessionEnabledHandler;
279 if (handler != null)291 if (handler != null)
280 // set the original handler back 292 // Set the original handler back
281 HttpContext.Current.Handler = handler.OriginalHandler;293 HttpContext.Current.Handler = handler.OriginalHandler;
282 }294 }
283 295
284 private void Application_PreRequestHandlerExecute(object sender, EventArgs e)296 private void Application_PreRequestHandlerExecute(object sender, EventArgs e)
285 {297 {
298 // Check if access to resource is to be secured.
286 string resource = GetResourceName();299 string resource = GetResourceName();
287 if (!SecurityProviderUtility.IsResourceSecurable(resource))300 if (!IsAccessSecured(resource))
288 return;301 return;
289 302
290 if (SecurityProviderCache.CurrentProvider == null)303 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