Skip to content
This repository has been archived by the owner on Mar 20, 2019. It is now read-only.

Commit

Permalink
Added an ASP.NET MVC template to the .vsi
Browse files Browse the repository at this point in the history
Merge branch 'mvcProjTemplate'
  • Loading branch information
AArnott committed Jan 9, 2010
2 parents ca06ff6 + e602330 commit 23aa694
Show file tree
Hide file tree
Showing 58 changed files with 26,380 additions and 71 deletions.
12 changes: 12 additions & 0 deletions projecttemplates/DotNetOpenAuth Starter Kits.vscontent
Expand Up @@ -11,4 +11,16 @@
<Attribute name="TemplateType" value="Project"/>
</Attributes>
</Content>
<Content>
<FileName>MvcRelyingParty.zip</FileName>
<DisplayName>ASP.NET MVC OpenID-InfoCard RP</DisplayName>
<Description>An ASP.NET MVC web site that accepts OpenID and InfoCard logins</Description>
<FileContentType>VSTemplate</FileContentType>
<ContentVersion>2.0</ContentVersion>
<Attributes>
<Attribute name="ProjectType" value="Visual C#"/>
<Attribute name="ProjectSubType" value="Web"/>
<Attribute name="TemplateType" value="Project"/>
</Attributes>
</Content>
</VSContent>
23 changes: 23 additions & 0 deletions projecttemplates/MvcRelyingParty.vstemplate
@@ -0,0 +1,23 @@
<VSTemplate Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="ProjectGroup">
<TemplateData>
<Name>ASP.NET MVC OpenID-InfoCard RP</Name>
<RequiredFrameworkVersion>3.5</RequiredFrameworkVersion>
<Description>An ASP.NET MVC web site that accepts OpenID and InfoCard logins</Description>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>Web</ProjectSubType>
<NumberOfParentCategoriesToRollUp>2</NumberOfParentCategoriesToRollUp>
<SortOrder>1000</SortOrder>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>WebRPApplication</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
<LocationField>Enabled</LocationField>
<EnableLocationBrowseButton>true</EnableLocationBrowseButton>
<Icon>__TemplateIcon.ico</Icon>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink ProjectName="$projectname$">MvcRelyingParty\MvcRelyingParty.vstemplate</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="RelyingPartyLogic">RelyingPartyLogic\RelyingPartyLogic.vstemplate</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>
</VSTemplate>
17 changes: 17 additions & 0 deletions projecttemplates/MvcRelyingParty/Code/Extensions.cs
@@ -0,0 +1,17 @@
namespace MvcRelyingParty {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

internal static class Extensions {
internal static Uri ActionFull(this UrlHelper urlHelper, string actionName) {
return new Uri(HttpContext.Current.Request.Url, urlHelper.Action(actionName));
}

internal static Uri ActionFull(this UrlHelper urlHelper, string actionName, string controllerName) {
return new Uri(HttpContext.Current.Request.Url, urlHelper.Action(actionName, controllerName));
}
}
}
@@ -0,0 +1,36 @@
namespace MvcRelyingParty {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using DotNetOpenAuth.OpenId;

/// <summary>
/// Forms authentication interface to facilitate login/logout functionality.
/// </summary>
/// <remarks>
/// The FormsAuthentication type is sealed and contains static members, so it is difficult to
/// unit test code that calls its members. The interface and helper class below demonstrate
/// how to create an abstract wrapper around such a type in order to make the AccountController
/// code unit testable.
/// </remarks>
public interface IFormsAuthentication {
void SignIn(Identifier claimedIdentifier, bool createPersistentCookie);

void SignOut();
}

/// <summary>
/// The standard FormsAuthentication behavior to use for the live site.
/// </summary>
public class FormsAuthenticationService : IFormsAuthentication {
public void SignIn(Identifier claimedIdentifier, bool createPersistentCookie) {
FormsAuthentication.SetAuthCookie(claimedIdentifier, createPersistentCookie);
}

public void SignOut() {
FormsAuthentication.SignOut();
}
}
}
46 changes: 46 additions & 0 deletions projecttemplates/MvcRelyingParty/Code/OpenIdRelyingPartyService.cs
@@ -0,0 +1,46 @@
namespace MvcRelyingParty {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.RelyingParty;

public interface IOpenIdRelyingParty {
IAuthenticationRequest CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnTo);

IAuthenticationResponse GetResponse();
}

/// <summary>
/// A wrapper around the standard <see cref="OpenIdRelyingParty"/> class.
/// </summary>
public class OpenIdRelyingPartyService : IOpenIdRelyingParty {
/// <summary>
/// The OpenID relying party to use for logging users in.
/// </summary>
/// <remarks>
/// This is static because it is thread-safe and is more expensive
/// to create than we want to run through for every single page request.
/// </remarks>
private static OpenIdRelyingParty relyingParty = new OpenIdRelyingParty();

/// <summary>
/// Initializes a new instance of the <see cref="OpenIdRelyingPartyService"/> class.
/// </summary>
public OpenIdRelyingPartyService() {
}

#region IOpenIdRelyingParty Members

public IAuthenticationRequest CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnTo) {
return relyingParty.CreateRequest(userSuppliedIdentifier, realm, returnTo);
}

public IAuthenticationResponse GetResponse() {
return relyingParty.GetResponse();
}

#endregion
}
}

0 comments on commit 23aa694

Please sign in to comment.