Пример #1
0
        private async Task HandleSingleParam(HttpContext context, ConfigurationIdentity clientIdentity)
        {
            switch (context.Request.Method)
            {
            case "GET":
            {
                var clientResourceCatalogue = await archive.GetArchiveConfigCatalogue(clientIdentity);

                await httpResponseFactory.BuildJsonResponse(context, clientResourceCatalogue);

                break;
            }

            case "DELETE":
            {
                if (context.Request.Query.TryGetValue("before", out var pram) && DateTime.TryParse(pram, out var dateParam))
                {
                    await archive.DeleteOldArchiveConfigs(dateParam, clientIdentity);

                    httpResponseFactory.BuildNoContentResponse(context);
                    break;
                }
                httpResponseFactory.BuildNotFoundStatusResponse(context);
                break;
            }

            default:
            {
                httpResponseFactory.BuildMethodNotAcceptedStatusResponse(context);
                break;
            }
            }
        }
Пример #2
0
        private async Task HandleSaveSnapshot(HttpContext context, ConfigServerOptions options)
        {
            if (context.Request.Method != "POST")
            {
                httpResponseFactory.BuildMethodNotAcceptedStatusResponse(context);
                return;
            }

            var command = await context.GetObjectFromJsonBodyAsync <CreateSnapshotCommand>();

            var commmandResult = await commandBus.SubmitAsync(command);

            await httpResponseFactory.BuildResponseFromCommandResult(context, commmandResult);
        }
Пример #3
0
        private async Task GetResourceCatalogue(HttpContext context, ConfigurationIdentity clientIdentity, ConfigServerOptions options)
        {
            if (context.Request.Method != "GET")
            {
                httpResponseFactory.BuildMethodNotAcceptedStatusResponse(context);
                return;
            }
            if (!context.ChallengeClientConfigurator(options, clientIdentity.Client, httpResponseFactory))
            {
                return;
            }
            var clientResourceCatalogue = await resourceStore.GetResourceCatalogue(clientIdentity);

            await httpResponseFactory.BuildJsonResponse(context, clientResourceCatalogue);
        }
 private bool CheckMethodAndAuthentication(HttpContext context, ConfigServerOptions options)
 {
     if (context.Request.Method == "GET")
     {
         return(context.ChallengeUser(options.ClientAdminClaimType, new HashSet <string>(new[] { ConfigServerConstants.AdminClaimValue, ConfigServerConstants.ConfiguratorClaimValue }, StringComparer.OrdinalIgnoreCase), options.AllowManagerAnomynousAccess, httpResponseFactory));
     }
     else if (context.Request.Method == "POST")
     {
         return(context.ChallengeUser(options.ClientAdminClaimType, new HashSet <string>(new[] { ConfigServerConstants.AdminClaimValue }, StringComparer.OrdinalIgnoreCase), options.AllowManagerAnomynousAccess, httpResponseFactory));
     }
     else
     {
         httpResponseFactory.BuildMethodNotAcceptedStatusResponse(context);
         return(false);;
     }
 }
        public async Task Handle(HttpContext context, ConfigServerOptions options)
        {
            // /{ Client Id}/{ config name}
            // GET: Gets Config model for editor
            // POST: Sets Config from editor model
            if (!CheckMethodAndAuthentication(context, options))
            {
                return;
            }

            var pathParams = context.ToPathParams();

            if (pathParams.Length != 2)
            {
                httpResponseFactory.BuildNotFoundStatusResponse(context);
                return;
            }

            var client = await configClientService.GetClientOrDefault(pathParams[0]);

            if (!context.ChallengeClientConfigurator(options, client, httpResponseFactory))
            {
                return;
            }

            switch (context.Request.Method)
            {
            case "GET":
                await HandleGetRequest(context, client, pathParams[1]);

                break;

            case "POST":
                await HandlePostRequest(context, client, pathParams[1]);

                break;

            default:
                httpResponseFactory.BuildMethodNotAcceptedStatusResponse(context);
                break;
            }
            return;
        }
Пример #6
0
 private bool CheckMethodAndAuthentication(HttpContext context, ConfigServerOptions options)
 {
     if (context.Request.Method == "GET")
     {
         return(context.ChallengeAuthentication(options.AllowAnomynousAccess, httpResponseFactory));
     }
     else
     {
         httpResponseFactory.BuildMethodNotAcceptedStatusResponse(context);
         return(false);
     }
 }
Пример #7
0
 private bool CheckMethodAndAuthentication(HttpContext context, ConfigServerOptions options)
 {
     if (context.Request.Method == "GET")
     {
         return(true);
     }
     else
     {
         httpResponseFactory.BuildMethodNotAcceptedStatusResponse(context);
         return(false);
     }
 }
        public async Task Handle(HttpContext context, ConfigServerOptions options)
        {
            var param = context.ToPathParams();

            if (param.Length != 0)
            {
                httpResponseFactory.BuildNotFoundStatusResponse(context);
            }
            else if (context.Request.Method != "POST")
            {
                httpResponseFactory.BuildMethodNotAcceptedStatusResponse(context);
            }
            else
            {
                await httpResponseFactory.BuildJsonResponse(context, Guid.NewGuid());
            }
        }
Пример #9
0
        public async Task Handle(HttpContext context, ConfigServerOptions options)
        {
            if (context.Request.Method != "GET")
            {
                httpResponseFactory.BuildMethodNotAcceptedStatusResponse(context);
                return;
            }

            var permissions = GetPermissionFromPrincipal(context.User, options);
            var pathParams  = context.ToPathParams();

            if (pathParams.Length == 0)
            {
                await httpResponseFactory.BuildJsonResponse(context, permissions);
            }
            else
            {
                var client = await clientService.GetClientOrDefault(pathParams[0]);

                var clientPermission = MapToClientPermission(permissions, client);
                await httpResponseFactory.BuildJsonResponse(context, clientPermission);
            }
        }