コード例 #1
0
        public static IdentityServerServiceFactory Create(
            IEnumerable<InMemoryUser> users = null,
            IEnumerable<Client> clients = null,
            IEnumerable<Scope> scopes = null)
        {
            var factory = new IdentityServerServiceFactory();
            
            if (users != null)
            {
                var userService = new InMemoryUserService(users);
                factory.UserService = Registration.RegisterFactory<IUserService>(() => userService);
            }

            if (clients != null)
            {
                var clientStore = new InMemoryClientStore(clients);
                factory.ClientStore = Registration.RegisterFactory<IClientStore>(() => clientStore);
            }

            if (scopes != null)
            {
                var scopeStore = new InMemoryScopeStore(scopes);
                factory.ScopeStore = Registration.RegisterFactory<IScopeStore>(() => scopeStore);
            }

            return factory;
        }
コード例 #2
0
        public static IdentityServerServiceFactory Configure()
        {
            var factory = new IdentityServerServiceFactory();

            var scopeStore = new InMemoryScopeStore(Scopes.Get());
            factory.ScopeStore = new Registration<IScopeStore>(resolver => scopeStore);
            
            var clientStore = new InMemoryClientStore(Clients.Get());
            factory.ClientStore = new Registration<IClientStore>(resolver => clientStore);            
            //var corsPolicyService = new CorsPolicyService();
            //factory.CorsPolicyService = new Registration<ICorsPolicyService>(ressolver => corsPolicyService);

            var origns = new List<string>();
            
            origns.Add("http://thebeast.com:15831");
            origns.Add("http://localhost:15831");
            origns.Add("http://localhost:15832");
            origns.Add("http://karamaangular.azurewebsites.net");

            var defaultCorsPolicyService = new DefaultCorsPolicyService() { AllowAll = false, AllowedOrigins = origns };
            factory.CorsPolicyService = new Registration<ICorsPolicyService>(ressolver => defaultCorsPolicyService);

            /*            factory.ConfigureDefaultViewService(new DefaultViewServiceOptions(){})*/
            ;
            return factory;
        }
コード例 #3
0
        public static TokenRequestValidator CreateTokenRequestValidator(
            IdentityServerOptions options = null,
            IScopeStore scopes = null,
            IAuthorizationCodeStore authorizationCodeStore = null,
            IRefreshTokenStore refreshTokens = null,
            IUserService userService = null,
            ICustomGrantValidator customGrantValidator = null,
            ICustomRequestValidator customRequestValidator = null,
            ScopeValidator scopeValidator = null,
            IDictionary<string, object> environment = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

            if (scopes == null)
            {
                scopes = new InMemoryScopeStore(TestScopes.Get());
            }

            if (userService == null)
            {
                userService = new TestUserService();
            }

            if (customRequestValidator == null)
            {
                customRequestValidator = new DefaultCustomRequestValidator();
            }

            if (customGrantValidator == null)
            {
                customGrantValidator = new TestGrantValidator();
            }

            if (refreshTokens == null)
            {
                refreshTokens = new InMemoryRefreshTokenStore();
            }

            if (scopeValidator == null)
            {
                scopeValidator = new ScopeValidator(scopes);
            }

            IOwinContext context;
            if (environment == null)
            {
                context = new OwinContext(new Dictionary<string, object>());
            }
            else
            {
                context = new OwinContext(environment);
            }


            return new TokenRequestValidator(options, authorizationCodeStore, refreshTokens, userService, scopes, customGrantValidator, customRequestValidator, scopeValidator, context);
        }
コード例 #4
0
ファイル: Factory.cs プロジェクト: ridopark/IdentityServer3
        public static TokenRequestValidator CreateTokenRequestValidator(
            IdentityServerOptions options = null,
            IScopeStore scopes = null,
            IAuthorizationCodeStore authorizationCodeStore = null,
            IRefreshTokenStore refreshTokens = null,
            IUserService userService = null,
            ICustomGrantValidator customGrantValidator = null,
            ICustomRequestValidator customRequestValidator = null,
            ScopeValidator scopeValidator = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

            if (scopes == null)
            {
                scopes = new InMemoryScopeStore(TestScopes.Get());
            }

            if (userService == null)
            {
                userService = new TestUserService();
            }

            if (customRequestValidator == null)
            {
                customRequestValidator = new DefaultCustomRequestValidator();
            }

            if (customGrantValidator == null)
            {
                customGrantValidator = new TestGrantValidator();
            }

            if (refreshTokens == null)
            {
                refreshTokens = new InMemoryRefreshTokenStore();
            }

            if (scopeValidator == null)
            {
                scopeValidator = new ScopeValidator(scopes);
            }

            return new TokenRequestValidator(
                options, 
                authorizationCodeStore, 
                refreshTokens, 
                userService, 
                customGrantValidator, 
                customRequestValidator, 
                scopeValidator, 
                new DefaultEventService());
        }
