Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nigel Brown 16 posts 36 karma points
    Feb 24, 2018 @ 21:54
    Nigel Brown
    0

    Setting up UmbracoCms.IdentityExtensions - but receiving errors

    Hi,

    I am trying to set up a custom Umbraco Back Office Login for Umbraco 7.8.1. I have read a lot of articles on line about UmbracoCms.IdentityExtensions, that can be extended to use Google/Facebook login etc.

    I have performed the following steps.

    1. I have setup a clean / empty web project on Visual Studio Community 2017
    2. Installed Umbraco CMS
    3. PM> install-package UmbracoCMS
    4. Ran the project and installed Umbraco. (it works ok)
    5. PM>Install-Package UmbracoCms.IdentityExtensions This added an number of files to the App_Start folder. eg UmbracoStandardOwinStartup.cs and amended the web.config.

    this is the code for 'UmbracoStandardOwinStartup.cs'

    using Microsoft.Owin;
    using Owin;
    using Umbraco.Core;
    using Umbraco.Core.Security;
    using Umbraco.Web;
    using Umbraco.Web.Security.Identity;
    using Umbraco.IdentityExtensions;
    using DemoProject;
    
    
    //To use this startup class, change the appSetting value in the web.config called 
    // "owin:appStartup" to be "UmbracoStandardOwinStartup"
    
    [assembly: OwinStartup("UmbracoStandardOwinStartup", typeof(UmbracoStandardOwinStartup))]
    
    namespace DemoProject
    {
        /// <summary>
        /// The standard way to configure OWIN for Umbraco
        /// </summary>
        /// <remarks>
        /// The startup type is specified in appSettings under owin:appStartup - change it to "StandardUmbracoStartup" to use this class
        /// </remarks>
        public class UmbracoStandardOwinStartup : UmbracoDefaultOwinStartup
        {
            public override void Configuration(IAppBuilder app)
            {
                //ensure the default options are configured
                base.Configuration(app);
    
                /* 
                 * Configure external logins for the back office:
                 * 
                 * Depending on the authentication sources you would like to enable, you will need to install 
                 * certain Nuget packages. 
                 * 
                 * For Google auth:                 Install-Package UmbracoCms.IdentityExtensions.Google
                 * For Facebook auth:                   Install-Package UmbracoCms.IdentityExtensions.Facebook
                 * For Microsoft auth:                  Install-Package UmbracoCms.IdentityExtensions.Microsoft
                 * For Azure ActiveDirectory auth:      Install-Package UmbracoCms.IdentityExtensions.AzureActiveDirectory
                 * 
                 * There are many more providers such as Twitter, Yahoo, ActiveDirectory, etc... most information can
                 * be found here: http://www.asp.net/web-api/overview/security/external-authentication-services
                 * 
                 * For sample code on using external providers with the Umbraco back office, install one of the 
                 * packages listed above to review it's code samples 
                 *  
                 */
    
                /*
                 * To configure a simple auth token server for the back office:
                 *             
                 * By default the CORS policy is to allow all requests
                 * 
                 *      app.UseUmbracoBackOfficeTokenAuth(new BackOfficeAuthServerProviderOptions());
                 *      
                 * If you want to have a custom CORS policy for the token server you can provide
                 * a custom CORS policy, example: 
                 * 
                 *      app.UseUmbracoBackOfficeTokenAuth(
                 *          new BackOfficeAuthServerProviderOptions()
                 *              {
                 *                  //Modify the CorsPolicy as required
                 *                  CorsPolicy = new CorsPolicy()
                 *                  {
                 *                      AllowAnyHeader = true,
                 *                      AllowAnyMethod = true,
                 *                      Origins = { "http://mywebsite.com" }                
                 *                  }
                 *              });
                 */
    
            }
        }
    }
    

    Within the web.config I have added the line in side the appSettings.

    <add key="owin:appStartup" value="UmbracoStandardOwinStartup" />
    

    these lines have been added into the web.config as well.

     <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
    

    When I now run the project I get the following error.

    The following errors occurred while attempting to load the app. - The OwinStartupAttribute.FriendlyName value 'UmbracoDefaultOwinStartup' does not match the given value 'UmbracoStandardOwinStartup' in Assembly 'umbraco, Version=1.0.6614.16987, Culture=neutral, PublicKeyToken=null'. - The given type or method 'UmbracoStandardOwinStartup' was not found. Try specifying the Assembly. To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config. To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.

    I have tried different permutations in the web.config file. such as

    <add key="owin:appStartup" value="demoProject.UmbracoStandardOwinStartup" />
    

    or

    <add key="owin:appStartup" value="demoProject.demoProject.UmbracoStandardOwinStartup" />
    

    or tried this amendment in 'UmbracoStandardOwinStartup.cs' [assembly: OwinStartup("UmbracoStandardOwinStartup", typeof(demoProject.UmbracoStandardOwinStartup))]

    But still the error prevails. If I make the web.config entry

    <add key="owin:appStartup" value="UmbracoDefaultOwinStartup" />
    

    Then the umbraco project loads, but I assume this is the actual (umbraco) default and the startup code does not get fired, in the App_Startup

    I have searched online for help, but am unable to find a solution.

    Any thoughts.

    thanks

Please Sign in or register to post replies

Write your reply to:

Draft