Skip to content
Snippets Groups Projects
Commit dab5df00 authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

switched @Controller to @RestController + frontend should logout using POST...

switched @Controller to @RestController + frontend should logout using POST /logout instead of trying to clear session with own method
parent 6487322e
No related branches found
No related tags found
No related merge requests found
......@@ -23,8 +23,8 @@ package org.hbp.mip;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import org.hbp.mip.utils.HibernateUtil;
import org.hbp.mip.model.User;
import org.hbp.mip.utils.HibernateUtil;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -58,6 +58,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.util.WebUtils;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
......@@ -78,7 +81,6 @@ import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.Principal;
@SpringBootApplication
@RestController
@EnableOAuth2Client
......@@ -161,14 +163,14 @@ public class MIPApplication extends WebSecurityConfigurerAdapter {
return principal;
}
@RequestMapping("/logout")
/*@RequestMapping("/logout")
public void logout(HttpServletResponse response) {
Cookie cookie = new Cookie("user", null);
cookie.setPath("/");
cookie.setMaxAge(0);
response.addCookie(cookie);
}
}*/
@Override
protected void configure(HttpSecurity http) throws Exception {
......@@ -228,6 +230,12 @@ public class MIPApplication extends WebSecurityConfigurerAdapter {
response.addCookie(cookie);
}
}
/*response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Allow-Headers","*");
response.addHeader("Access-Control-Allow-Methods","GET, POST, PUT, OPTIONS");
response.addHeader("Access-Control-Allow-Credentials","true");*/
filterChain.doFilter(request, response);
}
};
......@@ -239,4 +247,14 @@ public class MIPApplication extends WebSecurityConfigurerAdapter {
return repository;
}
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("http://frontend");
}
};
}
}
......@@ -14,7 +14,6 @@ import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.security.Principal;
......@@ -23,7 +22,7 @@ import java.util.List;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Controller
@RestController
@RequestMapping(value = "/articles", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/articles", description = "the articles API")
public class ArticlesApi {
......
......@@ -12,14 +12,14 @@ import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Controller
@RestController
@RequestMapping(value = "/datasets", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/datasets", description = "the datasets API")
public class DatasetsApi {
......
......@@ -10,13 +10,13 @@ import org.hbp.mip.utils.HibernateUtil;
import org.hibernate.Session;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Controller
@RestController
@RequestMapping(value = "/groups", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/groups", description = "the groups API")
public class GroupsApi {
......
......@@ -14,7 +14,6 @@ import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.security.Principal;
......@@ -25,7 +24,7 @@ import java.util.Random;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Controller
@RestController
@RequestMapping(value = "/models", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/models", description = "the models API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-07T07:38:20.227Z")
......
......@@ -6,17 +6,17 @@ import org.hbp.mip.model.Query;
import org.hbp.mip.utils.CSVUtil;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
/**
* Created by mirco on 18.01.16.
*/
@Controller
@RestController
@RequestMapping(value = "/queries/requests", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/queries/requests", description = "the requests API")
public class RequestsApi {
......
......@@ -8,16 +8,16 @@ import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Controller
@RestController
@RequestMapping(value = "/stats", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/stats", description = "the stats API")
public class StatsApi {
......
......@@ -6,10 +6,10 @@ import org.hbp.mip.utils.HibernateUtil;
import org.hibernate.Session;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
......@@ -17,7 +17,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
* Created by mirco on 14.01.16.
*/
@Controller
@RestController
@RequestMapping(value = "/users", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/users", description = "the users API")
public class UsersApi {
......
......@@ -13,18 +13,14 @@ import org.hbp.mip.utils.HibernateUtil;
import org.hibernate.Session;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;
import java.util.LinkedList;
import java.util.List;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Controller
@RestController
@RequestMapping(value = "/variables", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/variables", description = "the variables API")
public class VariablesApi {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment