Skip to content

Commit 6eda280

Browse files
authored
Merge pull request #110 from it-at-m/feature/initial-accept-checklist
Feature/initial accept checklist
2 parents fc513a7 + 18572f1 commit 6eda280

File tree

20 files changed

+333
-64
lines changed

20 files changed

+333
-64
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package de.muenchen.dbs.personalization.configuration;
2+
3+
import jakarta.validation.constraints.NotBlank;
4+
import lombok.Data;
5+
import org.springframework.boot.context.properties.ConfigurationProperties;
6+
import org.springframework.context.annotation.Profile;
7+
import org.springframework.validation.annotation.Validated;
8+
9+
@ConfigurationProperties(prefix = "p13n")
10+
@Validated
11+
@Profile("!no-security")
12+
@Data
13+
public class P13nConfiguration {
14+
/**
15+
* ServiceNavigator API URL.
16+
*/
17+
@NotBlank
18+
private String serviceNavigatorUrl = "https://stadt.muenchen.de/service/rs/befi/navigator";
19+
20+
/**
21+
* (optional) Proxy Host used to call ServiceNavigator.
22+
*/
23+
private String proxyHost = null;
24+
25+
/**
26+
* (optional) Proxy Port used to call ServiceNavigator.
27+
*/
28+
private int proxyPort = 80;
29+
30+
}

personalization-service/src/main/java/de/muenchen/dbs/personalization/configuration/SecurityConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public SecurityFilterChain filterChain(final HttpSecurity http) throws Exception
5252
// allow access to swagger-ui
5353
PathPatternRequestMatcher.withDefaults().matcher(HttpMethod.GET, "/swagger-ui/**"),
5454
// allow access to /actuator/metrics for Prometheus monitoring in OpenShift
55-
PathPatternRequestMatcher.withDefaults().matcher(HttpMethod.GET, "/actuator/metrics"))
55+
PathPatternRequestMatcher.withDefaults().matcher(HttpMethod.GET, "/actuator/metrics"),
56+
PathPatternRequestMatcher.withDefaults().matcher(HttpMethod.GET, "/public/**"))
5657
.permitAll())
5758
.authorizeHttpRequests((requests) -> requests.requestMatchers("/**")
5859
.authenticated())
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package de.muenchen.dbs.personalization.servicenavigator;
2+
3+
import de.muenchen.dbs.personalization.configuration.P13nConfiguration;
4+
import io.swagger.v3.oas.annotations.Operation;
5+
import io.swagger.v3.oas.annotations.tags.Tag;
6+
import java.net.InetSocketAddress;
7+
import java.net.Proxy;
8+
import java.util.List;
9+
import lombok.RequiredArgsConstructor;
10+
import lombok.extern.slf4j.Slf4j;
11+
import org.apache.commons.lang3.StringUtils;
12+
import org.springframework.beans.factory.annotation.Autowired;
13+
import org.springframework.http.HttpStatus;
14+
import org.springframework.http.ResponseEntity;
15+
import org.springframework.http.client.SimpleClientHttpRequestFactory;
16+
import org.springframework.web.bind.annotation.GetMapping;
17+
import org.springframework.web.bind.annotation.RequestMapping;
18+
import org.springframework.web.bind.annotation.RequestParam;
19+
import org.springframework.web.bind.annotation.ResponseStatus;
20+
import org.springframework.web.bind.annotation.RestController;
21+
import org.springframework.web.client.RestTemplate;
22+
23+
@RestController
24+
@RequestMapping("/public/servicenavigator")
25+
@Slf4j
26+
@RequiredArgsConstructor
27+
@Tag(name = "Public ServiceNavigator Endpoints", description = "Endpoints not requiring authentication")
28+
public class PublicServiceNavigatorController {
29+
30+
private static final String SERVICENAVIGATOR_QUERY_PARAMETER_ID = "?id=";
31+
32+
private final RestTemplate restTemplate;
33+
private final P13nConfiguration p13nConfiguration;
34+
35+
@Autowired
36+
public PublicServiceNavigatorController(final P13nConfiguration p13nConfiguration) {
37+
this.p13nConfiguration = p13nConfiguration;
38+
39+
if (StringUtils.isBlank(p13nConfiguration.getProxyHost())) {
40+
this.restTemplate = new RestTemplate();
41+
} else {
42+
final Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(p13nConfiguration.getProxyHost(), p13nConfiguration.getProxyPort()));
43+
final SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
44+
requestFactory.setProxy(proxy);
45+
this.restTemplate = new RestTemplate(requestFactory);
46+
}
47+
}
48+
49+
@GetMapping
50+
@Operation(summary = "Lookup ServiceNavigator Services by ServiceID. Returns a list of services for the given service IDs.")
51+
@ResponseStatus(HttpStatus.OK)
52+
public List<Object> getServicesByIds(@RequestParam("ids") final String serviceIds) {
53+
final String url = p13nConfiguration.getServiceNavigatorUrl() + SERVICENAVIGATOR_QUERY_PARAMETER_ID + serviceIds;
54+
final ResponseEntity<List> forEntity = restTemplate.getForEntity(url, List.class);
55+
return forEntity.getBody();
56+
}
57+
58+
}

