public ScopeStore(ScopeConfigurationDbContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            this.context = context;
        }
Esempio n. 2
0
		public static void ConfigureScopes(IEnumerable<Scope> scopes, EntityFrameworkServiceOptions options) {
			using(var db = new ScopeConfigurationDbContext(options.ConnectionString, options.Schema)) {
				if(!db.Scopes.Any()) {
					foreach(var s in scopes) {
						var e = s.ToEntity();
						db.Scopes.Add(e);
					}
					db.SaveChanges();
				}
			}
		}
        public IdentityAdminCoreManagerTests()
        {
            _identityAdminManagerService = new IdentityAdminManagerService("IdSvr3ConfigAdmin");
            using (var db = new ClientConfigurationDbContext(ConnectionString))
            {
                var allClients = db.Clients.Where(p => true);
                foreach (var c in allClients  )
                {
                    db.Clients.Remove(c);
                }
                db.SaveChanges();
                var testClient = new Client
                {
                    ClientId = "IdToTest",
                    ClientName = _clientName,
                    Enabled = true,
                    Flow = Flows.Implicit,
                    RequireConsent = true,
                    AllowRememberConsent = true,
                    RedirectUris =new List<ClientRedirectUri>() {new ClientRedirectUri {Id = 1, Uri = "www.redirect.com"}},
                    PostLogoutRedirectUris = new List<ClientPostLogoutRedirectUri>(){new ClientPostLogoutRedirectUri{Id = 1, Uri = "www.postRedirectUri.com"}},
                    AllowedScopes = new List<ClientScope>() { new ClientScope { Scope = "read" ,Id = 1} },
                    AccessTokenType = AccessTokenType.Jwt,
                    ClientSecrets = new List<ClientSecret>{new ClientSecret{Id = 1,Description = "removeMe",Type = "ssssshhh", Value = "nothing to see here"}},
                    IdentityProviderRestrictions = new List<ClientIdPRestriction>(){new ClientIdPRestriction{Id = 1,Provider = "www.provideme.com"}},
                    AllowedCustomGrantTypes = new List<ClientCustomGrantType>{new ClientCustomGrantType{Id = 1, GrantType = "Authorization Grant"}},
                    Claims = new List<ClientClaim>{new ClientClaim{Id = 1,Value = "tester", Type = "role"}},
                    AllowedCorsOrigins = new List<ClientCorsOrigin> { new ClientCorsOrigin { Id = 1,Origin = "www.CrossOriginMe.com"} }
                };
                db.Clients.Add(testClient);
                db.SaveChanges();
                _clientSubject = testClient.Id.ToString();
            }

            using (var db = new ScopeConfigurationDbContext(ConnectionString))
            {
                var allScopes = db.Scopes.Where(p => true);
                foreach (var c in allScopes)
                {
                    db.Scopes.Remove(c);
                }
                db.SaveChanges();
                var testScope = new Scope { Name = _scopeName,ScopeClaims = new List<ScopeClaim>{new ScopeClaim{Id = 1,Description = "To Test", Name = "testScope"}}};
                db.Scopes.Add(testScope);
                db.SaveChanges();
                _scopeSubject = testScope.Id.ToString();
            }
        }
        private static void ConfigureScopes(IEnumerable<Scope> scopes, EntityFrameworkServiceOptions options)
        {
            using (var db = new ScopeConfigurationDbContext(options.ConnectionString, options.Schema))
            {
                //if (!db.Scopes.Any())
                //{
                    foreach (var s in scopes)
                    {
                        if (db.Scopes.Any(x=>x.Name == s.Name))
                        {
                            // scope exists
                        }
                        else
                        {
                             var e = s.ToEntity();
                            db.Scopes.Add(e);
                        }

                    }
                    db.SaveChanges();
               // }
            }
        }
        public ScopeStore(ScopeConfigurationDbContext context)
        {
            if (context == null) throw new ArgumentNullException("context");

            this.context = context;
        }