Exemplo n.º 1
0
        public void Configuration(IAppBuilder app)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.Trace()
                         .CreateLogger();

            app.Map("/identity", x =>
            {
                var serviceFactory = new IdentityServerServiceFactory()
                                     .UseInMemoryClients(Hardcoded.Clients())
                                     .UseInMemoryScopes(Hardcoded.Scopes());

                // this will require storing of username/password somewhere

                /*
                 * serviceFactory.UseInMemoryUsers(Hardcoded.Users());
                 */

                // this is to allow a new UserService to be created each time one is needed

                /*
                 * serviceFactory.Register(new Registration<List<InMemoryUser>>(Hardcoded.Users(), (string) null));
                 * serviceFactory.UserService = new Registration<IUserService, UserService>((string) null);
                 */

                // this will register one with no dependencies that gets created each time
                //serviceFactory.UserService = new Registration<IUserService>(typeof(UserService));

                // this will creat a single UserService to be shared at runtime - better make it thread safe
                serviceFactory.UserService = new Registration <IUserService>(new UserService());

                var options = new IdentityServerOptions
                {
                    SiteName = "CMSAuthServer IdentityServer",
                    // publicorigin would be important if behind a proxy
                    //PublicOrigin = "",
                    SigningCertificate    = Hardcoded.Cert(),
                    Factory               = serviceFactory,
                    RequireSsl            = false,
                    AuthenticationOptions = new AuthenticationOptions
                    {
                        IdentityProviders = ConfigureIdentityProviders
                    }
                };

                x.UseIdentityServer(options);
            });
        }
Exemplo n.º 2
0
        private static void ConfigureWindowsTokenProvider(IAppBuilder app)
        {
            var options = new WindowsAuthenticationOptions
            {
                IdpRealm                     = "urn:win",
                SubjectType                  = SubjectType.Sid,
                IdpReplyUrl                  = RootUrl + "was",
                PublicOrigin                 = RootUrl,
                SigningCertificate           = Hardcoded.Cert(),
                EnableOAuth2Endpoint         = true,
                EmitWindowsAccountNameAsName = true
            };

            app.UseWindowsAuthenticationService(options);
        }
Exemplo n.º 3
0
        public void Configuration(IAppBuilder appBuilder)
        {
            appBuilder.Map("/windows", ConfigureWindowsTokenProvider);

            var factory = new IdentityServerServiceFactory()
                          .UseInMemoryClients(Hardcoded.Clients())
                          .UseInMemoryScopes(Hardcoded.Scopes());

            factory.UserService = new Registration <IUserService>(typeof(ExternalRegistrationUserService));

            var options = new IdentityServerOptions
            {
                SigningCertificate    = Hardcoded.Cert(),
                Factory               = factory,
                AuthenticationOptions = new AuthenticationOptions
                {
                    EnableLocalLogin  = true,
                    IdentityProviders = ConfigureIdentityProviders
                }
            };

            appBuilder.UseIdentityServer(options);
        }