use of com.yahoo.elide.spring.security.AuthenticationUser in project elide by yahoo.
the class JsonApiController method elideGet.
@GetMapping(value = "/**", produces = JSON_API_CONTENT_TYPE)
public Callable<ResponseEntity<String>> elideGet(@RequestHeader HttpHeaders requestHeaders, @RequestParam MultiValueMap<String, String> allRequestParams, HttpServletRequest request, Authentication authentication) {
final String apiVersion = HeaderUtils.resolveApiVersion(requestHeaders);
final Map<String, List<String>> requestHeadersCleaned = HeaderUtils.lowercaseAndRemoveAuthHeaders(requestHeaders);
final String pathname = getJsonApiPath(request, settings.getJsonApi().getPath());
final User user = new AuthenticationUser(authentication);
final String baseUrl = getBaseUrlEndpoint();
return new Callable<ResponseEntity<String>>() {
@Override
public ResponseEntity<String> call() throws Exception {
ElideResponse response = elide.get(baseUrl, pathname, convert(allRequestParams), requestHeadersCleaned, user, apiVersion, UUID.randomUUID());
return ResponseEntity.status(response.getResponseCode()).body(response.getBody());
}
};
}
use of com.yahoo.elide.spring.security.AuthenticationUser in project elide by yahoo.
the class GraphqlController method post.
/**
* Single entry point for GraphQL requests.
*
* @param requestHeaders request headers
* @param graphQLDocument post data as json document
* @param principal The user principal
* @return response
*/
@PostMapping(value = { "/**", "" }, consumes = JSON_CONTENT_TYPE, produces = JSON_CONTENT_TYPE)
public Callable<ResponseEntity<String>> post(@RequestHeader HttpHeaders requestHeaders, @RequestBody String graphQLDocument, Authentication principal) {
final User user = new AuthenticationUser(principal);
final String apiVersion = HeaderUtils.resolveApiVersion(requestHeaders);
final Map<String, List<String>> requestHeadersCleaned = HeaderUtils.lowercaseAndRemoveAuthHeaders(requestHeaders);
final QueryRunner runner = runners.getRunner(apiVersion);
final String baseUrl = getBaseUrlEndpoint();
return new Callable<ResponseEntity<String>>() {
@Override
public ResponseEntity<String> call() throws Exception {
ElideResponse response;
if (runner == null) {
response = buildErrorResponse(mapper, new InvalidOperationException("Invalid API Version"), false);
} else {
Elide elide = runner.getElide();
response = runner.run(baseUrl, graphQLDocument, user, UUID.randomUUID(), requestHeadersCleaned);
}
return ResponseEntity.status(response.getResponseCode()).body(response.getBody());
}
};
}
use of com.yahoo.elide.spring.security.AuthenticationUser in project elide by yahoo.
the class JsonApiController method elidePost.
@PostMapping(value = "/**", consumes = JSON_API_CONTENT_TYPE, produces = JSON_API_CONTENT_TYPE)
public Callable<ResponseEntity<String>> elidePost(@RequestHeader HttpHeaders requestHeaders, @RequestParam MultiValueMap<String, String> allRequestParams, @RequestBody String body, HttpServletRequest request, Authentication authentication) {
final String apiVersion = HeaderUtils.resolveApiVersion(requestHeaders);
final Map<String, List<String>> requestHeadersCleaned = HeaderUtils.lowercaseAndRemoveAuthHeaders(requestHeaders);
final String pathname = getJsonApiPath(request, settings.getJsonApi().getPath());
final User user = new AuthenticationUser(authentication);
final String baseUrl = getBaseUrlEndpoint();
return new Callable<ResponseEntity<String>>() {
@Override
public ResponseEntity<String> call() throws Exception {
ElideResponse response = elide.post(baseUrl, pathname, body, convert(allRequestParams), requestHeadersCleaned, user, apiVersion, UUID.randomUUID());
return ResponseEntity.status(response.getResponseCode()).body(response.getBody());
}
};
}
use of com.yahoo.elide.spring.security.AuthenticationUser in project elide by yahoo.
the class JsonApiController method elideDeleteRelation.
@DeleteMapping(value = "/**", consumes = JSON_API_CONTENT_TYPE)
public Callable<ResponseEntity<String>> elideDeleteRelation(@RequestHeader HttpHeaders requestHeaders, @RequestParam MultiValueMap<String, String> allRequestParams, @RequestBody String body, HttpServletRequest request, Authentication authentication) {
final String apiVersion = HeaderUtils.resolveApiVersion(requestHeaders);
final Map<String, List<String>> requestHeadersCleaned = HeaderUtils.lowercaseAndRemoveAuthHeaders(requestHeaders);
final String pathname = getJsonApiPath(request, settings.getJsonApi().getPath());
final User user = new AuthenticationUser(authentication);
final String baseUrl = getBaseUrlEndpoint();
return new Callable<ResponseEntity<String>>() {
@Override
public ResponseEntity<String> call() throws Exception {
ElideResponse response = elide.delete(baseUrl, pathname, body, convert(allRequestParams), requestHeadersCleaned, user, apiVersion, UUID.randomUUID());
return ResponseEntity.status(response.getResponseCode()).body(response.getBody());
}
};
}
use of com.yahoo.elide.spring.security.AuthenticationUser in project elide by yahoo.
the class JsonApiController method elidePatch.
@PatchMapping(value = "/**", consumes = { JSON_API_CONTENT_TYPE, JSON_API_PATCH_CONTENT_TYPE })
public Callable<ResponseEntity<String>> elidePatch(@RequestHeader HttpHeaders requestHeaders, @RequestParam MultiValueMap<String, String> allRequestParams, @RequestBody String body, HttpServletRequest request, Authentication authentication) {
final String apiVersion = HeaderUtils.resolveApiVersion(requestHeaders);
final Map<String, List<String>> requestHeadersCleaned = HeaderUtils.lowercaseAndRemoveAuthHeaders(requestHeaders);
final String pathname = getJsonApiPath(request, settings.getJsonApi().getPath());
final User user = new AuthenticationUser(authentication);
final String baseUrl = getBaseUrlEndpoint();
return new Callable<ResponseEntity<String>>() {
@Override
public ResponseEntity<String> call() throws Exception {
ElideResponse response = elide.patch(baseUrl, request.getContentType(), request.getContentType(), pathname, body, convert(allRequestParams), requestHeadersCleaned, user, apiVersion, UUID.randomUUID());
return ResponseEntity.status(response.getResponseCode()).body(response.getBody());
}
};
}
Aggregations