Skip to content

Commit 3111beb

Browse files
authored
Update README.md
Signed-off-by: Joachim Fosse <56757601+joaf123@users.noreply.github.com>
1 parent 3493917 commit 3111beb

File tree

1 file changed

+48
-65
lines changed

1 file changed

+48
-65
lines changed

README.md

Lines changed: 48 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,45 @@
11
# Verify FormsAuthentication cookie on request through custom attribute
22

3-
> httpModule for FormsAuthentication verification on requests using custom attributes.
3+
ASP.NET HttpModule for verification of FormsAuthentication on requests, using custom attributes.
4+
5+
## Setup:
6+
7+
### Web.config
8+
```xml
9+
<?xml version="1.0" encoding="utf-8"?>
10+
<configuration>
11+
<system.webServer>
12+
<!--RequireAuthentication Module-->
13+
<modules>
14+
<add name="AttributeBasedFormsAuthenticationModule" type="AttributeBasedFormsAuthenticationModule" preCondition="integratedMode" />
15+
</modules>
16+
</system.webServer>
17+
</configuration>
418

19+
```
20+
21+
### Global.asax:
22+
```asp
23+
<%@ Application Language="VB" %>
24+
25+
<script RunAt="server">
26+
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
27+
Me.UseAuthorization()
28+
End Sub
29+
</script>
30+
```
31+
32+
### DO NOT FORGET BEFORE USING:
33+
34+
* Make sure your FormsAuthentication cookie is set correctly
35+
* Verify/change the assembly metadata for System.Web.Extensions which is used to get the Type definition for RestHandlerWithSession:
36+
```csharp
37+
Type _RestHandlerWithSessionType = Type.GetType("System.Web.Script.Services.RestHandlerWithSession, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
538

39+
// the "Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" part must match YOUR spesific scenario
40+
```
641

7-
## Currently supported use cases - C#:
42+
## Supported Use Cases:
843

944
### Decorated on spesific PageMethod's or Ajax WebMethod's:
1045

@@ -13,77 +48,25 @@
1348
[WebMethod]
1449
public string AjaxMethod() {
1550
```
16-
17-
18-
### Decorated on Page Class:
19-
```csharp
20-
[RequiresAuthentication]
21-
public partial class WebFormsPage : System.Web.UI.Page
22-
```
23-
### Decorated on MasterPage Class:
24-
```csharp
25-
[RequiresAuthentication]
26-
public partial class WebFormsMasterPage : System.Web.UI.MasterPage
27-
```
28-
### Decorated on WebService Class:
51+
or
52+
### Decorated on the main WebService Class:
2953
```csharp
3054
[RequiresAuthentication]
3155
[System.Web.Script.Services.ScriptService()]
3256
[WebService(Namespace = "http://localhost:8080/")]
3357
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
3458
[global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()]
3559
public class AspAjaxWebService : System.Web.Services.WebService
36-
{
37-
}
3860
```
3961

40-
---
41-
42-
## Currently supported use cases - VB.NET:
43-
44-
### Decorated on spesific PageMethod's or Ajax WebMethod's:
45-
```vb
46-
<RequiresAuthentication>
47-
<WebMethod>
48-
public function AjaxMethod() as string
49-
```
50-
51-
### Decorated on Page Class:
52-
```vb
53-
<RequiresAuthentication>
54-
Partial Class WebFormsPage
55-
Inherits System.Web.UI.Page
56-
```
57-
58-
### Decorated on MasterPage Class:
59-
```vb
60-
<RequiresAuthentication>
61-
Partial Class WebFormsMasterPage
62-
Inherits System.Web.UI.MasterPage
63-
```
64-
65-
### Decorated on WebService Class:
66-
```vb
67-
<RequiresAuthentication>
68-
<System.Web.Script.Services.ScriptService()>
69-
<WebService([Namespace]:="http://localhost:8080/")>
70-
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
71-
<[global].Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
72-
Public Class AspAjaxWebService
73-
Inherits System.Web.Services.WebService
74-
End Class
62+
### Decorated on a Page Class:
63+
```csharp
64+
[RequiresAuthentication]
65+
public partial class WebFormsPage : System.Web.UI.Page
7566
```
76-
77-
<br/>
78-
79-
---
80-
81-
## DO NOT FORGET BEFORE USING:
82-
83-
* Make sure your FormsAuthentication cookie is set correctly
84-
* Verify/change the assembly metadata for System.Web.Extensions which is used to get the Type definition for RestHandlerWithSession:
85-
```csharp
86-
Type _RestHandlerWithSessionType = Type.GetType("System.Web.Script.Services.RestHandlerWithSession, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
87-
88-
// the "Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" part must match YOUR spesific scenario
67+
or
68+
### Decorated on a MasterPage Class:
69+
```csharp
70+
[RequiresAuthentication]
71+
public partial class WebFormsMasterPage : System.Web.UI.MasterPage
8972
```

0 commit comments

Comments
 (0)