如何在episerver mvc网站上创建授权系统?

时间:2014-03-05 09:49:51

标签: asp.net-mvc security authorization episerver

Episerver CMS(MVC站点)中的标准提供程序无法从管理面板创建用户。如何修复它并将授权和身份验证添加到Episerver CMS上的MVC站点。我可以在Episerver CMS中使用标准MVC授权系统(来自MVC模板)吗?

1 个答案:

答案 0 :(得分:3)

只有配置的成员资格提供者允许,并且DefaultMembershipProvider(旧版本SqlMembershipProvider)支持,EPiServer才能从Admin创建用户。

EPiServer还使用MultiplexingMembershipProvider,它允许组合多个提供者。更多信息:http://world.episerver.com/Blogs/Anders-Hattestad/Dates/2010/12/Multiplexing-providers/

因此,要配置DefaultMembershipProvider,您必须安装Nuget包:Microsoft ASP.NET Universal Providers 1.2.0这不是最新的NuGet包。最新的软件包依赖于Entity Framework 6,因为我知道它不能与EPiServer一起使用。所以安装1.2.0版

然后在Web.config中添加成员资格提供者,角色提供者和个人资料提供者:

    <profile defaultProvider="DefaultProfileProvider" automaticSaveEnabled="true" enabled="true">
      <properties>
        <add name="Address" type="System.String" />
        <add name="ZipCode" type="System.String" />
        <add name="Locality" type="System.String" />
        <add name="Email" type="System.String" />
        <add name="FirstName" type="System.String" />
        <add name="LastName" type="System.String" />
        <add name="Language" type="System.String" />
        <add name="Country" type="System.String" />
        <add name="Company" type="System.String" />
        <add name="Title" type="System.String" />
        <add name="SubscriptionInfo" type="EPiServer.Personalization.SubscriptionInfo, EPiServer" />
        <add name="CustomExplorerTreePanel" type="System.String" />
        <add name="FileManagerFavourites" type="System.Collections.Generic.List`1[System.String]" />
        <add name="EditTreeSettings" type="EPiServer.Personalization.GuiSettings, EPiServer" />
        <add name="ClientToolsActivationKey" type="System.String" />
        <add name="FrameworkName" type="System.String" />
      </properties>
      <providers>
        <clear />
        <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="EPiServerDB" applicationName="SampleWeb" />
      </providers>
    </profile>
    <roleManager enabled="true" defaultProvider="MultiplexingRoleProvider" cacheRolesInCookie="true">
      <providers>
        <clear />
        <add name="MultiplexingRoleProvider" type="EPiServer.Security.MultiplexingRoleProvider, EPiServer.Framework, Version=7.5.394.2, Culture=neutral, PublicKeyToken=8fe83dea738b45b7" provider1="DefaultRoleProvider" provider2="WindowsRoleProvider" providerMap1="DefaultMembershipProvider" providerMap2="WindowsMembershipProvider" />
        <add name="WindowsRoleProvider" applicationName="EPiServerSample" type="EPiServer.Security.WindowsRoleProvider, EPiServer" />
        <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="EPiServerDB" applicationName="SampleWeb" />
      </providers>
    </roleManager>
    <membership defaultProvider="MultiplexingMembershipProvider">
      <providers>
        <clear />
        <add name="MultiplexingMembershipProvider" type="EPiServer.Security.MultiplexingMembershipProvider, EPiServer.Framework, Version=7.5.394.2, Culture=neutral, PublicKeyToken=8fe83dea738b45b7" provider1="DefaultMembershipProvider" provider2="WindowsMembershipProvider" />
        <add name="WindowsMembershipProvider" type="EPiServer.Security.WindowsMembershipProvider, EPiServer" deletePrefix="BUILTIN\" searchByEmail="true" />
        <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="EPiServerDB" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="SampleWeb" />
      </providers>
    </membership>

我在这里也使用了WindowsMembershp提供,所以我可以使用我的Windows凭据登录,但请注意它在MultiplexingMembershipProvider中注册为第二个:provider2 =&#34; WindowsMembershipProvider&#34;。

配置完成后,您可以使用普通ASP.NET membership API进行授权和身份验证。