Skip to content

Commit f0df409

Browse files
authored
Update module with comments
1 parent d9496fe commit f0df409

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

AuthorizationHttpModule.cs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
1-
using System;
1+
using System;
22
using System.Reflection;
33
using System.Web;
44
using System.Web.Compilation;
55
using System.Web.Security;
66
using System.Web.UI;
7-
7+
/// <summary>
8+
/// Verify authorization on call to WebMethods or Pages with the attribute: &lt;RequiresAuthentication&gt; (VB) | [RequiresAuthentication] (C#).
9+
/// </summary>
810
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
911
public class RequiresAuthenticationAttribute : Attribute { }
1012

13+
/// <summary>
14+
/// Attribute based forms authentication verification module.
15+
/// </summary>
1116
public class AttributeBasedFormsAuthenticationModule : IHttpModule {
17+
/// <summary>
18+
/// Inits the AttributeBasedFormsAuthentication Module.
19+
/// </summary>
20+
/// <param name="application">HttpApplication Parameter</param>
1221
public void Init(HttpApplication application) {
1322
application.PostMapRequestHandler += OnPostAuthorizeRequest;
1423
}
1524

25+
/// <summary>
26+
/// Disposes the AttributeBasedFormsAuthentication Module
27+
/// </summary>
1628
public void Dispose() {
1729
// Clean up resources, if any
1830
}
1931

32+
/// <summary>
33+
/// Authorize request.
34+
/// </summary>
35+
/// <param name="sender">Sender Parameter</param>
36+
/// <param name="e">EventArgs Parameter</param>
2037
private void OnPostAuthorizeRequest(object sender, EventArgs e) {
2138
var app = (HttpApplication)sender;
2239
var context = app.Context;
@@ -43,15 +60,24 @@ private void OnPostAuthorizeRequest(object sender, EventArgs e) {
4360
}
4461
}
4562

63+
/// <summary>
64+
/// Deny access.
65+
/// </summary>
66+
/// <param name="context">The context.</param>
4667
private static void DenyAccess(HttpContext context) {
4768
context.Response.StatusCode = 401;
4869
context.Response.SuppressContent = true;
4970
context.Response.End();
5071
}
5172

73+
/// <summary>
74+
/// Gets the web method name from request.
75+
/// </summary>
76+
/// <param name="request">The request.</param>
77+
/// <returns>WebMethod name as string.</returns>
5278
private static string GetWebMethodNameFromRequest(HttpRequest request) {
5379
var pathInfo = request.PathInfo.TrimStart('/');
5480
var slashIndex = pathInfo.IndexOf('/');
5581
return slashIndex >= 0 ? pathInfo.Substring(0, slashIndex) : pathInfo;
5682
}
57-
}
83+
}

0 commit comments

Comments
 (0)