From ef0da3e6158e966ade9faef6850fd5254031fe85 Mon Sep 17 00:00:00 2001 From: yunyun Date: Thu, 11 Nov 2021 18:17:11 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20day1=20=EB=B0=B0=EC=9A=B4=20?= =?UTF-8?q?=EB=82=B4=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MEMO.md | 7 ++ pom.xml | 116 +++++++++++++++++- .../kdt/yun/configures/WebMvcConfigure.java | 19 +++ .../yun/configures/WebSecurityConfigure.java | 34 +++++ src/main/resources/application.properties | 1 - src/main/resources/application.yml | 16 +++ src/main/resources/banner.txt | 7 ++ src/main/resources/lobback.xml | 20 +++ .../resources/static/assets/icons/favi.png | Bin 0 -> 9686 bytes src/main/resources/templates/index.html | 13 ++ src/main/resources/templates/me.html | 26 ++++ 11 files changed, 256 insertions(+), 3 deletions(-) create mode 100644 MEMO.md create mode 100644 src/main/java/com/kdt/yun/configures/WebMvcConfigure.java create mode 100644 src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java delete mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/application.yml create mode 100644 src/main/resources/banner.txt create mode 100644 src/main/resources/lobback.xml create mode 100644 src/main/resources/static/assets/icons/favi.png create mode 100644 src/main/resources/templates/index.html create mode 100644 src/main/resources/templates/me.html diff --git a/MEMO.md b/MEMO.md new file mode 100644 index 0000000..70bb8fb --- /dev/null +++ b/MEMO.md @@ -0,0 +1,7 @@ +## 공부 주제 + +## 공부 내용 + +## 참고 사항 + +- 베너 만드는 사이트 : http://patorjk.com/software/taag/#p=display&f=Graffiti&t=Type%20Something%20 \ No newline at end of file diff --git a/pom.xml b/pom.xml index cfb7c9c..15735e9 100644 --- a/pom.xml +++ b/pom.xml @@ -8,18 +8,116 @@ 2.5.6 + com.kdt.yun spring-security-master-class 0.0.1-SNAPSHOT ssmc ssmc + + UTF-8 + UTF-8 + 2.2.9.Final + 30.1.1-jre + 3.12.0 + 2.11.0 + 2.12.4 17 + org.springframework.boot spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + + org.springframework.boot + spring-boot-starter-undertow + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + org.springframework.boot + spring-boot-configuration-processor + + + + + org.springframework.boot + spring-boot-starter-security + + + + io.undertow + undertow-core + ${undertow.version} + + + + io.undertow + undertow-servlet + ${undertow.version} + + + + + org.thymeleaf.extras + thymeleaf-extras-springsecurity5 + + + + com.google.guava + guava + ${guava.version} + + + + org.apache.commons + commons-lang3 + ${commons.lang.version} + + + + commons-io + commons-io + ${commons.io.version} + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.datatype.version} + + + + com.fasterxml.jackson.module + jackson-module-afterburner + ${jackson.datatype.version} + + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson.datatype.version} + + + + + org.springframework.security + spring-security-test + test @@ -31,11 +129,25 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + org.springframework.boot spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + - - + \ No newline at end of file diff --git a/src/main/java/com/kdt/yun/configures/WebMvcConfigure.java b/src/main/java/com/kdt/yun/configures/WebMvcConfigure.java new file mode 100644 index 0000000..e2bfc00 --- /dev/null +++ b/src/main/java/com/kdt/yun/configures/WebMvcConfigure.java @@ -0,0 +1,19 @@ +package com.kdt.yun.configures; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * Created by yunyun on 2021/11/11. + */ + +@Configuration +public class WebMvcConfigure implements WebMvcConfigurer { + + @Override + public void addViewControllers(ViewControllerRegistry registry){ + registry.addViewController("/").setViewName("index"); + registry.addViewController("/me").setViewName("me"); + } +} diff --git a/src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java b/src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java new file mode 100644 index 0000000..45603b6 --- /dev/null +++ b/src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java @@ -0,0 +1,34 @@ +package com.kdt.yun.configures; + +import org.springframework.context.annotation.Configuration; +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.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +/** + * Created by yunyun on 2021/11/11. + */ + +@Configuration +@EnableWebSecurity +public class WebSecurityConfigure extends WebSecurityConfigurerAdapter { + + @Override + public void configure(WebSecurity web){ + web.ignoring().antMatchers("/assets/**"); + } + + @Override + protected void configure(HttpSecurity http) throws Exception{ + http + .authorizeRequests() + .antMatchers("/me").hasAnyRole("USER","ADMIN") + .anyRequest().permitAll() + .and() + .formLogin() + .defaultSuccessUrl("/") + .permitAll() + .and(); + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 8b13789..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..44f784e --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,16 @@ +spring: + application: + name: spring security 01 + thymeleaf: + cache: true + security: + user: + name: user + password: user123 + roles: USER + messages: + basename: i18n/messages + encoding: UTF-8 + cache-duration: PT1H +server: + port: 8080 \ No newline at end of file diff --git a/src/main/resources/banner.txt b/src/main/resources/banner.txt new file mode 100644 index 0000000..08b4d8a --- /dev/null +++ b/src/main/resources/banner.txt @@ -0,0 +1,7 @@ + ###### ######## ###### ## ## ######## #### ######## ## ## ## ## ### ###### ######## ######## ######## +## ## ## ## ## ## ## ## ## ## ## ## ## ### ### ## ## ## ## ## ## ## ## +## ## ## ## ## ## ## ## ## #### #### #### ## ## ## ## ## ## ## + ###### ###### ## ## ## ######## ## ## ## ## ### ## ## ## ###### ## ###### ######## + ## ## ## ## ## ## ## ## ## ## ## ## ######### ## ## ## ## ## +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## + ###### ######## ###### ####### ## ## #### ## ## ####### ## ## ## ## ###### ## ######## ## ## \ No newline at end of file diff --git a/src/main/resources/lobback.xml b/src/main/resources/lobback.xml new file mode 100644 index 0000000..c55cd77 --- /dev/null +++ b/src/main/resources/lobback.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/static/assets/icons/favi.png b/src/main/resources/static/assets/icons/favi.png new file mode 100644 index 0000000000000000000000000000000000000000..3b48c65e3f49f5797dff7d74bbb86c5a2e72f5f8 GIT binary patch literal 9686 zcmZX4by!qy^Y<<#urx?32uMf@NJ$EUNJ>ce(y?^9EK4IT-6#l3O0KYUH%c#!Al=OZ z%gguqJ@4~-uJ=9HHD~6`%xC7z+<)BHocly+sw)u_(h~vz0Al4g3R?GE^`12F@$T<( z*sNgy08r6hUS3mKUY=Rg9b#keWDNjtCR&-BQz-Lr_E}h%oA(WKa}m1xXhlZGXqm$X z+K5B3i2e|DMD=&$#sPuSvQLQw=pTMS_O#)D;ok`!DiI!%Y;k|NnuRBH(((3t-g)}= zJAmF>2RFe440e}&Kkn@fG~Oh%<^@+JHsAs`K9RiD;(jYz>k%kt z{m#Z;F)ElvXM`R z!R9lI18vN1peIGuL2!6$7~Ep+D!A*5!cT14)+(xEItIBJNp&KkvJ1@JU0F|Cn{))2m)7bac`pPzHYJg|=GClwpVGqE$mw@*~ ze@_4a_NQ>bgL_VKPYU^1|FNp(WB*6i_{ULBTV7fDo@-mVTU)z$*g-tYi0YE>LrvK0 z=zHp`sY+NuocS!k5KC)5UuV~UAOJ~UiF?u6+S7vB*V)O%L&8^zMbw{~Jfa+QZ7--qq6{;==q-TnkHx zm!}j9%RhJ{PW}#r)W@Jvhko?0j;Jx-xn) z2f2z?J+Fgd2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ljSA zah2;<#43YFK@^T#sM*89rZx#<^UJHn15@s%xS=>2Oi=b=k}i_F?>))f3yD-U)WT#o zBhxpx@{@BT9b7&n%+-0zU}<3Q1;{NrsLYDLg^+C}@%iG#pPwM%8aPcs@qK}xm>Jmy7ilLkI&E`B#Y?^82| zgVE;;IC(f#(!Klq+(s@g!V+^4VLL5eKvDdTDuaYQkgf)|!|6|XdcmH<`(v`o5A*x2 zynN+nlWPR4>o=9(JNy_{j~Yz;exZhv%;6m2N`jccSs< + + + + + + + + +index page + + + \ No newline at end of file diff --git a/src/main/resources/templates/me.html b/src/main/resources/templates/me.html new file mode 100644 index 0000000..95a0b99 --- /dev/null +++ b/src/main/resources/templates/me.html @@ -0,0 +1,26 @@ + + + + + + + + + +

