SseopE
SseopE
SseopE
전체 방문자
오늘
어제
  • 분류 전체보기 (44)
    • Programming (3)
      • JAVA (3)
    • Spring (7)
      • 스프링 부트와 AWS로 혼자 구현하는 웹 서비스 (5)
      • Spring 공부 (0)
    • Infra (6)
      • Docker (3)
      • Kubernetes (3)
      • Kafka (0)
    • Machine Learning (2)
      • Scikit-Learn (1)
      • MLOps (1)
      • BentoML (0)
      • Kubeflow (0)
    • OS (2)
      • Linux (2)
    • Algorithm (23)
      • Sorting (7)
      • BOJ (15)
      • Programmers (0)
      • Data Structure (1)
    • 특강 (0)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • java
  • resource
  • 자바
  • 1541번
  • 2275번
  • 2981번
  • 1931번
  • BaseEstimator
  • Spring boot
  • docker
  • 도커
  • container
  • Kubernetes
  • scikit learn
  • 스웜 모드
  • 2580번
  • boj
  • TransformMixin
  • 백준
  • Spring

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
SseopE

SseopE

Spring/스프링 부트와 AWS로 혼자 구현하는 웹 서비스

스프링 부트와 AWS로 혼자 구현하는 웹 서비스 - 4 [properties]

2022. 4. 25. 20:46

application.properties

local에서 테스트하면서 사용했던 설정이다.

# database setting
spring.jpa.show_sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL57Dialect
spring.jpa.properties.hibernate.dialect.storage_engine=innodb
spring.datasource.hikari.jdbc-url=jdbc:h2:mem:testdb;MODE=MYSQL
spring.datasource.hikari.username=sa
spring.h2.console.enabled=true
spring.profiles.include=oauth

#session setting
spring.session.store-type=jdbc

spring.jpa.show_sql : 하이버네이트가 만들어서 전송하는 쿼리문을 log에 띄워주도록 설정

spring.jpa.properties.hibernate.dialect : 하이버네이트가 표시하는 log를 설정한 DB의 문법에 맞게 표현

spring.datasource.hikari.jdbc-url : 연결할 DB의 주소를 표시

spring.datasource.hikari.username : DB 아이디

spring.datasource.hikari.password : DB 패스워드

spring.h2.console.enabled : 인메모리 데이터베이스인 h2 데이터베이스의 콘솔을 사용할 수 있도록 설정

 - ex) http://localhost:port/h2-console, 주소와 name password는 설정한대로 입력

spring.profiles.include : 추가적인 properties를 포함시킴

spring.session.store-type : 저장 세션 타입 설정

 

application-real.properties

위와 거의 동일하나 

spring.datasource.hikari.jdbc-url

spring.datasource.hikari.username

spring.datasource.hikari.password

설정은 실제 구축한 DB에 연결할 것 이므로 설정하지 않고 따로 properties로 빼서 설정

따로 빼서 설정하는 이유는 아이디, 패스워드, 주소 등은 노출되면 보안상에 문제가 생기기 때문에 gitignore에 설정해서 repository에 올라가지 않도록 유의 한다.

 

application-oauth.properties

로그인할때 혹은 다른 보안 설정을 위한 설정파일로 사용했다.

spring.security.oauth2.client.registration.google.client-id=
spring.security.oauth2.client.registration.google.client-secret=
spring.security.oauth2.client.registration.google.scope=

spring.security.oauth2.client.registration.naver.client-id=
spring.security.oauth2.client.registration.naver.client-secret=
spring.security.oauth2.client.registration.naver.redirect-uri=
spring.security.oauth2.client.registration.naver.authorization_grant_type=
spring.security.oauth2.client.registration.naver.scope=
spring.security.oauth2.client.registration.naver.client-name=
spring.security.oauth2.client.provider.naver.authorization_uri=
spring.security.oauth2.client.provider.naver.token_uri=
spring.security.oauth2.client.provider.naver.user-info-uri=
spring.security.oauth2.client.provider.naver.user_name_attribute=

위의 설정에서는 구글과 네이버 로그인 API를 사용하기 위해 설정한 값들이다.

구글은 스프링 시큐리티에서 공식으로 지원하기 때문에 좀 자동적으로 설정되는게 많아서 편했는데

네이버는 공식 지원이 되지않아 설정할 값들이 좀 많다.

 

구글, 네이버 둘다 공통적으로

spring.security.oauth2.client.registration.{company}.client-id : 발급받은 api의 클라이언트 id 값

spring.security.oauth2.client.registration.{company}.client-secret : 발급받은 api의 클라이언트 secret 값

spring.security.oauth2.client.registration.{company}.scope : 로그인 정보 중 사용할 정보 범위

 

를 설정했고, 이외에 Naver에 추가적으로 설정한것은 다음과 같다.

 

spring.security.oauth2.client.registration.{company}.redirect-uri : {baseUrl}/{action}/oauth2/code/{registrationId}

spring.security.oauth2.client.registration.{company}.authorization_grant_type : authorization_code

spring.security.oauth2.client.registration.{company}.client_name : Naver

spring.security.oauth2.client.provider.{company}.authorization_uri : https://nid.naver.com/oauth2.0/authorize

spring.security.oauth2.client.provider.{company}.token_uri : https://nid.naver.com/oauth2.0/token

spring.security.oauth2.client.provider.{company}.user-info-uri : https://openapi.naver.com/v1/nid/me

spring.security.oauth2.client.provider.{company}.user_name_attribute : response

 

client-id와 client-secret은 노출되지 않게 조심해야한다.

'Spring > 스프링 부트와 AWS로 혼자 구현하는 웹 서비스' 카테고리의 다른 글

스프링 부트와 AWS로 혼자 구현하는 웹 서비스 - 4 [Classes]  (0) 2022.04.25
스프링 부트와 AWS로 혼자 구현하는 웹 서비스 - 3 [Annotation]  (0) 2022.04.25
스프링 부트와 AWS로 혼자 구현하는 웹 서비스 - 2 [Plugins]  (0) 2022.04.24
스프링 부트와 AWS로 혼자 구현하는 웹 서비스 - 1 [Gradle]  (0) 2022.04.24
    'Spring/스프링 부트와 AWS로 혼자 구현하는 웹 서비스' 카테고리의 다른 글
    • 스프링 부트와 AWS로 혼자 구현하는 웹 서비스 - 4 [Classes]
    • 스프링 부트와 AWS로 혼자 구현하는 웹 서비스 - 3 [Annotation]
    • 스프링 부트와 AWS로 혼자 구현하는 웹 서비스 - 2 [Plugins]
    • 스프링 부트와 AWS로 혼자 구현하는 웹 서비스 - 1 [Gradle]
    SseopE
    SseopE

    티스토리툴바