Ejemplo n.º 1
0
        public async Task Test_Create_Page_ByScopeIdAsync()
        {
            var dao = new IdentityServer3CassandraDao();
            await dao.EstablishConnectionAsync();

            await dao.TruncateTablesAsync();

            List <Scope> addedScopes = new List <Scope>();
            int          nNumber     = 100;
            var          adminStore  = new IdentityServer3AdminStore();

            for (int i = 0; i < nNumber; ++i)
            {
                addedScopes.Add(await CreateAsync(nNumber));
            }

            var pageSize = 9;

            byte[] pagingState  = null;
            int    runningCount = 0;

            do
            {
                var items = await adminStore.PageScopesAsync(pageSize, pagingState);

                pagingState   = items.PagingState;
                runningCount += items.Count();
            } while (pagingState != null);
            Assert.AreEqual(100, runningCount);
        }
Ejemplo n.º 2
0
        public async Task <IDSScopePageRecord> PageScopsesAsync(int pageSize, string pagingState)
        {
            var adminStore = new IdentityServer3AdminStore();


            var page = await adminStore.PageScopesAsync(pageSize, null);

            var state  = HttpUtility.UrlEncode(page.PagingState);
            var record = new IDSScopePageRecord()
            {
                CurrentPagingState = HttpUtility.UrlEncode(page.CurrentPagingState),
                PageSize           = pageSize,
                PagingState        = HttpUtility.UrlEncode(page.PagingState),
                Scopes             = page
            };

            return(record);
        }
        // GET: Admin/Home/Manage/5
        public async Task <ActionResult> Scopes(string id, string email)
        {
            // note this is POC.  We need a dynamic ajax page that does paging
            var usm = new UserScopeModel
            {
                AllowedScopes    = new List <UserScopeRecord>(),
                UserScopeRecords = new List <UserScopeRecord>(),
                Email            = email,
                UserId           = id
            };

            var fullUserStore = UserManager.FullUserStore;
            var adminStore    = new IdentityServer3AdminStore();
            var userScopes    = await adminStore.FindScopesByUserAsync(id);

            foreach (var scope in userScopes)
            {
                usm.UserScopeRecords.Add(new UserScopeRecord()
                {
                    Enabled = true, Name = scope
                });
            }
            int pageSize = 100;
            var page     = await adminStore.PageScopesAsync(100, null);

            var state  = HttpUtility.UrlEncode(page.PagingState);
            var record = new IDSScopePageRecord()
            {
                CurrentPagingState = HttpUtility.UrlEncode(page.CurrentPagingState),
                PageSize           = pageSize,
                PagingState        = HttpUtility.UrlEncode(page.PagingState),
                Scopes             = page
            };

            foreach (var scope in page)
            {
                usm.AllowedScopes.Add(new UserScopeRecord()
                {
                    Enabled = false,
                    Name    = scope.Name
                });
            }
            return(View(usm));
        }
Ejemplo n.º 4
0
        // GET: Admin/Scope
        public async Task <ActionResult> Index()
        {
            var adminStore = new IdentityServer3AdminStore();

            int pageSize = 100;
            var page     = await adminStore.PageScopesAsync(100, null);

            var state  = HttpUtility.UrlEncode(page.PagingState);
            var record = new IDSScopePageRecord()
            {
                CurrentPagingState = HttpUtility.UrlEncode(page.CurrentPagingState),
                PageSize           = pageSize,
                PagingState        = HttpUtility.UrlEncode(page.PagingState),
                Scopes             = page
            };


            return(View(record));
        }