public async Task <global::IdentityServer3.Core.Models.Scope> GetScopeAsync()
        {
            if (_original != null)
            {
                return(await Task.FromResult(_original));
            }
            global::IdentityServer3.Core.Models.Scope result = null;
            result = await MakeIdentityServerScopeAsync();

            return(result);
        }
 public AbstractScopeHandle(global::IdentityServer3.Core.Models.Scope scope = null)
 {
     _original = scope;
     if (scope != null)
     {
         AllowUnrestrictedIntrospection = scope.AllowUnrestrictedIntrospection;
         Claims                  = Serialize(scope.Claims);
         ClaimsRule              = scope.ClaimsRule;
         Description             = scope.Description;
         DisplayName             = scope.DisplayName;
         Emphasize               = scope.Emphasize;
         Enabled                 = scope.Enabled;
         IncludeAllClaimsForUser = scope.IncludeAllClaimsForUser;
         Name                    = scope.Name;
         Required                = scope.Required;
         ScopeSecrets            = Serialize(scope.ScopeSecrets);
         ShowInDiscoveryDocument = scope.ShowInDiscoveryDocument;
         Type                    = scope.Type;
     }
 }
        public static async Task <List <FlattenedScopeRecord> > InsertTestData_Scopes(int count = 1)
        {
            var dao = new IdentityServer3CassandraDao();
            await dao.EstablishConnectionAsync();

            var result = new List <FlattenedScopeRecord>();

            for (int i = 0; i < count; ++i)
            {
                var name = "ScopeName:" + Guid.NewGuid();
                global::IdentityServer3.Core.Models.Scope record = new global::IdentityServer3.Core.Models.Scope()
                {
                    AllowUnrestrictedIntrospection = true,
                    Name                    = name,
                    ClaimsRule              = "ClaimRule:" + i,
                    Description             = "Description:" + i,
                    DisplayName             = "DisplayName:" + i,
                    Enabled                 = true,
                    Emphasize               = true,
                    IncludeAllClaimsForUser = true,
                    Required                = true,
                    Type                    = ScopeType.Identity,
                    ScopeSecrets            = new List <Secret>()
                    {
                        new Secret
                        {
                            Type        = "Type1:" + i,
                            Description = "Decription1:" + i,
                            Expiration  = DateTimeOffset.UtcNow,
                            Value       = "Value1:" + i
                        },
                        new Secret
                        {
                            Type        = "Type2:" + i,
                            Description = "Decription2:" + i,
                            Expiration  = DateTimeOffset.UtcNow,
                            Value       = "Value2:" + i
                        }
                    },
                    ShowInDiscoveryDocument = true,
                    Claims = new List <ScopeClaim>()
                    {
                        new ScopeClaim
                        {
                            AlwaysIncludeInIdToken = true,
                            Description            = "Decription1:" + i,
                            Name = "Name1:" + i
                        },
                        new ScopeClaim
                        {
                            AlwaysIncludeInIdToken = true,
                            Description            = "Decription2:" + i,
                            Name = "Name2:" + i
                        }
                    }
                };
                var scopeRecord = new FlattenedScopeRecord(new FlattenedScopeHandle(record));
                await dao.UpsertScopeAsync(scopeRecord);

                result.Add(scopeRecord);
            }
            //   await dao.UpsertManyScopeAsync(result);
            return(result);
        }
Esempio n. 4
0
        public async Task <Scope> CreateAsync(int i)
        {
            var dao = new IdentityServer3CassandraDao();
            await dao.EstablishConnectionAsync();

            var name = Guid.NewGuid().ToString();

            global::IdentityServer3.Core.Models.Scope record = new global::IdentityServer3.Core.Models.Scope()
            {
                AllowUnrestrictedIntrospection = true,
                Name                    = name,
                ClaimsRule              = "ClaimRule:" + i,
                Description             = "Description:" + i,
                DisplayName             = "DisplayName:" + i,
                Enabled                 = true,
                Emphasize               = true,
                IncludeAllClaimsForUser = true,
                Required                = true,
                Type                    = ScopeType.Identity,
                ScopeSecrets            = new List <Secret>()
                {
                    new Secret
                    {
                        Type        = "Type1:" + i,
                        Description = "Decription1:" + i,
                        Expiration  = DateTimeOffset.UtcNow,
                        Value       = "Value1:" + i
                    },
                    new Secret
                    {
                        Type        = "Type2:" + i,
                        Description = "Decription2:" + i,
                        Expiration  = DateTimeOffset.UtcNow,
                        Value       = "Value2:" + i
                    }
                },
                ShowInDiscoveryDocument = true,
                Claims = new List <ScopeClaim>()
                {
                    new ScopeClaim
                    {
                        AlwaysIncludeInIdToken = true, Description = "Decription1:" + i,
                        Name = "Name1:" + i
                    },
                    new ScopeClaim
                    {
                        AlwaysIncludeInIdToken = true, Description = "Decription2:" + i,
                        Name = "Name2:" + i
                    }
                }
            };
            var  scopeRecord = new FlattenedScopeRecord(new FlattenedScopeHandle(record));
            Guid id          = scopeRecord.Id;

            var result = await dao.UpsertScopeAsync(scopeRecord);

            Assert.IsTrue(result);

            var result2 = await dao.FindScopeByIdAsync(id);

            Assert.IsNotNull(result2);

            scopeRecord = new FlattenedScopeRecord(new FlattenedScopeHandle(result2));

            Assert.AreEqual(scopeRecord.Record.Name, name);
            Assert.AreEqual(scopeRecord.Id, id);

            var scope = await scopeRecord.Record.GetScopeAsync();

            Assert.AreEqual(record.Claims.Count, scope.Claims.Count);

            var differences = record.Claims.Except(scope.Claims, ScopeClaimComparer.MinimalScopeClaimComparer);

            Assert.IsTrue(!differences.Any());
            return(scope);
        }
Esempio n. 5
0
 public FlattenedScopeHandle(global::IdentityServer3.Core.Models.Scope scope = null)
     : base(scope)
 {
 }