diff --git a/spring-5-security-cognito/pom.xml b/spring-5-security-cognito/pom.xml
index 8d03b91ce0..5f8f328086 100644
--- a/spring-5-security-cognito/pom.xml
+++ b/spring-5-security-cognito/pom.xml
@@ -34,11 +34,6 @@
-
- org.springframework.security.oauth.boot
- spring-security-oauth2-autoconfigure
- ${oauth-auto.version}
-
org.springframework.security
spring-security-oauth2-client
@@ -62,10 +57,8 @@
test
-
+
- 2.1.0.RELEASE
- 2.1.0.RELEASE
com.baeldung.cognito.SpringCognitoApplication
diff --git a/spring-5-security-cognito/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java b/spring-5-security-cognito/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java
index 6841fa7a65..df35a46ef3 100644
--- a/spring-5-security-cognito/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java
+++ b/spring-5-security-cognito/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java
@@ -1,12 +1,10 @@
package com.baeldung.cognito;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
-@PropertySource("cognito/application-cognito.yml")
public class CognitoWebConfiguration implements WebMvcConfigurer {
@Override
diff --git a/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SecurityConfiguration.java b/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SecurityConfiguration.java
new file mode 100644
index 0000000000..ba0436d20d
--- /dev/null
+++ b/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SecurityConfiguration.java
@@ -0,0 +1,23 @@
+package com.baeldung.cognito;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+
+@Configuration
+public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http.csrf()
+ .and()
+ .authorizeRequests(authz -> authz.mvcMatchers("/")
+ .permitAll()
+ .anyRequest()
+ .authenticated())
+ .oauth2Login()
+ .and()
+ .logout()
+ .logoutSuccessUrl("/");
+ }
+}
\ No newline at end of file
diff --git a/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java b/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java
index eebe6d8f45..fc55de590c 100644
--- a/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java
+++ b/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java
@@ -2,10 +2,8 @@ package com.baeldung.cognito;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.PropertySource;
@SpringBootApplication
-@PropertySource("cognito/application-cognito.yml")
public class SpringCognitoApplication {
public static void main(String[] args) {
diff --git a/spring-5-security-cognito/src/main/resources/application.yml b/spring-5-security-cognito/src/main/resources/application.yml
new file mode 100644
index 0000000000..e53a2642e0
--- /dev/null
+++ b/spring-5-security-cognito/src/main/resources/application.yml
@@ -0,0 +1,15 @@
+spring:
+ security:
+ oauth2:
+ client:
+ registration:
+ cognito:
+ client-id: your_clientId
+ client-secret: your_clientSecret
+ scope: openid
+ redirect-uri: http://localhost:8080/login/oauth2/code/cognito
+ clientName: your_clientName
+ provider:
+ cognito:
+ issuerUri: https://cognito-idp.{region}.amazonaws.com/{poolId}
+ user-name-attribute: cognito:username
diff --git a/spring-5-security-cognito/src/main/resources/cognito/application-cognito.yml b/spring-5-security-cognito/src/main/resources/cognito/application-cognito.yml
deleted file mode 100644
index 0a28dbccb4..0000000000
--- a/spring-5-security-cognito/src/main/resources/cognito/application-cognito.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-spring:
- security:
- oauth2:
- client:
- registration:
- cognito:
- client-id: clientId
- client-secret: clientSecret
- scope: openid
- redirectUriTemplate: "http://localhost:8080/login/oauth2/code/cognito"
- clientName: cognito-client-name
- provider:
- cognito:
- issuerUri: https://cognito-idp.{region}.amazonaws.com/{poolId}
- usernameAttribute: cognito:username
diff --git a/spring-5-security-cognito/src/main/resources/cognito/home.html b/spring-5-security-cognito/src/main/resources/cognito/home.html
deleted file mode 100644
index f0bd9e52a8..0000000000
--- a/spring-5-security-cognito/src/main/resources/cognito/home.html
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
- OAuth2 Cognito Demo
-
-
-
-
-
-
-
-
-
OAuth2 Spring Security Cognito Demo
-
-
-
-
-
-
-
-
-
diff --git a/spring-5-security-cognito/src/main/resources/cognito/style.css b/spring-5-security-cognito/src/main/resources/cognito/style.css
deleted file mode 100644
index 45190d6d70..0000000000
--- a/spring-5-security-cognito/src/main/resources/cognito/style.css
+++ /dev/null
@@ -1,9 +0,0 @@
-.login {
- background-color: #7289da;
- color: #fff;
-}
-
-.login:hover {
- background-color: #697ec4;
- color: #fff;
-}
diff --git a/spring-5-security-cognito/src/main/resources/templates/home.html b/spring-5-security-cognito/src/main/resources/templates/home.html
new file mode 100644
index 0000000000..df3c86fe2a
--- /dev/null
+++ b/spring-5-security-cognito/src/main/resources/templates/home.html
@@ -0,0 +1,35 @@
+
+
+
+
+
+OAuth2 Cognito Demo
+
+
+
+
+
+
+
+
OAuth2 Spring Security Cognito Demo
+
+
+
+
+
+
+
+
+