diff --git a/docs/development/start_and_debug_locally_de.md b/docs/development/start_and_debug_locally_de.md new file mode 100644 index 00000000..4af74e65 --- /dev/null +++ b/docs/development/start_and_debug_locally_de.md @@ -0,0 +1,26 @@ +# Smeagol lokal starten +Im folgenden wird beschrieben, wie Smeagol lokal ausgeführt werden kann. +Dennoch ist dafür ein lokales EcoSystem mit einem lauffähigen SCM-Manager notwendig. +Außerdem muss der CAS in die development-Stage gebracht werden. +Dafür folgendes ausführen: `etcdctl set config/_global/stage development && docker restart cas` + + +## 1. Frontend starten +* Sicherstellen dass die installierte Node-Version kleiner als 18 ist. Mit Node 16 wurde es erfolgreich getestet. +* Aus dem Root-Ordner des Repositories folgendes ausführen: `node src/main/scripts/start.js` + + +## 2. Backend starten +* Beim SCM-Manager ein API-Token erstellen: `https://192.168.56.2/scm/me/settings/apiKeys` +* Den API-Key kopieren und in die application.yml unter `src/main/resources` eintragen + +Beispiel: +``` +scm: + url: https://192.168.56.2/scm + accessKey: eyJhcGlLZXlJZCI6IjVFVFp5ZUNlckEiLCJ1c2VyIjoiYWRtaW4iLCJwYXNzcGhyYXNlIjoieDFodXliWkhIaWpuTnNoNFlqQngifQ +``` + +* Mit `./mvwnw spring-boot:run` bzw `mvn spring-boot:run` Smeagol starten - Applikation läuft nun. +* Alternativ kann Smeagol auch einfach über die IDE gestartet werden. Die Konfiguration dafür sollte automatisch angelegt worden sein. + diff --git a/docs/development/start_and_debug_locally_en.md b/docs/development/start_and_debug_locally_en.md new file mode 100644 index 00000000..cc645f48 --- /dev/null +++ b/docs/development/start_and_debug_locally_en.md @@ -0,0 +1,25 @@ +# Start Smeagol locally +The following describes how to run Smeagol locally. +However, this requires a local EcoSystem with a running SCM manager. +In addition, the CAS must be brought into the development stage. +To do this, execute the following: `etcdctl set config/_global/stage development && docker restart cas`. + + +## 1. start frontend +* Make sure that the installed node version is lower than 18. With Node 16 it was tested successfully. +* From the root folder of the repository execute: `node src/main/scripts/start.js`. + + +## 2. start backend +* Create an API token at the SCM manager: `https://192.168.56.2/scm/me/settings/apiKeys`. +* Copy the API key and add it to the application.yml under `src/main/resources`. + +Example: +``` +scm: + url: https://192.168.56.2/scm + accessKey: eyJhcGlLZXlJZCI6IjVFVFp5ZUNlckEiLCJ1c2VyIjoiYWRtaW4iLCJwYXNzcGhyYXNlIjoieDFodXliWkhIaWpuTnNoNFlqQngifQ +``` + +* Start Smeagol with `./mvwnw spring-boot:run` or `mvn spring-boot:run` - application is now running. +* Alternatively, Smeagol can also be started simply via the IDE. The configuration for this should have been created automatically. diff --git a/src/main/java/com/cloudogu/smeagol/AccountService.java b/src/main/java/com/cloudogu/smeagol/AccountService.java index b30f1e97..db699ab0 100644 --- a/src/main/java/com/cloudogu/smeagol/AccountService.java +++ b/src/main/java/com/cloudogu/smeagol/AccountService.java @@ -39,14 +39,20 @@ public class AccountService { private final String scmUrl; private final RestTemplate scmRestTemplate; + // For local development purposes only + private final String accessKey; + private static final String ACCESS_TOKEN_ENDPOINT = "/api/v2/cas/auth/"; @Autowired public AccountService(ObjectFactory requestFactory, RestTemplateBuilder restTemplateBuilder, + @Value("${scm.accessKey:#{null}}") String accessKey, @Value("${scm.url}") String scmUrl, Stage stage) { this.scmRestTemplate = createRestTemplate(restTemplateBuilder, stage, scmUrl); this.requestFactory = requestFactory; this.scmUrl = scmUrl; + // For local development purposes only + this.accessKey = accessKey; } /** @@ -98,6 +104,12 @@ private Account getNewAccount(HttpServletRequest request) { } private String getAccessToken(AttributePrincipal principal) { + // Should be used in local development only + if (this.accessKey != null){ + String accessKey = this.accessKey; + return accessKey; + } + String accessTokenEndpointURL = getAccessTokenEndpoint(); String pt = principal.getProxyTicketFor(accessTokenEndpointURL); if (Strings.isNullOrEmpty(pt)) { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 27325db9..ca4e2ec0 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -16,6 +16,8 @@ ui: scm: url: https://192.168.56.2/scm + accessKey: eyJhcGlLZXlJZCI6IjVFVFp5ZUNlckEiLCJ1c2VyIjoiYWRtaW4iLCJwYXNzcGhyYXNlIjoieDFodXliWkhIaWpuTnNoNFlqQngifQ + cas: url: https://192.168.56.2/cas