Exemplo n.º 1
0
        private static IdentityServerServiceFactory ConfigureFactory(SsoServiceEnvironmentConfiguration environment)
        {
            var connectionString = environment.TableStorageConnectionString;

            var factory = new IdentityServerServiceFactory();

            var viewOptions = new DefaultViewServiceOptions();

#if DEBUG
            viewOptions.CacheViews = false;
#endif
            viewOptions.Stylesheets.Add("https://maxcdn.bootstrapcdn.com/bootswatch/3.3.6/united/bootstrap.min.css");
            viewOptions.Stylesheets.Add("https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css");
            viewOptions.Stylesheets.Add("https://appsyndication.azureedge.net/css/site.css");
#if DEBUG
            viewOptions.Stylesheets.Add("/sso/css/site.css");
#endif
            viewOptions.Scripts.Add("https://code.jquery.com/jquery-1.12.3.min.js");
            viewOptions.Scripts.Add("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js");
            viewOptions.Scripts.Add("https://appsyndication.azureedge.net/js/site.js");

            factory.ConfigureDefaultViewService(viewOptions);

            var scopes = Scopes.Get();

            var scopeStore = new InMemoryScopeStore(scopes);
            factory.ScopeStore = new Registration <IScopeStore>(scopeStore);

            var clients = Clients.Get(environment);

            var clientStore = new InMemoryClientStore(clients);
            factory.ClientStore = new Registration <IClientStore>(clientStore);

            factory.UserService = new Registration <IUserService, UserService>();
            factory.Register(new Registration <AtsUserService>());
            factory.Register(new Registration <AtsUserRepository>());
            factory.Register(new Registration <AtsUserServiceConfig>(r => new AtsUserServiceConfig(connectionString, "appsyndication")));

            return(factory);
        }
Exemplo n.º 2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <ClientStoreConfiguration>(this.Configuration.GetSection("ClientSecrets"));

            services.AddSingleton <IClientStore, ClientStore>();

            services.Configure <IdentityServerOptions>(options =>
            {
                options.SiteName           = "AppSyndication";
                options.SigningCertificate = this.LoadCertificate(this.Configuration.GetValue <string>("CertificateThumprint"));
                options.RequireSsl         = false;
            });

            services.AddIdentityServer()
            .ConfigureIdentity <ApplicationUser>()
            .AddInMemoryScopes(Scopes.Get());

            services.AddIdentity <ApplicationUser, ApplicationRole>(options =>
            {
                options.ClaimsIdentity.RoleClaimType     = JwtClaimTypes.Role;
                options.ClaimsIdentity.UserIdClaimType   = JwtClaimTypes.Subject;
                options.ClaimsIdentity.UserNameClaimType = JwtClaimTypes.PreferredUserName;
                options.SignIn.RequireConfirmedEmail     = true;
                options.User.AllowedUserNameCharacters   = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
                options.User.RequireUniqueEmail          = true;
            })
            .AddAzureTableStore(this.Configuration.GetConnectionString("Storage"))
            .AddDefaultTokenProviders();

            services.AddTransient <IEmailSender, AuthMessageSender>();
            services.AddTransient <ISmsSender, AuthMessageSender>();

            services.AddRouting(options =>
            {
                options.AppendTrailingSlash = true;
                options.LowercaseUrls       = true;
            });

            services.AddMvc();
        }