コード例 #5
0
        public static IdentityServerServiceFactory Configure()
        {
            var factory = new IdentityServerServiceFactory();

            var scopeStore = new InMemoryScopeStore(Scopes.Get());
            factory.ScopeStore = new Registration<IScopeStore>(scopeStore);
            var clientStore = new InMemoryClientStore(Clients.Get());
            factory.ClientStore = new Registration<IClientStore>(clientStore);

            return factory;
        }
コード例 #6
0
        public static IdentityServerServiceFactory Configure(string connString)
        {
            var factory = new IdentityServerServiceFactory();

            factory.UserService = Registration<IUserService>.RegisterFactory(()=>MembershipRebootUserServiceFactory.Factory(connString));

            var scopeStore = new InMemoryScopeStore(Scopes.Get());
            factory.ScopeStore = Registration.RegisterFactory<IScopeStore>(() => scopeStore);
            var clientStore = new InMemoryClientStore(Clients.Get());
            factory.ClientStore = Registration.RegisterFactory<IClientStore>(() => clientStore);

            return factory;
        }
コード例 #7
0
        public static IdentityServerServiceFactory Create()
        {
            var scopes = new InMemoryScopeStore(TestScopes.Get());
            var clients = new InMemoryClientStore(TestClients.Get());
            
            var fact = new IdentityServerServiceFactory
            {
                ScopeStore = new Registration<IScopeStore>((resolver) => scopes),
                ClientStore = new Registration<IClientStore>((resolver) => clients)
            };

            return fact;
        }
コード例 #8
0
        public static TokenRequestValidator CreateTokenValidator(
            IdentityServerOptions options = null,
            IScopeStore scopes = null,
            IAuthorizationCodeStore authorizationCodeStore = null,
            IRefreshTokenStore refreshTokens = null,
            IUserService userService = null,
            IAssertionGrantValidator assertionGrantValidator = null,
            ICustomRequestValidator customRequestValidator = null)
        {
            if (options == null)
            {
                options = Thinktecture.IdentityServer.Tests.TestIdentityServerOptions.Create();
            }

            if (scopes == null)
            {
                scopes = new InMemoryScopeStore(TestScopes.Get());
            }

            if (userService == null)
            {
                userService = new TestUserService();
            }

            if (customRequestValidator == null)
            {
                customRequestValidator = new DefaultCustomRequestValidator();
            }

            if (assertionGrantValidator == null)
            {
                assertionGrantValidator = new TestAssertionValidator();
            }

            if (refreshTokens == null)
            {
                refreshTokens = new InMemoryRefreshTokenStore();
            }

            return new TokenRequestValidator(options, authorizationCodeStore, refreshTokens, userService, scopes, assertionGrantValidator, customRequestValidator);
        }
コード例 #9
0
        public IdentityServerHost()
        {
            var clientStore = new InMemoryClientStore(Clients);
            var scopeStore = new InMemoryScopeStore(Scopes);
            var userService = new InMemoryUserService(Users);

            var factory = new IdentityServerServiceFactory
            {
                ScopeStore = new Registration<IScopeStore>(scopeStore),
                ClientStore = new Registration<IClientStore>(clientStore),
                UserService = new Registration<IUserService>(userService),
                ClientSecretValidator = new Registration<IClientSecretValidator, PlainTextClientSecretValidator>(),
            };

            Options = new IdentityServerOptions
            {
                Factory = factory,
                DataProtector = new NoDataProtector(),
                SiteName = "Thinktecture IdentityServer3 Host",
                SigningCertificate = SigningCertificate
            };
        }
コード例 #10
0
ファイル: Factory.cs プロジェクト: ridopark/IdentityServer3
        public static AuthorizeRequestValidator CreateAuthorizeRequestValidator(
            IdentityServerOptions options = null,
            IScopeStore scopes = null,
            IClientStore clients = null,
            IUserService users = null,
            ICustomRequestValidator customValidator = null,
            IRedirectUriValidator uriValidator = null,
            ScopeValidator scopeValidator = null,
            IDictionary<string, object> environment = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

            if (scopes == null)
            {
                scopes = new InMemoryScopeStore(TestScopes.Get());
            }

            if (clients == null)
            {
                clients = new InMemoryClientStore(TestClients.Get());
            }

            if (customValidator == null)
            {
                customValidator = new DefaultCustomRequestValidator();
            }

            if (uriValidator == null)
            {
                uriValidator = new DefaultRedirectUriValidator();
            }

            if (scopeValidator == null)
            {
                scopeValidator = new ScopeValidator(scopes);
            }

            var mockSessionCookie = new Mock<SessionCookie>((IOwinContext)null, (IdentityServerOptions)null);
            mockSessionCookie.CallBase = false;
            mockSessionCookie.Setup(x => x.GetSessionId()).Returns((string)null);

            return new AuthorizeRequestValidator(options, clients, customValidator, uriValidator, scopeValidator, mockSessionCookie.Object);

        }
