示例#1
0
        public static ClientSecretValidator CreateClientSecretValidator(IClientStore clients = null, SecretParser parser = null, SecretValidator validator = null)
        {
            var options = TestIdentityServerOptions.Create();

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

            if (parser == null)
            {
                var parsers = new List <ISecretParser>
                {
                    new BasicAuthenticationSecretParser(options, TestLogger.Create <BasicAuthenticationSecretParser>()),
                    new PostBodySecretParser(options, TestLogger.Create <PostBodySecretParser>())
                };

                parser = new SecretParser(parsers, TestLogger.Create <SecretParser>());
            }

            if (validator == null)
            {
                var validators = new List <ISecretValidator>
                {
                    new HashedSharedSecretValidator(TestLogger.Create <HashedSharedSecretValidator>()),
                    new PlainTextSharedSecretValidator(TestLogger.Create <PlainTextSharedSecretValidator>())
                };

                validator = new SecretValidator(validators, TestLogger.Create <SecretValidator>());
            }

            return(new ClientSecretValidator(clients, parser, validator, new TestEventService(), TestLogger.Create <ClientSecretValidator>()));
        }
示例#2
0
        public static AuthorizeRequestValidator CreateAuthorizeRequestValidator(
            IdentityServerOptions options = null,
            IResourceStore resourceStore  = null,
            IClientStore clients          = null,
            IProfileService profile       = null,
            ICustomAuthorizeRequestValidator customValidator = null,
            IRedirectUriValidator uriValidator = null,
            ScopeValidator scopeValidator      = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

            if (resourceStore == null)
            {
                resourceStore = new InMemoryResourcesStore(TestScopes.GetIdentity(), TestScopes.GetApis());
            }

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

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

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

            if (scopeValidator == null)
            {
                scopeValidator = new ScopeValidator(resourceStore, new LoggerFactory().CreateLogger <ScopeValidator>());
            }

            var sessionId = new MockSessionIdService();

            return(new AuthorizeRequestValidator(
                       options,
                       clients,
                       customValidator,
                       uriValidator,
                       scopeValidator,
                       sessionId,
                       TestLogger.Create <AuthorizeRequestValidator>()));
        }
示例#3
0
 public static IClientStore CreateClientStore()
 {
     return(new InMemoryClientStore(TestClients.Get()));
 }
示例#4
0
        public static AuthorizeRequestValidator CreateAuthorizeRequestValidator(
            IdentityServerOptions options = null,
            IResourceStore resourceStore  = null,
            IClientStore clients          = null,
            IProfileService profile       = null,
            ICustomAuthorizeRequestValidator customValidator = null,
            IRedirectUriValidator uriValidator              = null,
            ScopeValidator scopeValidator                   = null,
            JwtRequestValidator jwtRequestValidator         = null,
            JwtRequestUriHttpClient jwtRequestUriHttpClient = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

            if (resourceStore == null)
            {
                resourceStore = new InMemoryResourcesStore(TestScopes.GetIdentity(), TestScopes.GetApis());
            }

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

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

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

            if (scopeValidator == null)
            {
                scopeValidator = new ScopeValidator(resourceStore, new LoggerFactory().CreateLogger <ScopeValidator>());
            }

            if (jwtRequestValidator == null)
            {
                jwtRequestValidator = new JwtRequestValidator("https://identityserver", new LoggerFactory().CreateLogger <JwtRequestValidator>());
            }

            if (jwtRequestUriHttpClient == null)
            {
                jwtRequestUriHttpClient = new JwtRequestUriHttpClient(new HttpClient(new NetworkHandler(new Exception("no jwt request uri response configured"))), new LoggerFactory().CreateLogger <JwtRequestUriHttpClient>());
            }

            var userSession = new MockUserSession();

            return(new AuthorizeRequestValidator(
                       options,
                       clients,
                       customValidator,
                       uriValidator,
                       scopeValidator,
                       userSession,
                       jwtRequestValidator,
                       jwtRequestUriHttpClient,
                       TestLogger.Create <AuthorizeRequestValidator>()));
        }