๊ด€๋ฆฌ ๋ฉ”๋‰ด

Coding Planet

Spring Boot Actuator - Security ๋ณด์•ˆ์„ค์ •ํ•˜๊ธฐ(ํ™˜๊ฒฝ์„ค์ •), ID์™€ ๋น„๋ฐ€๋ฒˆํ˜ธ ์„ค์ •ํ•˜๊ธฐ ๋ณธ๋ฌธ

๐ŸŒฑSPRING

Spring Boot Actuator - Security ๋ณด์•ˆ์„ค์ •ํ•˜๊ธฐ(ํ™˜๊ฒฝ์„ค์ •), ID์™€ ๋น„๋ฐ€๋ฒˆํ˜ธ ์„ค์ •ํ•˜๊ธฐ

jhj.sharon 2023. 8. 20. 23:34
๋ฐ˜์‘ํ˜•
์ด์ „ ํฌ์ŠคํŠธ(https://sharonprogress.tistory.com/231)์—์„œ ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์šด์˜ ์ค‘์ธ ์ƒํƒœ์™€ ํ–‰๋™์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š” ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ธ Spring Boot Actuator์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ดค๋‹ค.  ์ด ๊ฒฝ์šฐ endpoint์„ ํ†ตํ•ด์„œ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ํ—ˆ๊ฐ€ ์—†์ด๋„ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿฐ ์ ์€ ๋ณด์•ˆ์ƒ ์ข‹์ง€ ์•Š๋‹ค. ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ๋ณด์•ˆ(Security)์„ค์ •์ด ํ•„์š”ํ•˜๋‹ค. ๋‹ค๋งŒ ์ด ํฌ์ŠคํŠธ์—๋Š” ๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ธ ๋ณด์•ˆ ๊ด€๋ จ ํ™˜๊ฒฝ ์„ค์ •๋งŒ์„ ์•Œ๋ ค์ค€๋‹ค.

 

 

1. pom.xml์— dependency ์ถ”๊ฐ€

		<!--ADD SUPPORT FOR SPRING SECURITY-->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-security</artifactId>
		</dependency>

 

2. ๋””ํดํŠธ ์•„์ด๋”” ๋ฐ ๋น„๋ฐ€๋ฒˆํ˜ธ ํ™•์ธ

1) ID์™€ ํŒจ์Šค์›Œ๋“œ ํ™•์ธํ•˜๊ธฐ

  • ์—”๋“œํฌ์ธํŠธ์— ์ ‘๊ทผํ•˜๊ธฐ ์œ„ํ•œ ๊ธฐ๋ณธ ID๋Š” 'user'์ด๊ณ  ๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” ์ฝ˜์†”์— ์ถœ๋ ฅ๋œ๋‹ค.
  • ๋ฉ”์ธ application์„ ์‹คํ–‰ํ•ด์„œ ์ฝ˜์†”์—์„œ ํ™•์ธํ•˜์ž

 

2) localhost ์ ‘์†ํ•˜๊ธฐ

 

2)ID์™€ ํŒจ์Šค์›Œ๋“œ๋กœ ์ ‘์†!

์ •์ƒ์ ์œผ๋กœ ์ถœ๋ ฅ๋œ๋‹ค.

 

 

 

2. ํŠน์ • ์—”๋“œํฌ์ธํŠธ ์ ‘์† ๋น„ํ™œ์„ฑํ™” ํ•˜๊ธฐ

1) application.properties์—์„œ exclude ์„ค์ •ํ•˜๊ธฐ

#Exclude individual endpoints with a comma-delimited list
management.endpoints.web.exposure.exclude=health, info

 

2) ์ ‘๊ทผ ๋ถˆ๊ฐ€ ํ™•์ธ

 

 

 

๐Ÿ’ป ํ•˜์ง€๋งŒ ์‹ค์ œ ๊ฐœ๋ฐœ, devOps๋“ฑ์—์„œ ํ•ด๋‹น ์—”๋“œํฌ์ธํŠธ๋“ค์€ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ƒํƒœ ํ™•์ธ์— ๋งค์šฐ ์œ ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๊ธฐ๋ณธ์ ์œผ๋กœ๋Š” ๋กœ๊ทธ์ธ ์ ‘๊ทผ์œผ๋กœ ๋ณด์•ˆ์„ ์œ ์ง€ํ•  ๊ฒƒ์„ ์ถ”์ฒœํ•œ๋‹ค.

 

 

 

๋ฐ˜์‘ํ˜•
Comments