내 정보

+
+ 님 반갑습니다. +
+ User has role ROLE_ADMIN. +
+
+ User has role ROLE_USER. +
+ + + + \ No newline at end of file From 106002af2aaa6f49b5ac4aea51bd82b1c347cc41 Mon Sep 17 00:00:00 2001 From: yunyun Date: Thu, 11 Nov 2021 19:44:58 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=EB=AF=B8=EC=85=981=20-=20admin=20?= =?UTF-8?q?=EA=B3=84=EC=A0=95,=20user=20=EA=B3=84=EC=A0=95=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=98=EA=B8=B0=20-=20configure=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=ED=99=9C=EC=9A=A9=ED=95=B4=EC=84=9C=20?= =?UTF-8?q?=EB=AF=B8=EC=85=98=20=EC=88=98=ED=96=89=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yun/configures/WebSecurityConfigure.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java b/src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java index 45603b6..34775ff 100644 --- a/src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java +++ b/src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java @@ -1,10 +1,15 @@ package com.kdt.yun.configures; +import org.apache.commons.io.file.NoopPathVisitor; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 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.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.crypto.password.NoOpPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; /** * Created by yunyun on 2021/11/11. @@ -14,6 +19,19 @@ @EnableWebSecurity public class WebSecurityConfigure extends WebSecurityConfigurerAdapter { + @Override + public void configure(AuthenticationManagerBuilder auth) throws Exception { + //super.configure(auth); + auth.inMemoryAuthentication() + .withUser("user") + .password("user123") + .roles("USER"); + auth.inMemoryAuthentication() + .withUser("admin") + .password("admin123") + .roles("ADMIN"); + } + @Override public void configure(WebSecurity web){ web.ignoring().antMatchers("/assets/**"); @@ -31,4 +49,11 @@ protected void configure(HttpSecurity http) throws Exception{ .permitAll() .and(); } + + @Bean + public PasswordEncoder passwordEncoder(){ + return NoOpPasswordEncoder.getInstance(); + } + + } From e735d19874f96101b550e2e285b38d252bd36616 Mon Sep 17 00:00:00 2001 From: yunyun Date: Thu, 11 Nov 2021 21:08:33 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=EB=AF=B8=EC=85=982=20-=20HttpSecur?= =?UTF-8?q?ity=20=ED=81=B4=EB=9E=98=EC=8A=A4=EC=9D=98=20logout()=20API?= =?UTF-8?q?=EB=A5=BC=20=ED=86=B5=ED=95=B4=20=EB=A1=9C=EA=B7=B8=EC=95=84?= =?UTF-8?q?=EC=9B=83=20=EA=B8=B0=EB=8A=A5=EC=9D=84=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=20=20=20=20-=20=EB=A1=9C=EA=B7=B8=EC=95=84=EC=9B=83=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20path=20=E2=80=9C/logout=E2=80=9D=20=20=20?= =?UTF-8?q?=20=20-=20=EB=A1=9C=EA=B7=B8=EC=95=84=EC=9B=83=20=EC=84=B1?= =?UTF-8?q?=EA=B3=B5=20=ED=9B=84=20=EB=A6=AC=EB=8B=A4=EC=9D=B4=EB=A0=89?= =?UTF-8?q?=EC=85=98=20path=20=E2=80=9C/=E2=80=9D=20-=20HttpSecurity=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=EC=9D=98=20rememberMe()=20API?= =?UTF-8?q?=EB=A5=BC=20=ED=86=B5=ED=95=B4=20Cookie=20=EA=B8=B0=EB=B0=98=20?= =?UTF-8?q?=EC=9E=90=EB=8F=99=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=EC=9D=84=20=EC=84=A4=EC=A0=95=20=20=20=20=20-=20?= =?UTF-8?q?=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=EB=AA=85=20=E2=80=9Crememb?= =?UTF-8?q?er-me=E2=80=9D=20=20=20=20=20-=20=EC=9E=90=EB=8F=99=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=ED=86=A0=ED=81=B0=20=EC=9C=A0=ED=9A=A8?= =?UTF-8?q?=EA=B8=B0=EA=B0=84=205=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/kdt/yun/configures/WebSecurityConfigure.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java b/src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java index 34775ff..8fdbc45 100644 --- a/src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java +++ b/src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java @@ -47,7 +47,16 @@ protected void configure(HttpSecurity http) throws Exception{ .formLogin() .defaultSuccessUrl("/") .permitAll() - .and(); + .and() + .rememberMe() + .rememberMeParameter("remember-me") + .tokenValiditySeconds(5 * 60) + .alwaysRemember(true) + .and() + .logout() + .logoutUrl("/logout") + .deleteCookies("JSESSIONID", "remember-me") + .logoutSuccessUrl("/"); } @Bean From 5ba13b132269d393ce6233b0470f491b6114d733 Mon Sep 17 00:00:00 2001 From: yunyun Date: Fri, 12 Nov 2021 09:45:47 +0900 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=EB=A6=AC=EB=8D=94=EB=8B=98=EC=9D=98?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=EB=A5=BC=20=EC=B0=B8=EA=B3=A0=20=ED=95=98?= =?UTF-8?q?=EC=97=AC=20=EC=88=98=EC=A0=95=ED=95=9C=20=EB=82=B4=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yun/configures/WebSecurityConfigure.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java b/src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java index 8fdbc45..3bff956 100644 --- a/src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java +++ b/src/main/java/com/kdt/yun/configures/WebSecurityConfigure.java @@ -10,6 +10,7 @@ import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.crypto.password.NoOpPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.web.util.matcher.AntPathRequestMatcher; /** * Created by yunyun on 2021/11/11. @@ -24,11 +25,11 @@ public void configure(AuthenticationManagerBuilder auth) throws Exception { //super.configure(auth); auth.inMemoryAuthentication() .withUser("user") - .password("user123") + .password("{noop}user123") .roles("USER"); auth.inMemoryAuthentication() .withUser("admin") - .password("admin123") + .password("{noop}admin123") .roles("ADMIN"); } @@ -51,18 +52,21 @@ protected void configure(HttpSecurity http) throws Exception{ .rememberMe() .rememberMeParameter("remember-me") .tokenValiditySeconds(5 * 60) - .alwaysRemember(true) + //.alwaysRemember(true) .and() .logout() - .logoutUrl("/logout") - .deleteCookies("JSESSIONID", "remember-me") - .logoutSuccessUrl("/"); + //.logoutUrl("/logout") + //.deleteCookies("JSESSIONID", "remember-me") + .logoutRequestMatcher(new AntPathRequestMatcher("/logout")) + .logoutSuccessUrl("/") + .invalidateHttpSession(true) // 기본 값이 true 이다. + .clearAuthentication(true); // 기본 값이 true 이다. } - @Bean - public PasswordEncoder passwordEncoder(){ - return NoOpPasswordEncoder.getInstance(); - } +// @Bean +// public PasswordEncoder passwordEncoder(){ +// return NoOpPasswordEncoder.getInstance(); +// } }