コード例 #11
0
        public static AuthorizeRequestValidator CreateAuthorizeRequestValidator(
            IdentityServerOptions options = null,
            IScopeStore scopes = null,
            IClientStore clients = null,
            IUserService users = null,
            ICustomRequestValidator customValidator = null,
            IRedirectUriValidator uriValidator = null,
            ScopeValidator scopeValidator = null,
            IDictionary<string, object> environment = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

            if (scopes == null)
            {
                scopes = new InMemoryScopeStore(TestScopes.Get());
            }

            if (clients == null)
            {
                clients = new InMemoryClientStore(TestClients.Get());
            }

            if (customValidator == null)
            {
                customValidator = new DefaultCustomRequestValidator();
            }

            if (uriValidator == null)
            {
                uriValidator = new DefaultRedirectUriValidator();
            }

            if (scopeValidator == null)
            {
                scopeValidator = new ScopeValidator(scopes);
            }

            IOwinContext context;
            if (environment == null)
            {
                context = new OwinContext(new Dictionary<string, object>());
            }
            else
            {
                context = new OwinContext(environment);
            }

            return new AuthorizeRequestValidator(options, clients, customValidator, uriValidator, scopeValidator, context);
        }
        public void Configuration(IAppBuilder app)
        {
            //var factory2 = new IdentityServerServiceFactory();

            //LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
            //var factory = InMemoryFactory.Create(
            //    scopes: Scopes.Get(),
            //    clients: Clients.Get(),
            //    users: Users2.Get()
            //    );
            var factory = new IdentityServerServiceFactory();
            var scopeStore = new InMemoryScopeStore(Scopes.Get());
            factory.ScopeStore = new Registration<IScopeStore>(scopeStore);
            var clientStore = new InMemoryClientStore(Clients.Get());
            factory.ClientStore = new Registration<IClientStore>(clientStore);
            factory.TokenService = new Registration<ITokenService>(typeof(MyCustomTokenService));
            factory.RefreshTokenStore = new Registration<IRefreshTokenStore>(typeof(MyCustomRefreshTokenStore));
            factory.CustomTokenValidator = new Registration<ICustomTokenValidator>(new MyCustomTokenValidator());
            factory.TokenHandleStore = new Registration<ITokenHandleStore>(new MyCustomTokenHandleStore());
            factory.ConfigureUserService("AspId");
            LogProvider.SetCurrentLogProvider(new NLogLogProvider());
            //LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
            //factory.TokenHandleStore = new Registration<ITokenHandleStore>();
            //factory.RefreshTokenStore = new Registration<IRefreshTokenStore>();
            //factory.CustomTokenValidator = new Registration<ICustomTokenValidator>(new MyCustomTokenValidator());
            //factory.Register(new Registration<IUserService, MyCustomUserService>());
            //factory.Register(new Registration<IMyCustomLogger, MyCustomLogger>());
            //factory.UserService = new Registration<IUserService>(typeof(IUserService));
            var options = new IdentityServerOptions
            {
                Factory = factory,
                //IssuerUri = "https://idsrv3.com",
                SiteName = "Thinktecture IdentityServer3 Halo",
                SigningCertificate = Certificate.Get(),
                RequireSsl = false,
                CspOptions = new CspOptions
                {
                    Enabled =true,
                },
                Endpoints = new EndpointOptions
                {
                    EnableAccessTokenValidationEndpoint = true,
                    EnableTokenEndpoint = true,
                    EnableTokenRevocationEndpoint = true,
                    EnableIdentityTokenValidationEndpoint = true,

                    //remove in production
                    EnableDiscoveryEndpoint = true,

                    EnableAuthorizeEndpoint= false,
                    EnableClientPermissionsEndpoint= false,
                    EnableCspReportEndpoint= false,

                    EnableEndSessionEndpoint=false,
                    EnableCheckSessionEndpoint = false,
                    EnableUserInfoEndpoint = false
                },
                AuthenticationOptions = new AuthenticationOptions
                {
                    EnableLocalLogin = true,
                    EnableLoginHint = false,
                },
                LoggingOptions = new LoggingOptions
                {
                    EnableHttpLogging=true,
                    EnableWebApiDiagnostics=true,
                    IncludeSensitiveDataInLogs=true,
                    WebApiDiagnosticsIsVerbose=true
                },
                EnableWelcomePage = false,
                IssuerUri = "https://HFL0100:44333"

            };
            options.CorsPolicy.AllowedOrigins.Add("http://localhost:14869/");

            app.UseHsts();
            app.UseIdentityServer(options);
        }
コード例 #13
0
        public static AuthorizeRequestValidator CreateAuthorizeValidator(
            IdentityServerOptions options = null,
            IScopeStore scopes = null,
            IClientStore clients = null,
            IUserService users = null,
            ICustomRequestValidator customValidator = null)
        {
            if (options == null)
            {
                options = Thinktecture.IdentityServer.Tests.TestIdentityServerOptions.Create();
            }

            if (scopes == null)
            {
                scopes = new InMemoryScopeStore(TestScopes.Get());
            }

            if (clients == null)
            {
                clients = new InMemoryClientStore(TestClients.Get());
            }

            if (customValidator == null)
            {
                customValidator = new DefaultCustomRequestValidator();
            }

            return new AuthorizeRequestValidator(options, scopes, clients, customValidator);
        }