public CallbackController(DbContext.DatabaseContext dbContext, ILogger <JiraExporterController> logger, ILoggingService remoteLogger
                           , IAppJiraCloudExporterCli client)
 {
     _dbContext    = dbContext;
     _logger       = logger;
     _remoteLogger = remoteLogger;
     _client       = client;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Method returns Exercise 3 action view
 /// </summary>
 /// <returns></returns>
 public ActionResult Exercise3()
 {
     using (DbContext.DatabaseContext context = new DbContext.DatabaseContext())
     {
         var cars = context.Car.ToList();
         return(View(cars));
     }
 }
Exemplo n.º 3
0
 public JiraExporterController(DbContext.DatabaseContext dbContext, ILogger <JiraExporterController> logger, IWebHostEnvironment hostEnvironment
                               , IConfiguration configuration, Services.IAppJiraCloudExporterCli client, IBasePathReplacement basePathReplacement, IHttpClientFactory clientFactory)
 {
     _dbContext           = dbContext;
     _logger              = logger;
     _hostEnvironment     = hostEnvironment;
     _configuration       = configuration;
     _client              = client;
     _basePathReplacement = basePathReplacement;
     _clientFactory       = clientFactory;
 }
        public async Task InvokeAsync(HttpContext context, DbContext.DatabaseContext dbContext, IAppJiraCloudExporterCli client)
        {
            client.RegistrationData = null;
            try
            {
                var requestValidation = new RequestValidation(context.Request);
                if (requestValidation.TokenExists)
                {
                    var registrationData = dbContext.ClientRegistration.FirstOrDefault(r =>
                                                                                       r.Key == client.AtlassianAppKey && r.ClientKey == requestValidation.ClientKey
                                                                                       );
                    // if registration data is not found and it is allowed for the request to be unauthorized, pass it through
                    if (default(Model.ClientRegistration) == registrationData && _options.TokenRequired)
                    {
                        throw new Exception($"Unregistered client {requestValidation.ClientKey}");
                    }

                    // if registration data is found, request has to be authorized
                    if (default(Model.ClientRegistration) != registrationData &&
                        requestValidation.Validate(registrationData))
                    {
                        client.RegistrationData = registrationData;
                    }
                }
                else if (_options.TokenRequired)
                {
                    throw new Exception($"No token");
                }
            }
            catch (Exception ex)
            {
                if (_options.ThrowException)
                {
                    throw;
                }
                client.AuthException = ex;
            }

            await _next(context);
        }