Neil Billingham
Neil Billingham

Reputation: 2295

IdentityServer 3 will not startup

I'm having problems firing up IdentityServer 3. It's a very simple setup which I intend to use for a development environment and I'm having problems diagnosing the issue. Here's my code:

Startup.cs

    using Owin;
    using System;
    using System.Security.Cryptography.X509Certificates;
    using IdentityServer3.Core.Models;
    using IdentityServer3.Core.Configuration;

    namespace IdentityServer3
    {
        public class Startup
        {
            public void Configuration(IAppBuilder app)
            {
                app.Map("/identity", idsrvApp =>
                {
                    idsrvApp.UseIdentityServer(new IdentityServerOptions
                    {
                        SiteName = "Embedded IdentityServer",
                        SigningCertificate = LoadCertificate(),

                        Factory = new IdentityServerServiceFactory()
                                    .UseInMemoryUsers(Users.Get())
                                    .UseInMemoryClients(Clients.Get())
                                    .UseInMemoryScopes(StandardScopes.All)
                    });
                });
            }

            X509Certificate2 LoadCertificate()
            {
                return new X509Certificate2(
                    string.Format(@"{0}bin\idsrv3test.pfx", AppDomain.CurrentDomain.BaseDirectory), "idsrv3test");
            }
        }
}

Users.cs

using IdentityServer3.Core;
using IdentityServer3.Core.Services.InMemory;
using System.Collections.Generic;
using System.Security.Claims;

namespace IdentityServer3
{
    public static class Users
    {
        public static List<InMemoryUser> Get()
        {
            return new List<InMemoryUser>
            {
                new InMemoryUser
                {
                    Username = "bob",
                    Password = "secret",
                    Subject = "1",

                    Claims = new[]
                    {
                        new Claim(Constants.ClaimTypes.GivenName, "Bob"),
                        new Claim(Constants.ClaimTypes.FamilyName, "Smith")
                    }
                }
            };
        }
    }
}

Clients.cs

using IdentityServer3.Core.Models;
using System.Collections.Generic;

namespace IdentityServer3
{
    public static class Clients
    {
        public static IEnumerable<Client> Get()
        {
            return new[]
            {
                new Client
                {
                    Enabled = true,
                    ClientName = "MVC Client",
                    ClientId = "mvc",
                    Flow = Flows.Implicit,

                    RedirectUris = new List<string>
                    {
                        "https://localhost:44319/"
                    },

                    AllowAccessToAllScopes = true
                }
            };
        }
    }
}

The certificate is from IdentityServer's github examples. It has been imported via the mmc certificate snapin and I set 'Copy to Output Directory' to 'Copy always' in Visual Studio 2015. I also have SSL enabled on the VS project and runAllManagedModulesForAllRequests="true" set in the web config/system.webServer/modules section.

When I try to fire it up via 'Start Debugging' I get:

{"Could not load type 'IdentityServer3.Core.Configuration.IdentityServerOptions' from assembly 'IdentityServer3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.":"IdentityServer3.Core.Configuration.IdentityServerOptions"}

Anyone else had this or has anyone got any insights on how to diagnose it?

Upvotes: 1

Views: 381

Answers (1)

Craig
Craig

Reputation: 889

I have had the same issue and it seems to be the name of the project / namespace used.

Naming my project IdentityServer3 I had the same issue. I created a project with a different name and this solved the problem.

Upvotes: 5

Related Questions