19. 대칭키를 활용한 DB정보 암호화

| 대칭키를 활용한 DB정보 암호화


1. User-service 의 db설정과 config 설정을 수정한다

applicaton.yml의 DB설정을 주석 처리한다

#  datasource:
#    url: jdbc:postgresql://localhost:5432/basic
#    username: postgres
#    password: wcadmin
#    driver-class-name: org.postgresql.Driver

bootstrap.yml의 config 설정 정보 수정한다.

"user-service"의 파일 정보를 불러올 수 있게 수정.

spring:
  cloud:
    config:
      uri: http://localhost:8888
      name: user-service
#  profiles:
#    active: dev

2. 패스워드를 암호화한 값 설정

설정파일이 있는 폴더에 가서 user-service.yml 파일에 DB설정 정보값을 입력한다.

3. native-file-repo > user-service.yml

spring:
  datasource:
    driver-class-name: org.postgresql.Driver
    url: jdbc:postgresql://localhost:5432/basic
    username: postgres
    password: '{cipher}c917b4f9bbdfc3bea72bc5fe4eaa69a8261aa51264483b52f229cd698d01e685'

token:
  expiration_time: 86400000
  secret: user_token_native_user_service

gateway:
  ip: localhost

 

테스트

패스워드를 보면 정상적으로 복호화되어 "wcadmin"으로 출력된 걸 볼 수 있다.

'📚 Spring > Spring Cloud' 카테고리의 다른 글

22. Feign Client  (0) 2023.05.28
21. RestTemplate  (0) 2023.05.27
18.대칭키와 비대칭키  (0) 2023.05.15
16. Spring Cloud Bus  (0) 2023.05.10
[Error] JWT 구현 시 javax/xml/bind/DatatypeConverter 에러 대처법  (0) 2023.05.04

댓글

Designed by JB FACTORY