-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/IM-459-New-Configure-keycloak-in…
…-remote-engine' into IM-457-Merge-develop-in-IM-384
- Loading branch information
Showing
11 changed files
with
305 additions
and
83 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...tegratedmodelling.klab.api/src/org/integratedmodelling/klab/api/auth/KlabHttpHeaders.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.integratedmodelling.klab.api.auth; | ||
|
||
/** | ||
* Defines constants for common HTTP headers. | ||
* | ||
* <p>This interface provides a set of predefined header names used | ||
* in HTTP requests and responses. These constants can be used to | ||
* avoid hardcoding string values and reduce errors.</p> | ||
* | ||
* @author Kristina | ||
*/ | ||
|
||
public interface KlabHttpHeaders { | ||
|
||
/** | ||
* Designed to send session information with requests. | ||
**/ | ||
public static final String KLAB_AUTHORIZATION = "Klab_Authorization"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
klab.engine/src/main/java/org/integratedmodelling/klab/engine/rest/api/EngineProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.integratedmodelling.klab.engine.rest.api; | ||
|
||
import javax.validation.constraints.NotEmpty; | ||
|
||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.validation.annotation.Validated; | ||
|
||
@Component | ||
@ConfigurationProperties("engine") | ||
public class EngineProperties { | ||
|
||
public EnvProperties env; | ||
|
||
public EnvProperties getEnv() { | ||
return env; | ||
} | ||
|
||
public void setEnv(EnvProperties env) { | ||
this.env = env; | ||
} | ||
|
||
@Validated | ||
public static class EnvProperties { | ||
|
||
@NotEmpty | ||
private String appBaseUrl; | ||
|
||
@NotEmpty | ||
private String keycloakUrl; | ||
|
||
public String getAppBaseUrl() { | ||
return appBaseUrl; | ||
} | ||
|
||
public void setAppBaseUrl(String appBaseUrl) { | ||
this.appBaseUrl = appBaseUrl; | ||
} | ||
|
||
public String getKeycloakUrl() { | ||
return keycloakUrl; | ||
} | ||
|
||
public void setKeycloakUrl(String keycloakUrl) { | ||
this.keycloakUrl = keycloakUrl; | ||
} | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
...java/org/integratedmodelling/klab/engine/rest/controllers/base/EnvironmentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.integratedmodelling.klab.engine.rest.controllers.base; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.integratedmodelling.klab.engine.rest.api.EngineProperties; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
@RestController | ||
public class EnvironmentController { | ||
|
||
@Autowired | ||
private EngineProperties engineProperties; | ||
|
||
private static final String APP_BASE_URL = "APP_BASE_URL"; | ||
private static final String KEYCLOAK_URL = "KEYCLOAK_URL"; | ||
|
||
@GetMapping(value = "/engine/environments") | ||
public void getEnvironmentVariables(HttpServletRequest request, HttpServletResponse response) throws IOException { | ||
|
||
response.setContentType("text/javascript;utf-8"); | ||
|
||
Map<String, String> kHubEnvironmentVariables = Map.ofEntries(Map.entry(APP_BASE_URL, engineProperties.env.getAppBaseUrl()), | ||
Map.entry(KEYCLOAK_URL, engineProperties.env.getKeycloakUrl())); | ||
|
||
ObjectMapper objectMapper = new ObjectMapper(); | ||
String jsonValue = objectMapper.writeValueAsString(kHubEnvironmentVariables); | ||
|
||
System.out.println(jsonValue); | ||
|
||
response.getWriter().append("var __ENV__= " + jsonValue + ";"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.