From 4b4193017fae8eefd6f1a4ed097b95f6a6144aea Mon Sep 17 00:00:00 2001 From: haerong22 Date: Sat, 28 Nov 2020 17:40:00 +0900 Subject: [PATCH] =?UTF-8?q?spring=20security=20=EC=9D=B8=EC=A6=9D=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- restful-web-service/pom.xml | 5 +++++ .../config/SecurityConfig.java | 18 ++++++++++++++++++ .../src/main/resources/application.yml | 6 +++++- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 restful-web-service/src/main/java/com/example/restfulwebservice/config/SecurityConfig.java diff --git a/restful-web-service/pom.xml b/restful-web-service/pom.xml index 271a41a7..e1a3ab89 100644 --- a/restful-web-service/pom.xml +++ b/restful-web-service/pom.xml @@ -39,6 +39,11 @@ org.springframework.boot spring-boot-starter-actuator + + org.springframework.boot + spring-boot-starter-security + 2.4.0 + org.springframework.data spring-data-rest-hal-browser diff --git a/restful-web-service/src/main/java/com/example/restfulwebservice/config/SecurityConfig.java b/restful-web-service/src/main/java/com/example/restfulwebservice/config/SecurityConfig.java new file mode 100644 index 00000000..de108f01 --- /dev/null +++ b/restful-web-service/src/main/java/com/example/restfulwebservice/config/SecurityConfig.java @@ -0,0 +1,18 @@ +package com.example.restfulwebservice.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@Configuration +public class SecurityConfig extends WebSecurityConfigurerAdapter { + @Autowired + public void ConfigureGlobal(AuthenticationManagerBuilder auth) + throws Exception{ + auth.inMemoryAuthentication() + .withUser("kim") + .password("{noop}test1234") + .roles("USER"); + } +} diff --git a/restful-web-service/src/main/resources/application.yml b/restful-web-service/src/main/resources/application.yml index 26fa09f4..85d7fd4f 100644 --- a/restful-web-service/src/main/resources/application.yml +++ b/restful-web-service/src/main/resources/application.yml @@ -8,9 +8,13 @@ logging: spring: messages: basename: messages + security: + user: + name: username + password: passw0rd management: endpoints: web: exposure: - include: "*" \ No newline at end of file + include: "*"