PMT-9: Move Template to Config Bean, so it can be reused by Generated Code

This commit is contained in:
Dominik Säume 2024-09-30 09:08:16 +02:00
parent 12d97a88d1
commit d3755984d9
Signed by: SZUT-Dominik
GPG key ID: 67D15BB250B41E7C
2 changed files with 16 additions and 1 deletions

View file

@ -0,0 +1,13 @@
package de.hmmh.pmt;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
@Configuration
public class Config {
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
}

View file

@ -2,6 +2,7 @@ package de.hmmh.pmt.auth;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
@ -25,7 +26,8 @@ public class JWT implements LogoutHandler {
private static final String OIDC_LOGOUT_ROUTE = "/protocol/openid-connect/logout"; private static final String OIDC_LOGOUT_ROUTE = "/protocol/openid-connect/logout";
private static final String OIDC_TOKEN_HINT_QUERY_PARAMETER = "id_token_hin"; private static final String OIDC_TOKEN_HINT_QUERY_PARAMETER = "id_token_hin";
private final RestTemplate template = new RestTemplate(); @Autowired
private RestTemplate template;
@Override @Override
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {