Exemplo n.º 1
0
        public async Task <IActionResult> OnGetAsync(int apiResourceId, int id)
        {
            TenantId      = _sessionTenantAccessor.TenantId;
            ApiResourceId = apiResourceId;


            Entity = await _adminServices.GetApiResourceByIdAsync(TenantId, ApiResourceId);

            var scopeEntity = Entity.Scopes.FirstOrDefault(x => x.Id == id);

            if (scopeEntity == null)
            {
                return(RedirectToPage("../Index", new { id = ApiResourceId }));
            }

            var subScope = scopeEntity.Scope.Substring(Entity.Name.Length + 1);

            Input = new InputModel()
            {
                Id          = id,
                PrependName = Entity.Name,
                Scope       = subScope
            };
            return(Page());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            TenantId = _sessionTenantAccessor.TenantId;
            Entity   = await _adminServices.GetApiResourceByIdAsync(TenantId, id);

            if (Entity == null)
            {
                return(RedirectToPage("../Index"));
            }
            Input = new InputModel()
            {
                Id = Entity.Id
            };
            return(Page());
        }
Exemplo n.º 3
0
        public async Task <ApiResource> GetApiResource(String apiResourceName,
                                                       CancellationToken cancellationToken)
        {
            ApiResource apiResourceModel = null;

            Duende.IdentityServer.EntityFramework.Entities.ApiResource apiResourceEntity = await this.ConfigurationDbContext.ApiResources.Where(a => a.Name == apiResourceName)
                                                                                           .Include(a => a.Scopes).Include(a => a.UserClaims)
                                                                                           .SingleOrDefaultAsync(cancellationToken: cancellationToken);

            if (apiResourceEntity == null)
            {
                throw new NotFoundException($"No Api Resource found with Name [{apiResourceName}]");
            }

            apiResourceModel = apiResourceEntity.ToModel();

            return(apiResourceModel);
        }
Exemplo n.º 4
0
 public async Task <IActionResult> OnPostAsync()
 {
     try
     {
         var entity = new Duende.IdentityServer.EntityFramework.Entities.ApiResource()
         {
             Id          = Input.Id,
             Name        = Input.Name,
             Description = Input.Description,
             Enabled     = Input.Enabled
         };
         await _adminServices.UpsertApiResourceAsync(TenantId, entity);
     }
     catch (Exception ex)
     {
         ModelState.AddModelError(string.Empty, ex.Message);
         return(Page());
     }
     return(RedirectToPage("./Index", new { id = Input.Id }));
 }
Exemplo n.º 5
0
 public async Task OnGetAsync(int id)
 {
     TenantId = _sessionTenantAccessor.TenantId;
     Entity   = await _adminServices.GetApiResourceByIdAsync(TenantId, id);
 }