コード例 #1
0
ファイル: Startup.cs プロジェクト: mriveira/pendencia
        private void InitializeDatabase(IApplicationBuilder app, ConfigSettingsBase settings)
        {
            using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                serviceScope.ServiceProvider.GetRequiredService <PersistedGrantDbContext>().Database.Migrate();
                var context = serviceScope.ServiceProvider.GetRequiredService <ConfigurationDbContext>();
                context.Database.Migrate();

                foreach (var client in Config.GetClients(settings))
                {
                    if (context.Clients.Where(_ => _.ClientId == client.ClientId).IsNotAny())
                    {
                        context.Clients.Add(client.ToEntity());
                    }
                }
                context.SaveChanges();
                foreach (var identityResource in Config.GetIdentityResources())
                {
                    if (context.IdentityResources.Where(_ => _.Name == identityResource.Name).IsNotAny())
                    {
                        context.IdentityResources.Add(identityResource.ToEntity());
                    }
                }
                context.SaveChanges();
                foreach (var apiResource in Config.GetApiResources())
                {
                    if (context.ApiResources.Where(_ => _.Name == apiResource.Name).IsNotAny())
                    {
                        context.ApiResources.Add(apiResource.ToEntity());
                    }
                }
                context.SaveChanges();
            }
        }
コード例 #2
0
        public static void Update(ConfigSettingsBase settings, ICache cache, IHostingEnvironment env, ConfigurationDbContext context)
        {
            //foreach (var client in Config.GetClients(settings))
            //{
            //    if (context.Clients.Where(_ => _.ClientId == client.ClientId).IsNotAny())
            //        context.Clients.Add(client.ToEntity());

            //}
            //context.SaveChanges();

            //foreach (var ir in Config.GetIdentityResources())
            //{
            //    if (context.IdentityResources.Where(_ => _.Name == ir.Name).IsNotAny())
            //        context.IdentityResources.Add(ir.ToEntity());

            //}
            //context.SaveChanges();

            //foreach (var ar in Config.GetApiResources())
            //{
            //    if (context.ApiResources.Where(_ => _.Name == ar.Name).IsNotAny())
            //        context.ApiResources.Add(ar.ToEntity());

            //}
            //context.SaveChanges();
        }
コード例 #3
0
 public DownloadController(ILoggerFactory logger, IHostingEnvironment env, IOptions <ConfigSettingsBase> configSettingsBase, IStorage storage)
 {
     this._logger             = logger.CreateLogger <DownloadController>();
     this._env                = env;
     this._uploadRoot         = "upload";
     this._storage            = storage;
     this._configSettingsBase = configSettingsBase.Value;
 }
        public static IEnumerable <Client> GetClients(ConfigSettingsBase settings)
        {
            return(new List <Client>
            {
                new Client
                {
                    ClientId = "Seed",
                    AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
                    ClientSecrets =
                    {
                        new Secret("secret".Sha256())
                    },
                    AllowedScopes =
                    {
                        StandardScopes.OpenId,
                        StandardScopes.Profile,
                        StandardScopes.Email,
                        "ssosa"
                    }
                },

                new Client
                {
                    ClientId = "Seed-spa",
                    ClientSecrets = { new Secret("segredo".Sha256()) },

                    AllowedGrantTypes = GrantTypes.Implicit,
                    AllowAccessTokensViaBrowser = true,

                    RedirectUris =
                    {
                        settings.RedirectUris
                    },
                    PostLogoutRedirectUris =
                    {
                        settings.PostLogoutRedirectUris
                    },

                    AllowedCorsOrigins = { settings.ClientAuthorityEndPoint },

                    AllowedScopes =
                    {
                        StandardScopes.OpenId,
                        StandardScopes.Profile,
                        StandardScopes.Email,
                        "ssosa"
                    },
                    RequireConsent = false,
                    AccessTokenLifetime = 43200
                }
            });
        }
コード例 #5
0
        public static void InitializeDatabase(IApplicationBuilder app,
                                              ConfigSettingsBase settings,
                                              ICache cache,
                                              IHostingEnvironment env)
        {
            using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                serviceScope.ServiceProvider.GetRequiredService <PersistedGrantDbContext>();
                var context = serviceScope.ServiceProvider.GetRequiredService <ConfigurationDbContext>();
                context.Database.Migrate();

                Update(settings, cache, env, context);
            }
        }
