From bf58ea29034ec3c7ee12a05bf5de2d5dc5c77ba8 Mon Sep 17 00:00:00 2001 From: Chantha Date: Mon, 18 May 2020 17:11:01 +0700 Subject: [PATCH] "Add Spring Security to project" --- ...ng_boot_starter_security_2_3_0_RELEASE.xml | 13 +++ ...y_spring_security_config_5_2_4_RELEASE.xml | 13 +++ ...ity_spring_security_core_5_2_4_RELEASE.xml | 13 +++ ...rity_spring_security_web_5_2_4_RELEASE.xml | 13 +++ .idea/workspace.xml | 85 ++++++++++++------- jdbc.iml | 6 +- .../com/chantha/jdbc/config/WebConfig.java | 29 ++++++- src/main/resources/application.properties | 2 +- 8 files changed, 141 insertions(+), 33 deletions(-) create mode 100644 .idea/libraries/Maven__org_springframework_boot_spring_boot_starter_security_2_3_0_RELEASE.xml create mode 100644 .idea/libraries/Maven__org_springframework_security_spring_security_config_5_2_4_RELEASE.xml create mode 100644 .idea/libraries/Maven__org_springframework_security_spring_security_core_5_2_4_RELEASE.xml create mode 100644 .idea/libraries/Maven__org_springframework_security_spring_security_web_5_2_4_RELEASE.xml diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_security_2_3_0_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_security_2_3_0_RELEASE.xml new file mode 100644 index 0000000..0db4e6e --- /dev/null +++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_security_2_3_0_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_security_spring_security_config_5_2_4_RELEASE.xml b/.idea/libraries/Maven__org_springframework_security_spring_security_config_5_2_4_RELEASE.xml new file mode 100644 index 0000000..47e4e93 --- /dev/null +++ b/.idea/libraries/Maven__org_springframework_security_spring_security_config_5_2_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_security_spring_security_core_5_2_4_RELEASE.xml b/.idea/libraries/Maven__org_springframework_security_spring_security_core_5_2_4_RELEASE.xml new file mode 100644 index 0000000..93389af --- /dev/null +++ b/.idea/libraries/Maven__org_springframework_security_spring_security_core_5_2_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_security_spring_security_web_5_2_4_RELEASE.xml b/.idea/libraries/Maven__org_springframework_security_spring_security_web_5_2_4_RELEASE.xml new file mode 100644 index 0000000..530a392 --- /dev/null +++ b/.idea/libraries/Maven__org_springframework_security_spring_security_web_5_2_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 15b2bba..63f85e0 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,16 +2,14 @@ - - - + + + + - - - - - - + + + + + + @@ -90,7 +95,7 @@ - + @@ -106,10 +111,10 @@ - + - + @@ -126,42 +131,62 @@ - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + diff --git a/jdbc.iml b/jdbc.iml index 66fe564..7999556 100644 --- a/jdbc.iml +++ b/jdbc.iml @@ -71,7 +71,6 @@ - @@ -130,6 +129,11 @@ + + + + + diff --git a/src/main/kotlin/com/chantha/jdbc/config/WebConfig.java b/src/main/kotlin/com/chantha/jdbc/config/WebConfig.java index cc1a322..fd9f8b4 100644 --- a/src/main/kotlin/com/chantha/jdbc/config/WebConfig.java +++ b/src/main/kotlin/com/chantha/jdbc/config/WebConfig.java @@ -1,4 +1,31 @@ package com.chantha.jdbc.config; -public class WebConfig { +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; + +public class WebConfig extends WebSecurityConfigurerAdapter { + + @Override + public void configure(WebSecurity web) throws Exception { + + UserDetails user= User.builder() + .username("chantha") + .password("chantha") + .roles("ADMIN") + .build(); + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.formLogin(); + http.cors().disable(); + } + + + + + } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c76806f..ad18dc6 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,7 +4,7 @@ spring.datasource.password=root spring.jpa.hibernate.ddl-auto=update spring.jpa.open-in-view=true - +server.port=8081