Exemplo n.º 1
0
        public static IIdentityServerBuilder AddEasyIdentityServer(this IServiceCollection services, IdentityApiConfig identityApiConfig)
        {
            var migrationsAssembly = typeof(IdentityServerExtensions).GetTypeInfo().Assembly.GetName().Name;
            var builder            = services.AddIdentityServerInternal(identityApiConfig)
                                     .AddConfigurationStore(options =>
            {
                options.ConfigureDbContext = b =>
                                             b.UseMySql(identityApiConfig.MySql.ConfigurationDbContextConnectionString,
                                                        sql => sql.MigrationsAssembly(migrationsAssembly));
            })
                                     .AddOperationalStore(options =>
            {
                options.ConfigureDbContext = b =>
                                             b.UseMySql(identityApiConfig.MySql.PersistedGrantDbContextConnectionString,
                                                        sql => sql.MigrationsAssembly(migrationsAssembly));
            })
                                     .AddDeveloperSigningCredential(true, "tempkey.rsa");

            return(builder);
        }
Exemplo n.º 2
0
        private static IIdentityServerBuilder AddIdentityServerInternal(this IServiceCollection services, IdentityApiConfig identityApiConfig)
        {
            var builder = services.AddIdentityServer(x =>
            {
                x.IssuerUri       = identityApiConfig.Host;
                x.PublicOrigin    = identityApiConfig.Host;
                x.UserInteraction = new UserInteractionOptions()
                {
                    LoginUrl  = "/Account/Login",
                    LogoutUrl = "/Account/Login",
                    ErrorUrl  = "/Error"
                };
            })
                          .AddDeveloperSigningCredential()
                          .AddProfileService <ProfileService>()
                          .AddAspNetIdentity <IdentityUser>();

            return(builder);
        }
Exemplo n.º 3
0
 public static IIdentityServerBuilder AddEasyIdentityServerInMemory(this IServiceCollection services, IdentityApiConfig identityApiConfig)
 {
     return(services.AddIdentityServerInternal(identityApiConfig)
            .AddInMemoryApiResources(Config.GetApiResources())
            .AddInMemoryIdentityResources(Config.GetIdentityResources())
            .AddInMemoryClients(Config.GetClients()));
 }