Loading src/main/java/es/redmic/user/config/Oauth2SecurityConfiguration.java +0 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,6 @@ public class Oauth2SecurityConfiguration { http.cors().and().anonymous().and().authorizeRequests().antMatchers("/user/actuator/**").permitAll() .antMatchers(HttpMethod.GET, "/user/profile/").permitAll() .antMatchers(HttpMethod.GET, "/user/modules/openmodules/").permitAll() .antMatchers(HttpMethod.GET, "/user/superset/get-token/**").permitAll() .antMatchers(HttpMethod.POST, "/user/register/**/").permitAll() .antMatchers(HttpMethod.POST, "/user/feedback/").permitAll() .antMatchers(HttpMethod.POST, "/user/profile/resettingRequest/**/").permitAll() Loading src/main/java/es/redmic/user/embedded/controller/SupersetEmbeddedController.javadeleted 100644 → 0 +0 −50 Original line number Diff line number Diff line package es.redmic.user.embedded.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; /*- * #%L * User * %% * Copyright (C) 2025 REDMIC Project / Server * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #L% */ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import es.redmic.user.embedded.service.SupersetEmbeddedService; @RestController @RequestMapping(value = "${controller.mapping.SUPERSET_EMBEDDED}") public class SupersetEmbeddedController { SupersetEmbeddedService service; public SupersetEmbeddedController(SupersetEmbeddedService service) { this.service = service; } @GetMapping(value = "/get-token/{dashboardid}") public Object getToken(@PathVariable("dashboardid") String dashboardid, @RequestParam(value = "token", required = true) String jwtToken) { return service.getGuestToken(dashboardid, jwtToken); } } src/main/java/es/redmic/user/embedded/service/SupersetEmbeddedService.javadeleted 100644 → 0 +0 −84 Original line number Diff line number Diff line package es.redmic.user.embedded.service; import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; import es.redmic.user.manager.service.UserProfileService; /*- * #%L * User * %% * Copyright (C) 2025 REDMIC Project / Server * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #L% */ @Service public class SupersetEmbeddedService { @Value("${property.SUPERSET_API_URL}") private String supersetApiUrl; @Value("${property.SUPERSET_API_BASE_PATH}") private String supersetApiBasePath; @Autowired UserProfileService userProfileService; List<MediaType> acceptableMediaTypes = new ArrayList<>(); public SupersetEmbeddedService() { acceptableMediaTypes.add(MediaType.APPLICATION_JSON); } public Object getGuestToken(String dashboardid, String jwtToken) { String url = supersetApiUrl + supersetApiBasePath + "guest_token/"; String username = userProfileService.getUsername(); RestTemplate restTemplate = new RestTemplate(); String body = "{\"resources\": [{\"id\": \"" + dashboardid + "\", \"type\": \"dashboard\"}], \"rls\": [], \"user\": {\"username\": \"" + username + "\"}}"; HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); headers.setAccept(acceptableMediaTypes); headers.set(HttpHeaders.REFERER, supersetApiUrl); headers.set(HttpHeaders.AUTHORIZATION, "Bearer " + jwtToken); HttpEntity<String> request = new HttpEntity<>(body, headers); String response; try { response = restTemplate.postForObject(url, request, String.class); } catch (org.springframework.web.client.HttpClientErrorException e) { // Error 4xx System.err.println("Response Body: " + e.getResponseBodyAsString()); throw new RuntimeException("Client error when requesting guest token: " + e.getStatusCode(), e); } return response; } } src/main/resources/application-dev.properties +0 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,4 @@ oauth.server=http://oauth:8081 spring.datasource.name=redmic spring.datasource.url=jdbc:postgresql://db:5432/redmic?currentSchema=app property.SUPERSET_API_URL=https://superset.ecomarcan.grafcan.es logging.level.es.redmic=debug src/main/resources/application-pre.properties +0 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,4 @@ oauth.server=http://oauth:8081 spring.datasource.name=redmic spring.datasource.url=jdbc:postgresql://db:5432/redmic?currentSchema=app property.SUPERSET_API_URL=https://superset.ecomarcan.grafcan.es logging.level.es.redmic=warn Loading
src/main/java/es/redmic/user/config/Oauth2SecurityConfiguration.java +0 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,6 @@ public class Oauth2SecurityConfiguration { http.cors().and().anonymous().and().authorizeRequests().antMatchers("/user/actuator/**").permitAll() .antMatchers(HttpMethod.GET, "/user/profile/").permitAll() .antMatchers(HttpMethod.GET, "/user/modules/openmodules/").permitAll() .antMatchers(HttpMethod.GET, "/user/superset/get-token/**").permitAll() .antMatchers(HttpMethod.POST, "/user/register/**/").permitAll() .antMatchers(HttpMethod.POST, "/user/feedback/").permitAll() .antMatchers(HttpMethod.POST, "/user/profile/resettingRequest/**/").permitAll() Loading
src/main/java/es/redmic/user/embedded/controller/SupersetEmbeddedController.javadeleted 100644 → 0 +0 −50 Original line number Diff line number Diff line package es.redmic.user.embedded.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; /*- * #%L * User * %% * Copyright (C) 2025 REDMIC Project / Server * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #L% */ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import es.redmic.user.embedded.service.SupersetEmbeddedService; @RestController @RequestMapping(value = "${controller.mapping.SUPERSET_EMBEDDED}") public class SupersetEmbeddedController { SupersetEmbeddedService service; public SupersetEmbeddedController(SupersetEmbeddedService service) { this.service = service; } @GetMapping(value = "/get-token/{dashboardid}") public Object getToken(@PathVariable("dashboardid") String dashboardid, @RequestParam(value = "token", required = true) String jwtToken) { return service.getGuestToken(dashboardid, jwtToken); } }
src/main/java/es/redmic/user/embedded/service/SupersetEmbeddedService.javadeleted 100644 → 0 +0 −84 Original line number Diff line number Diff line package es.redmic.user.embedded.service; import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; import es.redmic.user.manager.service.UserProfileService; /*- * #%L * User * %% * Copyright (C) 2025 REDMIC Project / Server * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #L% */ @Service public class SupersetEmbeddedService { @Value("${property.SUPERSET_API_URL}") private String supersetApiUrl; @Value("${property.SUPERSET_API_BASE_PATH}") private String supersetApiBasePath; @Autowired UserProfileService userProfileService; List<MediaType> acceptableMediaTypes = new ArrayList<>(); public SupersetEmbeddedService() { acceptableMediaTypes.add(MediaType.APPLICATION_JSON); } public Object getGuestToken(String dashboardid, String jwtToken) { String url = supersetApiUrl + supersetApiBasePath + "guest_token/"; String username = userProfileService.getUsername(); RestTemplate restTemplate = new RestTemplate(); String body = "{\"resources\": [{\"id\": \"" + dashboardid + "\", \"type\": \"dashboard\"}], \"rls\": [], \"user\": {\"username\": \"" + username + "\"}}"; HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); headers.setAccept(acceptableMediaTypes); headers.set(HttpHeaders.REFERER, supersetApiUrl); headers.set(HttpHeaders.AUTHORIZATION, "Bearer " + jwtToken); HttpEntity<String> request = new HttpEntity<>(body, headers); String response; try { response = restTemplate.postForObject(url, request, String.class); } catch (org.springframework.web.client.HttpClientErrorException e) { // Error 4xx System.err.println("Response Body: " + e.getResponseBodyAsString()); throw new RuntimeException("Client error when requesting guest token: " + e.getStatusCode(), e); } return response; } }
src/main/resources/application-dev.properties +0 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,4 @@ oauth.server=http://oauth:8081 spring.datasource.name=redmic spring.datasource.url=jdbc:postgresql://db:5432/redmic?currentSchema=app property.SUPERSET_API_URL=https://superset.ecomarcan.grafcan.es logging.level.es.redmic=debug
src/main/resources/application-pre.properties +0 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,4 @@ oauth.server=http://oauth:8081 spring.datasource.name=redmic spring.datasource.url=jdbc:postgresql://db:5432/redmic?currentSchema=app property.SUPERSET_API_URL=https://superset.ecomarcan.grafcan.es logging.level.es.redmic=warn