ํ์๊ฐ์
๊ณผ ๋ก๊ทธ์ธ API๋ฅผ ๊ตฌํํ๋ฉด์ 401 Unauthorized ์ค๋ฅ๊ฐ ๋ง์ด ๋์๋ค........
๋์ฒด ์ ๋ฐ์ํ๋์ง๋ ๋ชจ๋ฅด๋ ์ํ์์ ์๊ฐ์ ๋ง์ด ์ก์๋จน์๋ค..

์ผ๋จ ํ์๊ฐ์
์ ํ ๋,
username ๊ณผ password๋ฅผ ์
๋ ฅํ๊ฒ ํ๋ค.
๊ทธ๋ฆฌ๊ณ ์
๋ ฅ๋ฐ์ password๋ ์ํธํ๋ฅผ ํ์ฌ ์ ์ฅํ๋๋ก ํ์๋ค.
String encodePassword = passwordEncoder.encode(password);
/* --------------------------------------------------------- */
// passwordEncoder
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
PasswordEncoder ๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด์
build.gradle๐์ dependencies ๋ก
implementation 'org.springframework.boot:spring-boot-starter-security' ์ถ๊ฐํ์๋ค...
๊ทธ๋์ ์ด Application์์๋ Security๊ฐ ๋์ํ๊ณ ์์๋ ๊ฒ ๊ฐ๋ค.
๊ทธ๋์
Using generated security password: 374530d8-989a-42e0-b6ac-ad0bb9fc5779
This generated password is for development use only. Your security configuration must be updated before running your application in production.
์คํ์ ํ ๋๋ง๋ค Console์
Using generated security passowrd: $%$#%$##@@$!!@#@!#
๊ฐ ๊ณ์ ์๊ธฐ๋ฉด์ ์ค๋ฅ๊ฐ ๋ฌ๋ ๊ฒ ๊ฐ๋ค.
Application.java ์์ @SpringBootApplication annotation ์ ์ต์
์ ๊ฑธ์ด์ฃผ์ด์ผ ํ๋ค.
@SpringBootApplication (exclude = SecurityAutoConfiguration.class)
// Spring Security ์ธ์ฆ ๊ธฐ๋ฅ ์ ์ธ
public class PostApplication {
public static void main(String[] args) {
SpringApplication.run(PostApplication.class, args);
}
}
์ด๋ ๊ฒ ์ต์
์ ๊ฑธ์ด์ ์คํ์ ํ์๋๋
Security ์์ ์ธ์ฆ์ ๊ดํ ๊ธฐ๋ฅ๋ค์ ์คํํ์ง ์๊ฒ ๋๋ฉด์ Console ์ ๋ ์ด์ Using generated security passowrd ์ด๋ฐ ๊ฒ๋ค์ด ๋จ์ง ์์๋ค!!!!