{"id":2258,"date":"2021-07-17T16:48:07","date_gmt":"2021-07-17T07:48:07","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=2258"},"modified":"2021-07-17T17:17:12","modified_gmt":"2021-07-17T08:17:12","slug":"%ec%9b%b9%ec%84%9c%eb%b9%84%ec%8a%a4%ec%97%90-%eb%b3%b4%ec%95%88-%ec%a0%81%ec%9a%a9","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=2258","title":{"rendered":"\uc6f9\uc11c\ube44\uc2a4\uc5d0 \ubcf4\uc548 \uc801\uc6a9"},"content":{"rendered":"<h1>\uc6f9\uc11c\ube44\uc2a4\uc5d0 \ubcf4\uc548 \uc801\uc6a9<\/h1>\n<h2>\ubaa9\ud45c<\/h2>\n<p>\uc6f9\uc11c\ube44\uc2a4\uc5d0 \ub85c\uadf8\uc778 \uccb4\ud06c \uae30\ub2a5\uc744 \ucd94\uac00\ud569\ub2c8\ub2e4.<\/p>\n<h2>\ud504\ub85c\uc81d\ud2b8 \uc0dd\uc131<\/h2>\n<p>\uc2e0\uaddc \ud504\ub85c\uc81d\ud2b8\ub97c \uc0dd\uc131\ud569\ub2c8\ub2e4.<\/p>\n<p>\uc758\uc874\uc131\uc740 DevTools, Lombok, Spring Web, Thymeleaf \ub97c \uc120\ud0dd\ud569\ub2c8\ub2e4.<\/p>\n<h2>\ud30c\uc77c \ucd94\uac00<\/h2>\n<p>home.html<\/p>\n<pre><code class=\"language-html\">&lt;!DOCTYPE html&gt;\n&lt;html xmlns=&quot;http:\/\/www.w3.org\/1999\/xhtml&quot; xmlns:th=&quot;https:\/\/www.thymeleaf.org&quot; xmlns:sec=&quot;https:\/\/www.thymeleaf.org\/thymeleaf-extras-springsecurity3&quot;&gt;\n&lt;head&gt;\n    &lt;title&gt;Spring Security Example&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;h1&gt;Welcome!&lt;\/h1&gt;\n\n&lt;p&gt;Click &lt;a th:href=&quot;@{\/hello}&quot;&gt;here&lt;\/a&gt; to see a greeting.&lt;\/p&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<p>hello.html<\/p>\n<pre><code class=\"language-html\">&lt;!DOCTYPE html&gt;\n&lt;html xmlns=&quot;http:\/\/www.w3.org\/1999\/xhtml&quot; xmlns:th=&quot;https:\/\/www.thymeleaf.org&quot;\n      xmlns:sec=&quot;https:\/\/www.thymeleaf.org\/thymeleaf-extras-springsecurity3&quot;&gt;\n&lt;head&gt;\n  &lt;title&gt;Hello World!&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;h1&gt;Hello world!&lt;\/h1&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<p>MvcConfig.java<\/p>\n<pre><code class=\"language-java\">@Configuration\npublic class MvcConfig implements WebMvcConfigurer {\n\n    public void addViewControllers(ViewControllerRegistry registry) {\n        registry.addViewController(&quot;\/home&quot;).setViewName(&quot;home&quot;);\n        registry.addViewController(&quot;\/&quot;).setViewName(&quot;home&quot;);\n        registry.addViewController(&quot;\/hello&quot;).setViewName(&quot;hello&quot;);\n        registry.addViewController(&quot;\/login&quot;).setViewName(&quot;login&quot;);\n    }\n}<\/code><\/pre>\n<h2>\ud504\ub85c\uc81d\ud2b8 \uc2e4\ud589<\/h2>\n<p>\ud504\ub85c\uc81d\ud2b8\ub97c \uc2e4\ud589\ud569\ub2c8\ub2e4.<\/p>\n<p>\uc544\ubb34\ub7f0 \ubcf4\uc548 \uae30\ub2a5\uc5c6\uc774 \uc811\uc18d\uc774 \ub418\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p><a href=\"http:\/\/localhost:8080\/\">http:\/\/localhost:8080\/<\/a><\/p>\n<h2>\ubcf4\uc548 \uc801\uc6a9<\/h2>\n<p>&quot;\/&quot; \ub294 \ub85c\uadf8\uc778 \ud544\uc694\uc5c6\uc774 \uc811\uc18d \uac00\ub2a5\ud558\uac8c, &quot;\/hello&quot; \ub294 \ub85c\uadf8\uc778\uc774 \ud544\uc694\ud558\ub3c4\ub85d \uc124\uc815\ud569\ub2c8\ub2e4.<\/p>\n<p>\uc6b0\uc120, build.gradle \uc5d0 \uc544\ub798 \uc758\uc874\uc131\uc744 \ucd94\uac00\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-gradle\">implementation &#039;org.springframework.boot:spring-boot-starter-security&#039;\nimplementation &#039;org.springframework.security:spring-security-test&#039;<\/code><\/pre>\n<p>WebSecurityConfig.java<\/p>\n<p><code>configure(HttpSecurity http)<\/code> \uc5d0\uc11c \uac01\uac01\uc758 URL \uc5d0 \ub300\ud574 \ubcf4\uc548 \uc801\uc6a9\uc5ec\ubd80\ub97c \uc815\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p><code>&quot;\/&quot;, &quot;\/home&quot;<\/code> \uc5d0 \ub300\ud574 \uc804\ubd80 \ud5c8\uc6a9\uc744 \uc124\uc815\ud558\uace0, \ub098\uba38\uc9c0 URL \uc744 \uc804\ubd80 \ubcf4\uc548\uc124\uc815\ud569\ub2c8\ub2e4.<\/p>\n<p>\ub9c8\uc9c0\ub9c9\uc73c\ub85c \ub85c\uadf8\uc778 \ud398\uc774\uc9c0\ub3c4 \uc804\ubd80 \ud5c8\uc6a9\uc73c\ub85c \uc124\uc815\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-java\">@Configuration\n@EnableWebSecurity\npublic class WebSecurityConfig extends WebSecurityConfigurerAdapter {\n    @Override\n    protected void configure(HttpSecurity http) throws Exception {\n        http\n                .authorizeRequests()\n                    .antMatchers(&quot;\/&quot;, &quot;\/home&quot;).permitAll()\n                    .anyRequest().authenticated()\n                    .and()\n                .formLogin()\n                    .loginPage(&quot;\/login&quot;)\n                    .permitAll()\n                    .and()\n                .logout()\n                    .permitAll();\n    }\n\n    @Bean\n    @Override\n    public UserDetailsService userDetailsService() {\n        UserDetails user =\n                User.withDefaultPasswordEncoder()\n                        .username(&quot;user&quot;)\n                        .password(&quot;password&quot;)\n                        .roles(&quot;USER&quot;)\n                        .build();\n\n        return new InMemoryUserDetailsManager(user);\n    }\n}<\/code><\/pre>\n<p><code>userDetailsService()<\/code> \uc5d0\uc11c \uc0ac\uc6a9\uc790 \ub85c\uadf8\uc778 \uc815\ubcf4\ub97c \uc124\uc815\ud574 \uc90d\ub2c8\ub2e4.<\/p>\n<p>login.html \uc744 \ucd94\uac00\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-html\">&lt;!DOCTYPE html&gt;\n&lt;html xmlns=&quot;http:\/\/www.w3.org\/1999\/xhtml&quot; xmlns:th=&quot;https:\/\/www.thymeleaf.org&quot;\n      xmlns:sec=&quot;https:\/\/www.thymeleaf.org\/thymeleaf-extras-springsecurity3&quot;&gt;\n&lt;head&gt;\n    &lt;title&gt;Spring Security Example &lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;div th:if=&quot;${param.error}&quot;&gt;\n    Invalid username and password.\n&lt;\/div&gt;\n&lt;div th:if=&quot;${param.logout}&quot;&gt;\n    You have been logged out.\n&lt;\/div&gt;\n&lt;form th:action=&quot;@{\/login}&quot; method=&quot;post&quot;&gt;\n    &lt;div&gt;&lt;label&gt; User Name : &lt;input type=&quot;text&quot; name=&quot;username&quot;\/&gt; &lt;\/label&gt;&lt;\/div&gt;\n    &lt;div&gt;&lt;label&gt; Password: &lt;input type=&quot;password&quot; name=&quot;password&quot;\/&gt; &lt;\/label&gt;&lt;\/div&gt;\n    &lt;div&gt;&lt;input type=&quot;submit&quot; value=&quot;Sign In&quot;\/&gt;&lt;\/div&gt;\n&lt;\/form&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<p>hello.html \uc744 \uc218\uc815\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-html\">&lt;!DOCTYPE html&gt;\n&lt;html xmlns=&quot;http:\/\/www.w3.org\/1999\/xhtml&quot; xmlns:th=&quot;https:\/\/www.thymeleaf.org&quot;\n      xmlns:sec=&quot;https:\/\/www.thymeleaf.org\/thymeleaf-extras-springsecurity3&quot;&gt;\n&lt;head&gt;\n  &lt;title&gt;Hello World!&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;h1 th:inline=&quot;text&quot;&gt;Hello [[${#httpServletRequest.remoteUser}]]!&lt;\/h1&gt;\n&lt;form th:action=&quot;@{\/logout}&quot; method=&quot;post&quot;&gt;\n  &lt;input type=&quot;submit&quot; value=&quot;Sign Out&quot;\/&gt;\n&lt;\/form&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\uc6f9\uc11c\ube44\uc2a4\uc5d0 \ubcf4\uc548 \uc801\uc6a9 \ubaa9\ud45c \uc6f9\uc11c\ube44\uc2a4\uc5d0 \ub85c\uadf8\uc778 \uccb4\ud06c \uae30\ub2a5\uc744 \ucd94\uac00\ud569\ub2c8\ub2e4. \ud504\ub85c\uc81d\ud2b8 \uc0dd\uc131 \uc2e0\uaddc \ud504\ub85c\uc81d\ud2b8\ub97c \uc0dd\uc131\ud569\ub2c8\ub2e4. \uc758\uc874\uc131\uc740 DevTools, Lombok, Spring Web, Thymeleaf \ub97c \uc120\ud0dd\ud569\ub2c8\ub2e4. \ud30c\uc77c \ucd94\uac00 home.html &lt;!DOCTYPE html&gt; &lt;html xmlns=&quot;http:\/\/www.w3.org\/1999\/xhtml&quot; xmlns:th=&quot;https:\/\/www.thymeleaf.org&quot; xmlns:sec=&quot;https:\/\/www.thymeleaf.org\/thymeleaf-extras-springsecurity3&quot;&gt; &lt;head&gt; &lt;title&gt;Spring Security Example&lt;\/title&gt; &lt;\/head&gt; &lt;body&gt; &lt;h1&gt;Welcome!&lt;\/h1&gt; &lt;p&gt;Click &lt;a th:href=&quot;@{\/hello}&quot;&gt;here&lt;\/a&gt; to see a greeting.&lt;\/p&gt; &lt;\/body&gt; &lt;\/html&gt; hello.html &lt;!DOCTYPE html&gt; &lt;html xmlns=&quot;http:\/\/www.w3.org\/1999\/xhtml&quot; xmlns:th=&quot;https:\/\/www.thymeleaf.org&quot; xmlns:sec=&quot;https:\/\/www.thymeleaf.org\/thymeleaf-extras-springsecurity3&quot;&gt; &lt;head&gt;\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=2258\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"class_list":["post-2258","post","type-post","status-publish","format-standard","hentry","category-spring-boot-2-5"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2258"}],"version-history":[{"count":7,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2258\/revisions"}],"predecessor-version":[{"id":2266,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2258\/revisions\/2266"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}