Compare commits

..

3 Commits

Author SHA1 Message Date
Lea
bbbf0a9473 homepage skeleton 2025-02-12 08:54:28 +01:00
Huy
2cd1c6d8fd feat: Create initial landing page (CAS-8) (!11)
Co-authored-by: Phan Huy Tran <p.tran@neusta.de>
Reviewed-on: #11
Reviewed-by: Constantin Simonis <constantin@simonis.lol>
Reviewed-by: lziemke <lea.z4@schule.bremen.de>
2025-02-12 07:43:05 +00:00
Huy
35bfa3be7f fix: Fix security config, add health check route and adjust requests (!9)
Co-authored-by: Phan Huy Tran <p.tran@neusta.de>
Reviewed-on: #9
Reviewed-by: Constantin Simonis <constantin@simonis.lol>
Reviewed-by: lziemke <lea.z4@schule.bremen.de>
2025-02-05 11:38:00 +00:00
8 changed files with 39 additions and 40 deletions

View File

@ -1,21 +0,0 @@
@token =eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICIxX3I2eDlta1B3cm9NWHQ5Q1Y4cktyak5WNndybktrWnI0Qk5xYW9QM2VVIn0.eyJleHAiOjE3Mzg3NTI4MjYsImlhdCI6MTczODc1MjUyNiwianRpIjoiNmQ0NjhkOWYtZDMwNC00NGIxLWI1YTctMjk3MTM1ODNmNDUzIiwiaXNzIjoiaHR0cDovL2xvY2FsaG9zdDo5MDkwL3JlYWxtcy9MRjEyIiwiYXVkIjoiYWNjb3VudCIsInN1YiI6IjUyY2MwMjA4LWEzYmQtNDM2Ny05NGM1LTA0MDRiMDE2YTAwMyIsInR5cCI6IkJlYXJlciIsImF6cCI6ImxmMTIiLCJzZXNzaW9uX3N0YXRlIjoiMzU3OTA4M2EtODNjZi00YTJjLTgwZGMtZmQzNDhkZTFjYWMxIiwiYWNyIjoiMSIsImFsbG93ZWQtb3JpZ2lucyI6WyJodHRwOi8vbG9jYWxob3N0OjQyMDAiXSwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbImRlZmF1bHQtcm9sZXMtbGYxMiIsImxmMTJfdGVzdF9yb2xlIiwib2ZmbGluZV9hY2Nlc3MiLCJ1bWFfYXV0aG9yaXphdGlvbiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7ImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoicHJvZmlsZSBlbWFpbCIsInNpZCI6IjM1NzkwODNhLTgzY2YtNGEyYy04MGRjLWZkMzQ4ZGUxY2FjMSIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwicHJlZmVycmVkX3VzZXJuYW1lIjoibGYxMl90ZXN0X3VzZXIifQ.th_MJfbMYC-99eMOy0tfYskFLqwiPAx2UH8_XpwgnUzYF6XvydTmpWXifYYQzQpET_QcdOVFeyYnuED29Zsl8td6zd5was-6OqPgASBV-ZODRJ0AshRCD_NiD4C63XpwxZ7vy75sbUfaAr1VV_E072tAVxihQQxfjYcGwgfOjL1g85GDzVX8qu0uO31-YMdTNhyeBxLnWV1s-SwuoWFxWGb-ObVsCj2t2WVOf9Nxh-MofXw4heJEkDsnZ45O-_8ewtOLycfbJuK6CW2mZUhRmtm4MCSWC6QhFMi3nVekTuzg0jnRHb64ANaRAlT5Qy6VwlVZxyhKDpZdvPGOxZ-Cww
###
GET localhost:8080/welcome
###
GET localhost:8080/roles
Authorization: Bearer {{token}}
###
GET localhost:8080/hellos
Authorization: Bearer {{token}}
###
POST localhost:8080/hellos
Authorization: Bearer {{token}}
Content-Type: application/json
{
"message": "test"
}

View File

@ -3,4 +3,4 @@ Content-Type: application/x-www-form-urlencoded
grant_type=password&client_id=lf12&username=lf12_test_user&password=secret grant_type=password&client_id=lf12&username=lf12_test_user&password=secret
> {% client.global.set("token", response.body.access_token); %}

View File

@ -0,0 +1 @@
GET localhost:8080/health

View File

@ -0,0 +1,15 @@
package de.szut.casino.health;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@RestController
public class HealthController {
@GetMapping("/health")
public Map<String, String> healthCheck() {
return Map.of("status", "UP");
}
}

View File

@ -52,23 +52,12 @@ class KeycloakSecurityConfig {
@Bean @Bean
public SecurityFilterChain resourceServerFilterChain(HttpSecurity http) throws Exception { public SecurityFilterChain resourceServerFilterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(auth -> auth http.authorizeHttpRequests(auth -> auth
.requestMatchers(new AntPathRequestMatcher("/welcome")) .requestMatchers("/swagger", "/swagger-ui/**", "/v3/api-docs/**", "/health").permitAll()
.permitAll() .anyRequest().authenticated()
.requestMatchers( )
new AntPathRequestMatcher("/swagger"), .oauth2ResourceServer(spec -> spec.jwt(Customizer.withDefaults()));
new AntPathRequestMatcher("/swagger-ui/**"),
new AntPathRequestMatcher("/v3/api-docs/**"))
.permitAll()
.requestMatchers(new AntPathRequestMatcher("/hello/**"))
.hasRole("lf12_test_role")
.requestMatchers(new AntPathRequestMatcher("/roles"))
.authenticated()
.requestMatchers(new AntPathRequestMatcher("/"))
.permitAll()
.anyRequest()
.authenticated()).oauth2ResourceServer(spec -> spec.jwt(Customizer.withDefaults()));
return http.build(); return http.build();
} }
@ -90,4 +79,4 @@ class KeycloakSecurityConfig {
}); });
return jwtAuthenticationConverter; return jwtAuthenticationConverter;
} }
} }

View File

@ -1,4 +1,5 @@
import {Routes} from '@angular/router'; import { Routes } from '@angular/router';
import {LandingPageComponent} from "./landing-page/landing-page.component";
import {HomepageComponent} from "./homepage/homepage/homepage.component"; import {HomepageComponent} from "./homepage/homepage/homepage.component";
export const routes: Routes = [ export const routes: Routes = [
@ -6,4 +7,7 @@ export const routes: Routes = [
path: 'home', path: 'home',
component: HomepageComponent component: HomepageComponent
}, },
{ path: '', component: LandingPageComponent }
]; ];

View File

@ -0,0 +1,11 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-landing-page',
standalone: true,
imports: [],
templateUrl: './landing-page.component.html',
})
export class LandingPageComponent {
}