Ejemplo n.º 1
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>()));
        }
 public AuthorizeRequestValidator(
     IdentityServerOptions options,
     IClientStore clients,
     ICustomAuthorizeRequestValidator customValidator,
     IRedirectUriValidator uriValidator,
     ScopeValidator scopeValidator,
     IUserSession userSession,
     ILogger <AuthorizeRequestValidator> logger)
 {
     _options         = options;
     _clients         = clients;
     _customValidator = customValidator;
     _uriValidator    = uriValidator;
     _scopeValidator  = scopeValidator;
     _userSession     = userSession;
     _logger          = logger;
 }
 public AuthorizeRequestValidator(
     IdentityServerOptions options,
     IClientStore clients,
     ICustomAuthorizeRequestValidator customValidator,
     IRedirectUriValidator uriValidator,
     IResourceValidator resourceValidator,
     IUserSession userSession,
     JwtRequestValidator jwtRequestValidator,
     IJwtRequestUriHttpClient jwtRequestUriHttpClient,
     ILogger <AuthorizeRequestValidator> logger)
 {
     _options                 = options;
     _clients                 = clients;
     _customValidator         = customValidator;
     _uriValidator            = uriValidator;
     _resourceValidator       = resourceValidator;
     _jwtRequestValidator     = jwtRequestValidator;
     _userSession             = userSession;
     _jwtRequestUriHttpClient = jwtRequestUriHttpClient;
     _logger = logger;
 }
Ejemplo n.º 4
0
        public static AuthorizeRequestValidator CreateAuthorizeRequestValidator(
            IdentityServerOptions options        = null,
            IIssuerNameService issuerNameService = null,
            IResourceStore resourceStore         = null,
            IClientStore clients    = null,
            IProfileService profile = null,
            ICustomAuthorizeRequestValidator customValidator = null,
            IRedirectUriValidator uriValidator               = null,
            IResourceValidator resourceValidator             = null,
            JwtRequestValidator jwtRequestValidator          = null,
            IJwtRequestUriHttpClient jwtRequestUriHttpClient = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

            if (issuerNameService == null)
            {
                issuerNameService = new TestIssuerNameService(options.IssuerUri);
            }

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

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

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

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

            if (resourceValidator == null)
            {
                resourceValidator = CreateResourceValidator(resourceStore);
            }

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

            if (jwtRequestUriHttpClient == null)
            {
                jwtRequestUriHttpClient = new DefaultJwtRequestUriHttpClient(new HttpClient(new NetworkHandler(new Exception("no jwt request uri response configured"))), options, new LoggerFactory());
            }


            var userSession = new MockUserSession();

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