From 3577c35560c57a872e724d95db218e3ce7bc99d9 Mon Sep 17 00:00:00 2001 From: Gustavo Publio Date: Sat, 6 Jan 2018 05:59:24 +0100 Subject: [PATCH] removed authentication for ws ontologyUpload and fixed ajax request headers --- guidelines/web/js/app.js | 9 ++++++--- .../webservice/authapi/SecurityConstants.java | 1 + .../ontologytracker/webservice/authapi/WebSecurity.java | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/guidelines/web/js/app.js b/guidelines/web/js/app.js index 5d3a255..d9a65fc 100644 --- a/guidelines/web/js/app.js +++ b/guidelines/web/js/app.js @@ -187,19 +187,22 @@ function ($) { }); let startUpload = function (ontology, shacl) { - $("#upload-progress").show("slow"); + //$("#upload-progress").show("slow"); //let file = files[0]; let formData = new FormData(); formData.append("ontology", ontology); formData.append("shacltest", shacl); + formData.append("format", "text/turtle"); $.ajax({ url: 'http://localhost:8080/ws/users/ontologyUpload', method: 'POST', type: 'POST', data: formData, - contentType: 'text/turtle', + accepts: { "*": "text/turtle" }, + contentType: false, processData: false, + cache: false, xhr: function () { let xhr = new window.XMLHttpRequest(); xhr.upload.addEventListener("progress", @@ -281,7 +284,7 @@ jQuery(function ($) { SHACL_tests_group = ` - gdl-shape: ${groups[index].shape} + gdl-shape:${groups[index].shape} a sh:Shape; `; diff --git a/src/main/java/org/dbpedia/ontologytracker/webservice/authapi/SecurityConstants.java b/src/main/java/org/dbpedia/ontologytracker/webservice/authapi/SecurityConstants.java index 762b059..ac0aa99 100644 --- a/src/main/java/org/dbpedia/ontologytracker/webservice/authapi/SecurityConstants.java +++ b/src/main/java/org/dbpedia/ontologytracker/webservice/authapi/SecurityConstants.java @@ -8,4 +8,5 @@ public class SecurityConstants { public static final String HEADER_STRING = "Authorization"; public static final String SIGN_UP_URL = "/ws/users/sign-up"; public static final String PUBLIC_ONTOLOGY = "/ws/ontology"; + public static final String ONTOLOGY_UPLOAD = "/ws/users/ontologyUpload"; } \ No newline at end of file diff --git a/src/main/java/org/dbpedia/ontologytracker/webservice/authapi/WebSecurity.java b/src/main/java/org/dbpedia/ontologytracker/webservice/authapi/WebSecurity.java index d681755..d7a6eca 100644 --- a/src/main/java/org/dbpedia/ontologytracker/webservice/authapi/WebSecurity.java +++ b/src/main/java/org/dbpedia/ontologytracker/webservice/authapi/WebSecurity.java @@ -13,6 +13,7 @@ import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.context.annotation.Bean; +import static org.dbpedia.ontologytracker.webservice.authapi.SecurityConstants.ONTOLOGY_UPLOAD; import static org.dbpedia.ontologytracker.webservice.authapi.SecurityConstants.PUBLIC_ONTOLOGY; import static org.dbpedia.ontologytracker.webservice.authapi.SecurityConstants.SIGN_UP_URL; @@ -32,6 +33,7 @@ protected void configure(HttpSecurity http) throws Exception { http.cors().and().csrf().disable().authorizeRequests() .antMatchers(HttpMethod.POST, SIGN_UP_URL).permitAll() .antMatchers(HttpMethod.POST, PUBLIC_ONTOLOGY).permitAll() + .antMatchers(HttpMethod.POST, ONTOLOGY_UPLOAD).permitAll() .anyRequest().authenticated() .and() .addFilter(new JWTAuthenticationFilter(authenticationManager()))