Skip to content

Commit

Permalink
revamp the sample with docs
Browse files Browse the repository at this point in the history
  • Loading branch information
woloski committed Jul 8, 2012
1 parent c625f0b commit 984eb69
Show file tree
Hide file tree
Showing 15 changed files with 18,306 additions and 79 deletions.
31 changes: 31 additions & 0 deletions src/SampleRP/AllowTokenPostRequestValidator.cs
@@ -0,0 +1,31 @@
using System;
using System.Web;
using System.Web.Util;
using Microsoft.IdentityModel.Protocols.WSFederation;

namespace SampleRP
{
public class AllowTokenPostRequestValidator : RequestValidator
{
protected override bool IsValidRequestString(HttpContext context, string value,
RequestValidationSource requestValidationSource,
string collectionKey, out int validationFailureIndex)
{
validationFailureIndex = 0;

if (requestValidationSource == RequestValidationSource.Form &&
collectionKey.Equals(WSFederationConstants.Parameters.Result, StringComparison.Ordinal))
{
SignInResponseMessage message =
WSFederationMessage.CreateFromFormPost(context.Request) as SignInResponseMessage;

if (message != null)
{
return true;
}
}
return base.IsValidRequestString(context, value, requestValidationSource, collectionKey,
out validationFailureIndex);
}
}
}
5 changes: 3 additions & 2 deletions src/SampleRP/Content/Site.css
Expand Up @@ -84,7 +84,7 @@ first child of the left and right table columns */
page width. Or, you can specify an exact pixel width. */
.page
{
width: 90%;
width: 960px;
margin-left: auto;
margin-right: auto;
}
Expand All @@ -101,7 +101,7 @@ page width. Or, you can specify an exact pixel width. */
{
font-weight: bold;
padding: 5px 0;
margin: 0;
margin-bottom: 20px;
color: #fff;
border: none;
line-height: 2em;
Expand All @@ -115,6 +115,7 @@ page width. Or, you can specify an exact pixel width. */
background-color: #fff;
margin-bottom: 30px;
_height: 1px; /* only IE6 applies CSS properties starting with an underscrore */
clear: both;
}

#footer
Expand Down
88 changes: 88 additions & 0 deletions src/SampleRP/Content/markdownize.css
@@ -0,0 +1,88 @@
/**
* GitHub theme customized
*
* @author Craig Campbell
* @version 1.0.2
*/
pre {
border: 1px solid #ccc;
padding: 6px 10px;
line-height: 19px;
margin-bottom: 20px;
}

code {
border: 1px solid #eaeaea;
margin: 0px 2px;
padding: 0px 5px;
font-size: 12px;
}

pre code {
border: 0px;
padding: 0px;
margin: 0px;
-moz-border-radius: 0px;
-webkit-border-radius: 0px;
border-radius: 0px;
}

pre, code {
font-family: 'Bitstream Vera Sans Mono', Consolas, Courier, monospace;
color: #333;
background: #f8f8f8;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
overflow-x: auto
}

pre, pre code {
font-size: 13px;
}

pre .comment {
color: #998;
}

pre .support {
color: #0086B3;
}

pre .tag, pre .tag-name {
color: navy;
}

pre .keyword, pre .css-property, pre .vendor-prefix, pre .sass, pre .class, pre .id, pre .css-value, pre .entity.function, pre .storage.function {
font-weight: bold;
}

pre .css-property, pre .css-value, pre .vendor-prefix, pre .support.namespace {
color: #333;
}

pre .constant.numeric, pre .keyword.unit, pre .hex-color {
font-weight: normal;
color: #099;
}

pre .entity.class {
color: #458;
}

pre .entity.id, pre .entity.function {
color: #900;
}

pre .attribute, pre .variable {
color: teal;
}

pre .string, pre .support.value {
font-weight: normal;
color: #d14;
}

pre .regexp {
color: #009926;
}
19 changes: 3 additions & 16 deletions src/SampleRP/Controllers/HomeController.cs
Expand Up @@ -9,32 +9,19 @@
[HandleError]
public class HomeController : Controller
{
[ValidateInput(false)]
public ActionResult UnSecure()
{
return View();
}

[ValidateInput(false)]
[AuthenticateAndAuthorize(Realm = "http://sample-with-policyengine/")]
public ActionResult SecureWithPolicyEngine()
[AuthenticateAndAuthorize()]
public ActionResult MyClaims()
{
ViewData["Claims"] = ((IClaimsIdentity)User.Identity).Claims;

return View("Secure");
}

[ValidateInput(false)]
[AuthenticateAndAuthorize(Realm = "http://sample-without-policyengine/")]
public ActionResult SecureWithoutPolicyEngine()
{
ViewData["Claims"] = ((IClaimsIdentity)User.Identity).Claims;

return View("Secure");
}


[ValidateInput(false)]

public ActionResult LogOut()
{
var authModule = FederatedAuthentication.WSFederationAuthenticationModule;
Expand Down
13 changes: 8 additions & 5 deletions src/SampleRP/Global.asax.cs
Expand Up @@ -31,12 +31,15 @@ protected void Application_Start()
void WSFederationAuthenticationModule_SignedIn(object sender, System.EventArgs e)
{
WSFederationMessage wsFederationMessage = WSFederationMessage.CreateFromFormPost(HttpContext.Current.Request);
var wctx = HttpUtility.ParseQueryString(wsFederationMessage.Context);
string returnUrl = wctx["ru"];
if (wsFederationMessage.Context != null)
{
var wctx = HttpUtility.ParseQueryString(wsFederationMessage.Context);
string returnUrl = wctx["ru"];

// TODO: check for absolute url and throw to avoid open redirects
HttpContext.Current.Response.Redirect(returnUrl, false);
HttpContext.Current.ApplicationInstance.CompleteRequest();
// TODO: check for absolute url and throw to avoid open redirects
HttpContext.Current.Response.Redirect(returnUrl, false);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
}
}
}
8 changes: 7 additions & 1 deletion src/SampleRP/SampleRP.csproj
Expand Up @@ -44,7 +44,7 @@
<ItemGroup>
<Reference Include="Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.IdentityModel.3.5.0\lib\Microsoft.IdentityModel.dll</HintPath>
<HintPath>..\packages\Auth10.AspNet.0.9.2\lib\net35\Microsoft.IdentityModel.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
Expand All @@ -68,6 +68,7 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="AllowTokenPostRequestValidator.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Default.aspx.cs">
<DependentUpon>Default.aspx</DependentUpon>
Expand All @@ -81,8 +82,13 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Content\markdownize.css" />
<Content Include="Scripts\markdownize.js" />
<Content Include="Default.aspx" />
<Content Include="Global.asax" />
<Content Include="Scripts\jquery-1.7.2-vsdoc.js" />
<Content Include="Scripts\jquery-1.7.2.js" />
<Content Include="Scripts\jquery-1.7.2.min.js" />
<Content Include="Views\Home\Secure.aspx" />
<Content Include="Web.config">
<SubType>Designer</SubType>
Expand Down

0 comments on commit 984eb69

Please sign in to comment.