personalization-service/src/main/resources/application-local.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,9 @@ sso:
4242

4343
security:
4444
user-info-uri: ${sso.url}/auth/realms/${sso.realm}/protocol/openid-connect/userinfo
45-
logging-mode: all
45+
logging-mode: all
46+
47+
p13n:
48+
service-navigator-url: "https://stadt.muenchen.de/service/rs/befi/navigator/"
49+
proxy-host: "internet-proxy-client.muenchen.de"
50+
proxy-port: 80

personalization-service/src/test/java/de/muenchen/dbs/personalization/IntegrationTestBase.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import static de.muenchen.dbs.personalization.TestConstants.SPRING_TEST_PROFILE;
55

66
import com.fasterxml.jackson.databind.ObjectMapper;
7+
import de.muenchen.dbs.personalization.configuration.P13nConfiguration;
78
import java.time.Instant;
89
import java.util.Map;
910
import org.springframework.beans.factory.annotation.Autowired;
11+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
1012
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
1113
import org.springframework.boot.test.context.SpringBootTest;
1214
import org.springframework.security.oauth2.jwt.Jwt;
@@ -19,6 +21,7 @@
1921
classes = { PersonalizationServiceApplication.class },
2022
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
2123
)
24+
@EnableConfigurationProperties(P13nConfiguration.class)
2225
@ActiveProfiles(profiles = { SPRING_TEST_PROFILE, SPRING_NO_SECURITY_PROFILE })
2326
@AutoConfigureMockMvc
2427
public class IntegrationTestBase {

personalization-service/src/test/resources/application-test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ security:
77
# possible values: none, all, changing (With changing, only changing requests such as POST, PUT, DELETE are logged)
88
# Currently only dummy values, will later be changed for testing security.
99
user-info-uri: NotNeeded
10-
logging-mode: all
10+
logging-mode: all
11+
12+
p13n:
13+
service-navigator-url: "https://stadt.muenchen.de/service/rs/befi/navigator/"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
VITE_NODE_ENV=development
2+
VITE_VUE_APP_API_URL=http://localhost:8083
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
VITE_NODE_ENV=production
2+
VITE_VUE_APP_API_URL=
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta
6+
name="robots"
7+
content="noindex"
8+
/>
9+
<link
10+
href="/favicon.ico"
11+
rel="icon"
12+
/>
13+
<meta
14+
content="width=device-width, initial-scale=1.0"
15+
name="viewport"
16+
/>
17+
<title>personalization-webcomponent</title>
18+
19+
<!-- Muenchen.de Fontfaces -->
20+
<link
21+
href="https://assets.muenchen.de/mde/1.0.10/css/fonts.css"
22+
rel="stylesheet"
23+
/>
24+
25+
<!-- Load login-WC from local dev-server -->
26+
<script
27+
src="http://localhost:5173/src/main.ts"
28+
type="module"
29+
></script>
30+
31+
<!-- built files will be auto injected -->
32+
<script
33+
src="src/checklist-preview-webcomponent.ts"
34+
type="module"
35+
></script>
36+
</head>
37+
<body>
38+
<noscript>
39+
<strong>
40+
In order for the development page to work correctly, JavaScript needs to
41+
be activated.
42+
</strong>
43+
</noscript>
44+
<dbs-login
45+
kc-url="http://localhost:8100/auth/"
46+
kc-realm="local_realm"
47+
kc-client-id="local"
48+
overview-link="http://localhost:3000/"
49+
ticket-link="http://localhost:3000/"
50+
appointment-link="http://localhost:3000/"
51+
></dbs-login>
52+
<div>
53+
<checklist-preview />
54+
</div>
55+
</body>
56+
</html>

personalization-webcomponents/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ <h1>The following webcomponents are available:</h1>
4949
<li>
5050
<a href="index-checklist-detail.html">checklist-detail webcomp</a>
5151
</li>
52+
<li>
53+
<a href="index-checklist-preview.html">checklist-preview webcomp</a>
54+
</li>
5255
<li>
5356
<a href="index-checklist-overview.html">checklist-overview webcomp</a>
5457
</li>

0 commit comments

Comments
 (0)