Beispiel #1
0
        public ActionResult Authorize([FromBody] ExistingKeyRequest body)
        {
            var key = body.Key;

            if (!_authService.IsKeyValid(key))
            {
                throw new Exception("Access key is invalid");
            }

            if (!_databaseClient.ContainsKey(key))
            {
                _databaseClient.AddClient(key);
            }

            return(Ok());
        }
Beispiel #2
0
        public ActionResult PerformQuery([FromBody] QueryRequest body)
        {
            var key = _authService.GetKeyFromHttpContext(_httpContextAccessor.HttpContext);

            if (!_databaseClient.ContainsKey(key))
            {
                throw new Exception("Access key is invalid");
            }

            var result   = _databaseClient.PerformQuery(key, body.Query);
            var response = new QueryResponse()
            {
                Result = result
            };

            return(Ok(response));
        }