diff --git a/docker/config/application.tmpl b/docker/config/application.tmpl index 3321fea848679a067795142917be5c6b04d22976..e3a624a13a6c1588210c0546923888956fe45a9f 100644 --- a/docker/config/application.tmpl +++ b/docker/config/application.tmpl @@ -85,4 +85,5 @@ services: galaxy: galaxyUsername: {{ default .Env.GALAXY_USERNAME "admin" }} galaxyPassword: {{ default .Env.GALAXY_PASSWORD "password" }} + galaxyContext: {{ default .Env.GALAXY_CONTEXT "nativeGalaxy" }} diff --git a/src/main/java/eu/hbp/mip/controllers/SecurityApi.java b/src/main/java/eu/hbp/mip/controllers/SecurityApi.java index f949f16ac9dea9a422e5494984080cadb10d089b..1f073a270ac69dbb8de75aaed79d1feee8300876 100644 --- a/src/main/java/eu/hbp/mip/controllers/SecurityApi.java +++ b/src/main/java/eu/hbp/mip/controllers/SecurityApi.java @@ -3,11 +3,11 @@ package eu.hbp.mip.controllers; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; +import com.google.gson.JsonObject; import eu.hbp.mip.configuration.SecurityConfiguration; import org.springframework.beans.factory.annotation.Value; import eu.hbp.mip.model.User; import eu.hbp.mip.model.UserInfo; -import eu.hbp.mip.model.StringDtoResponse; import eu.hbp.mip.repositories.UserRepository; import io.swagger.annotations.ApiParam; import org.slf4j.Logger; @@ -31,6 +31,8 @@ public class SecurityApi { private static final Logger LOGGER = LoggerFactory.getLogger(SecurityApi.class); + private static final Gson gson = new Gson(); + @Autowired private UserInfo userInfo; @@ -90,17 +92,24 @@ public class SecurityApi { @Value("#{'${services.galaxy.galaxyPassword:password}'}") private String galaxyPassword; + @Value("#{'${services.galaxy.galaxyContext:nativeGalaxy}'}") + private String galaxyContext; + /** * Get Galaxy Reverse Proxy basic access token. * * @return Return a @{@link ResponseEntity} with the token. */ - @RequestMapping(path = "/galaxy/token", method = RequestMethod.GET, produces = "application/json") + @RequestMapping(path = "/galaxy", method = RequestMethod.GET, produces = "application/json") @ResponseStatus(value = HttpStatus.OK) - public ResponseEntity getGalaxyBasicAccessToken(){ + public ResponseEntity getGalaxyConfiguration(){ String stringEncoded = Base64.getEncoder().encodeToString((galaxyUsername + ":" + galaxyPassword).getBytes()); - return ResponseEntity.ok(new StringDtoResponse(stringEncoded)); + JsonObject object = new JsonObject(); + object.addProperty("authorization", "Basic " + stringEncoded); + object.addProperty("context", galaxyContext); + + return ResponseEntity.ok(gson.toJson(object)); } } diff --git a/src/main/java/eu/hbp/mip/model/StringDtoResponse.java b/src/main/java/eu/hbp/mip/model/StringDtoResponse.java deleted file mode 100644 index 272174d69049155915f0c78476912e882bae2b74..0000000000000000000000000000000000000000 --- a/src/main/java/eu/hbp/mip/model/StringDtoResponse.java +++ /dev/null @@ -1,21 +0,0 @@ -package eu.hbp.mip.model; - -public class StringDtoResponse { - - private String response; - - public StringDtoResponse() { - } - - public StringDtoResponse(String response) { - this.response = response; - } - - public String getResponse() { - return response; - } - - public void setResponse(String response) { - this.response = response; - } -}