Skip to content
Snippets Groups Projects
Commit 25fff846 authored by Manuel Spuhler's avatar Manuel Spuhler
Browse files

Reworked Galaxy config

parent d30700ec
No related branches found
No related tags found
No related merge requests found
...@@ -85,4 +85,5 @@ services: ...@@ -85,4 +85,5 @@ services:
galaxy: galaxy:
galaxyUsername: {{ default .Env.GALAXY_USERNAME "admin" }} galaxyUsername: {{ default .Env.GALAXY_USERNAME "admin" }}
galaxyPassword: {{ default .Env.GALAXY_PASSWORD "password" }} galaxyPassword: {{ default .Env.GALAXY_PASSWORD "password" }}
galaxyContext: {{ default .Env.GALAXY_CONTEXT "nativeGalaxy" }}
...@@ -3,11 +3,11 @@ package eu.hbp.mip.controllers; ...@@ -3,11 +3,11 @@ package eu.hbp.mip.controllers;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonObject;
import eu.hbp.mip.configuration.SecurityConfiguration; import eu.hbp.mip.configuration.SecurityConfiguration;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import eu.hbp.mip.model.User; import eu.hbp.mip.model.User;
import eu.hbp.mip.model.UserInfo; import eu.hbp.mip.model.UserInfo;
import eu.hbp.mip.model.StringDtoResponse;
import eu.hbp.mip.repositories.UserRepository; import eu.hbp.mip.repositories.UserRepository;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -31,6 +31,8 @@ public class SecurityApi { ...@@ -31,6 +31,8 @@ public class SecurityApi {
private static final Logger LOGGER = LoggerFactory.getLogger(SecurityApi.class); private static final Logger LOGGER = LoggerFactory.getLogger(SecurityApi.class);
private static final Gson gson = new Gson();
@Autowired @Autowired
private UserInfo userInfo; private UserInfo userInfo;
...@@ -90,17 +92,24 @@ public class SecurityApi { ...@@ -90,17 +92,24 @@ public class SecurityApi {
@Value("#{'${services.galaxy.galaxyPassword:password}'}") @Value("#{'${services.galaxy.galaxyPassword:password}'}")
private String galaxyPassword; private String galaxyPassword;
@Value("#{'${services.galaxy.galaxyContext:nativeGalaxy}'}")
private String galaxyContext;
/** /**
* Get Galaxy Reverse Proxy basic access token. * Get Galaxy Reverse Proxy basic access token.
* *
* @return Return a @{@link ResponseEntity} with the 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) @ResponseStatus(value = HttpStatus.OK)
public ResponseEntity getGalaxyBasicAccessToken(){ public ResponseEntity getGalaxyConfiguration(){
String stringEncoded = Base64.getEncoder().encodeToString((galaxyUsername + ":" + galaxyPassword).getBytes()); 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));
} }
} }
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;
}
}
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