Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
niki committed Dec 1, 2024
1 parent 59e8447 commit 1cf3a2a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.5</version>
<version>3.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down Expand Up @@ -48,7 +48,7 @@
<dependency>
<groupId>net.bull.javamelody</groupId>
<artifactId>javamelody-spring-boot-starter</artifactId>
<version>2.1.0</version>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nikirocks/CustomLogoutHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected String determineTargetUrl(HttpServletRequest request, HttpServletRespo
return UriComponentsBuilder
.fromUri(URI.create(logoutUrl))
.queryParam("client_id", clientId)
.queryParam("logout_uri", logoutRedirectUrl)
//.queryParam("logout_uri", logoutRedirectUrl)
.encode(StandardCharsets.UTF_8)
.build()
.toUriString();
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/nikirocks/CustomSuccessLoginHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.stereotype.Service;

import java.io.IOException;
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/nikirocks/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
@Controller
public class MainController {

@Autowired
private UserDao userDao;
@Autowired
private Menu menu;

@Autowired
public MainController(UserDao userDao, Menu menu) {
this.userDao = userDao;
this.menu = menu;
}

@RequestMapping(value = "/", method = RequestMethod.GET)
public String index() {
menu.setHome(true);
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/com/nikirocks/SecurityConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
@EnableWebSecurity
public class SecurityConfiguration {

@Value("${aws.cognito.logoutUrl}")
private String logoutUrl;

@Value("${aws.cognito.logout.success.redirectUrl}")
private String logoutRedirectUrl;
Expand All @@ -41,13 +39,12 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.requestMatchers("/css/**").permitAll()
.requestMatchers("/js/**").permitAll()
.requestMatchers("/images/**").permitAll()
.requestMatchers("/monitoring").hasRole("admins")
.requestMatchers("/monitoring").hasRole("user")
.requestMatchers("/secured").authenticated()
.anyRequest()
.authenticated())
.oauth2Login((oath2Login) -> oath2Login.successHandler(customSuccessLoginHandler).userInfoEndpoint(userInfoEndpointConfig -> userInfoEndpointConfig.userAuthoritiesMapper(userAuthoritiesMapper())))
.logout(x -> x.logoutSuccessHandler(
new CustomLogoutHandler(logoutUrl, logoutRedirectUrl, clientId)));
.logout(Customizer.withDefaults());

return http.build();
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spring:
resources:
cache:
cachecontrol:
max-age: 8h
max-age: 3h
chain:
enabled: true
strategy:
Expand All @@ -24,8 +24,9 @@ spring:
cognito:
client-id: ${client-id}
client-secret: ${client-secret}
scope: openid,email,profile

scope: openid
redirect-uri: http://localhost:8080/login/oauth2/code/cognito
clientName: springnogito
provider:
cognito:
issuer-uri: ${issuer-url}
Expand Down

0 comments on commit 1cf3a2a

Please sign in to comment.