コード例 #6
0
 public EmailQueue(
     IWebJobRequest webJobRequest,
     ICircuitBreaker CircuitBreaker,
     CurrentUser user,
     IOptions <ConfigSettingsExternalRequest> configSettingsExternalRequest,
     IOptions <ConfigSettingsBase> configSettingsBase,
     IOptions <ConfigCircuitBreaker> configCircuitBreaker,
     IOptions <ConfigEmailBase> configEmailBase,
     ILoggerFactory iLoggerFactory)
 {
     this._webJobRequest = webJobRequest;
     this._configSettingsExternalRequest = configSettingsExternalRequest.Value;
     this._configSettingsBase            = configSettingsBase.Value;
     this._configCircuitBreaker          = configCircuitBreaker.Value;
     this._configEmailBase = configEmailBase.Value;
     this._CircuitBreaker  = CircuitBreaker;
     this._user            = user;
     this._logger          = iLoggerFactory.CreateLogger(this.GetType().Name);
     this.Init();
 }
コード例 #7
0
 public ResourceOwnerPasswordValidator(IOptions <ConfigSettingsBase> configSettingsBase)
 {
     this._settings = configSettingsBase.Value;
 }
コード例 #8
0
 public MemoryComponent(IOptions <ConfigSettingsBase> configSettingsBase)
 {
     this._configSettingsBase = configSettingsBase.Value;
 }
コード例 #9
0
 public RedisComponent(IDistributedCache _cache, IOptions <ConfigSettingsBase> configSettingsBase)
 {
     this._cache = _cache;
     this._configSettingsBase = configSettingsBase.Value;
 }
 public RedisStackExchangeComponent(IOptions <ConfigSettingsBase> configSettings, IOptions <ConfigCacheConnectionStringBase> configCache)
 {
     this._configSettingsBase = configSettings.Value;
     RedisStackExchangeComponent.Init(configCache);
     this._cache = RedisStackExchangeComponent.RedisCache;
 }
コード例 #11
0
 public ResourceOwnerPasswordValidator(IOptions <ConfigSettingsBase> configSettingsBase, IUserCredentialServices userServices)
 {
     this._settings     = configSettingsBase.Value;
     this._userServices = userServices;
 }
コード例 #12
0
        public static IEnumerable <Client> GetClients(ConfigSettingsBase settings)
        {
            return(new List <Client>
            {
                new Client
                {
                    ClientId = "Seed",
                    AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
                    ClientSecrets =
                    {
                        new Secret("secret".Sha256())
                    },
                    AllowedScopes =
                    {
                        StandardScopes.OpenId,
                        StandardScopes.Profile,
                        StandardScopes.Email,
                        "ssosa"
                    }
                },

                new Client
                {
                    ClientId = "Seed-spa",
                    ClientSecrets = { new Secret("segredo".Sha256()) },

                    AllowedGrantTypes = GrantTypes.Implicit,
                    AllowAccessTokensViaBrowser = true,

                    RedirectUris = settings.RedirectUris.ToList(),
                    PostLogoutRedirectUris = settings.PostLogoutRedirectUris.ToList(),
                    AllowedCorsOrigins = settings.ClientAuthorityEndPoint.ToList(),

                    AllowedScopes =
                    {
                        StandardScopes.OpenId,
                        StandardScopes.Profile,
                        StandardScopes.Email,
                        "ssosa"
                    },
                    RequireConsent = false,
                    AccessTokenLifetime = 43200
                },
                new Client
                {
                    ClientId = "Seed-spa-custom",
                    ClientSecrets = { new Secret("segredo".Sha256()) },

                    AllowedGrantTypes = GrantTypes.Implicit,
                    AllowAccessTokensViaBrowser = true,

                    RedirectUris = settings.RedirectUris.ToList(),
                    PostLogoutRedirectUris = settings.PostLogoutRedirectUris.ToList(),
                    AllowedCorsOrigins = settings.ClientAuthorityEndPoint.ToList(),

                    AllowedScopes =
                    {
                        StandardScopes.OpenId,
                        StandardScopes.Profile,
                        StandardScopes.Email,
                        "ssosa"
                    },
                    RequireConsent = false,
                    AccessTokenLifetime = 43200
                },
                new Client
                {
                    ClientId = "hangfire-dash",
                    ClientName = "HangFire Dashboard",
                    ClientSecrets = { new Secret("segredo".Sha256()) },

                    AllowedGrantTypes = GrantTypes.Implicit,
                    AllowAccessTokensViaBrowser = true,
                    RedirectUris = settings.RedirectUris.ToList(),

                    AllowedScopes =
                    {
                        StandardScopes.OpenId,
                        StandardScopes.Profile,
                        StandardScopes.Email,
                        "ssosa"
                    },
                    RequireConsent = false,
                    AccessTokenLifetime = 43200
                },
                new Client
                {
                    ClientId = "hangfire-api",
                    AllowedGrantTypes = GrantTypes.ClientCredentials,
                    ClientSecrets =
                    {
                        new Secret("segredo".Sha256())
                    },
                    AllowedScopes =
                    {
                        StandardScopes.OpenId,
                        StandardScopes.Profile,
                        StandardScopes.Email,
                        "ssosa"
                    },
                    Claims = new List <Claim> {
                        new Claim(JwtClaimTypes.Subject, "991")
                    },
                    AccessTokenLifetime = 43200
                },
                new Client
                {
                    ClientId = "swagger-dash",
                    ClientName = "swagger Dashboard",
                    ClientSecrets = { new Secret("segredo".Sha256()) },

                    AllowedGrantTypes = GrantTypes.Implicit,
                    AllowAccessTokensViaBrowser = true,
                    RedirectUris = settings.RedirectUris.ToList(),

                    AllowedScopes =
                    {
                        StandardScopes.OpenId,
                        StandardScopes.Profile,
                        StandardScopes.Email,
                        "ssosa"
                    },
                    RequireConsent = false,
                    AccessTokenLifetime = 43200
                },
                new Client
                {
                    ClientId = "Seed-spa-anonymous",
                    AllowedGrantTypes = GrantTypes.ClientCredentials,
                    ClientSecrets =
                    {
                        new Secret("4aa288ca-1603-45c2-85c3-b41a08d2bd0a".Sha256())
                    },
                    AllowedScopes =
                    {
                        StandardScopes.OpenId,
                        StandardScopes.Profile,
                        StandardScopes.Email,
                        "ssosa"
                    },
                }
            });
        }
コード例 #13
0
        public static IEnumerable <Client> GetClients(ConfigSettingsBase settings)
        {
            return(new List <Client>
            {
                new Client
                {
                    ClientId = "Seed",
                    AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
                    ClientSecrets =
                    {
                        new Secret("secret".Sha256())
                    },
                    AllowedScopes =
                    {
                        StandardScopes.OpenId,
                        StandardScopes.Profile,
                        StandardScopes.Email,
                        "ssosa"
                    }
                },

                new Client
                {
                    ClientId = "Seed-spa",
                    ClientSecrets = { new Secret("segredo".Sha256()) },

                    AllowedGrantTypes = GrantTypes.Implicit,
                    AllowAccessTokensViaBrowser = true,

                    RedirectUris = settings.RedirectUris.ToList(),
                    PostLogoutRedirectUris = settings.PostLogoutRedirectUris.ToList(),
                    AllowedCorsOrigins = settings.ClientAuthorityEndPoint.ToList(),

                    AllowedScopes =
                    {
                        StandardScopes.OpenId,
                        StandardScopes.Profile,
                        StandardScopes.Email,
                        "ssosa"
                    },
                    RequireConsent = false,
                    AccessTokenLifetime = 43200
                },
                new Client
                {
                    ClientId = "hangfire-dash",
                    ClientName = "HangFire Dashboard",
                    ClientSecrets = { new Secret("segredo".Sha256()) },

                    AllowedGrantTypes = GrantTypes.Implicit,
                    AllowAccessTokensViaBrowser = true,
                    RedirectUris =
                    {
                        "http://localhost:8123/signin-oidc",
                    },

                    AllowedScopes =
                    {
                        StandardScopes.OpenId,
                        StandardScopes.Profile,
                        StandardScopes.Email,
                        "ssosa"
                    },
                    RequireConsent = false,
                    AccessTokenLifetime = 43200
                },
                new Client
                {
                    ClientId = "hangfire-api",
                    AllowedGrantTypes = GrantTypes.ClientCredentials,
                    ClientSecrets =
                    {
                        new Secret("segredo".Sha256())
                    },
                    AllowedScopes =
                    {
                        StandardScopes.OpenId,
                        StandardScopes.Profile,
                        StandardScopes.Email,
                        "ssosa"
                    },
                    Claims = new List <Claim> {
                        new Claim(JwtClaimTypes.Subject, "991")
                    },
                    AccessTokenLifetime = 43200
                },
                new Client
                {
                    ClientId = "swagger-dash",
                    ClientName = "swagger Dashboard",
                    ClientSecrets = { new Secret("segredo".Sha256()) },

                    AllowedGrantTypes = GrantTypes.Implicit,
                    AllowAccessTokensViaBrowser = true,
                    RedirectUris =
                    {
                        "http://localhost:8122/swagger/oauth2-redirect.html",
                    },

                    AllowedScopes =
                    {
                        StandardScopes.OpenId,
                        StandardScopes.Profile,
                        StandardScopes.Email,
                        "ssosa"
                    },
                    RequireConsent = false,
                    AccessTokenLifetime = 43200
                }
            });
        }
コード例 #14
0
 public ResourceOwnerPasswordValidator(IUsuarioRepository rep, IOptions <ConfigSettingsBase> configSettingsBase)
 {
     this._rep      = rep;
     this._settings = configSettingsBase.Value;
 }