Initial commit

This commit is contained in:
jooho
2021-10-20 17:12:00 +09:00
parent 0c884beff8
commit 8caa4bbc5a
487 changed files with 44198 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
# oauth2 를 사용하기 위해서는 아래의 TODO 를 등록해야 함
spring:
security:
oauth2:
client:
registration:
# /oauth2/authorization/google
google:
client-id: google_client_id # TODO
client-secret: google_client_secret # TODO
scope: profile,email
# 네이버는 Spring Security를 공식 지원하지 않기 때문에 CommonOAuth2Provider 에서 해주는 값들을 수동으로 입력한다.
# /oauth2/authorization/naver
naver:
client-id: naver_client_id # TODO
client-secret: naver_client_secret # TODO
redirect_uri: "{baseUrl}/{action}/oauth2/code/{registrationId}"
authorization_grant_type: authorization_code
scope: name,email,profile_image
client-name: Naver
# /oauth2/authorization/kakao
kakao:
client-id: kakao_client_id # TODO
client-secret: kakao_client_secret # TODO
redirect-uri: "{baseUrl}/{action}/oauth2/code/{registrationId}"
client-authentication-method: POST
authorization-grant-type: authorization_code
scope: profile_nickname, account_email
client-name: Kakao
provider:
naver:
authorization_uri: https://nid.naver.com/oauth2.0/authorize
token_uri: https://nid.naver.com/oauth2.0/token
user-info-uri: https://openapi.naver.com/v1/nid/me
# 기준이 되는 user_name 의 이름을 네이버에서는 response로 지정해야한다. (네이버 회원 조회시 반환되는 JSON 형태 때문이다)
# response를 user_name으로 지정하고 이후 자바 코드로 response의 id를 user_name으로 지정한다. (스프링 시큐리티에서 하위 필드를 명시할 수 없기 때문)
user_name_attribute: response
kakao:
authorization_uri: https://kauth.kakao.com/oauth/authorize
token_uri: https://kauth.kakao.com/oauth/token
user-info-uri: https://kapi.kakao.com/v2/user/me
user_name_attribute: id

View File

@@ -0,0 +1,66 @@
server:
port: 0 # random port
spring:
application:
name: user-service
profiles:
group:
default: oauth
docker: oauth
cf: oauth
k8s: oauth
jpa:
hibernate:
ddl-auto: none
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL57Dialect
storage_engine: innodb
format_sql: true
default_batch_fetch_size: 1000
jdbc:
batch_size: 1000
order_inserts: true
order_updates: true
show-sql: true
cache:
jcache:
config: classpath:ehcache.xml
# config server actuator
management:
endpoints:
web:
exposure:
include: refresh, health, beans
health:
mail:
enabled: false
# @TODO application-oauth.yml
# spring:
# security:
# oauth2:
# client:
# registration:
# google:
# client-id: @TODO https://console.cloud.google.com
# client-secret: @TODO
# scope: profile,email
# # 네이버는 Spring Security를 공식 지원하지 않기 때문에 CommonOAuth2Provider 에서 해주는 값들을 수동으로 입력한다.
# naver:
# client-id: @TODO https://developers.naver.com/apps/#/register?api=nvlogin
# client-secret: @TODO
# redirect_uri_template: "{baseUrl}/{action}/oauth2/code/{registrationId}"
# authorization_grant_type: authorization_code
# scope: name,email,profile_image
# client-name: Naver
# provider:
# naver:
# authorization_uri: https://nid.naver.com/oauth2.0/authorize
# token_uri: https://nid.naver.com/oauth2.0/token
# user-info-uri: https://openapi.naver.com/v1/nid/me
# # 기준이 되는 user_name 의 이름을 네이버에서는 response로 지정해야한다. (네이버 회원 조회시 반환되는 JSON 형태 때문이다)
# # response를 user_name으로 지정하고 이후 자바 코드로 response의 id를 user_name으로 지정한다. (스프링 시큐리티에서 하위 필드를 명시할 수 없기 때문)
# user_name_attribute: response

View File

@@ -0,0 +1,8 @@
spring:
cloud:
config:
uri: http://localhost:8888
name: user-service # user-service.yml이 있으면 불러오게 된다
# name: config-service # config-service의 application.yml 을 불러오게 된다
# profiles:
# active: prod # application-prod.yml

View File

@@ -0,0 +1,51 @@
<config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3'
xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core.xsd">
<cache alias="cache-user-authorization-by-roles"> <!-- 캐시 이름 -->
<key-type>java.util.List</key-type> <!-- 캐시 키 타입 -->
<value-type>java.util.List</value-type> <!-- 캐시 저장 값 타입 -->
<expiry>
<ttl unit="minutes">3</ttl> <!-- 만료 시간 -->
</expiry>
<listeners>
<listener>
<class>org.egovframe.cloud.userservice.config.CacheEventLogger</class> <!-- 캐시 이벤트 리스너 -->
<event-firing-mode>ASYNCHRONOUS</event-firing-mode>
<event-ordering-mode>UNORDERED</event-ordering-mode>
<events-to-fire-on>CREATED</events-to-fire-on>
<events-to-fire-on>EXPIRED</events-to-fire-on>
</listener>
</listeners>
<resources>
<heap unit="entries">2000</heap> <!-- 힙 사이즈 -->
<offheap unit="MB">1</offheap> <!-- 힙 사이즈가 부족할 경우 디스크 사용 용량 -->
</resources>
</cache>
<cache alias="cache-user-authorization-by-userid"> <!-- 캐시 이름 -->
<key-type>java.lang.String</key-type> <!-- 캐시 키 타입 -->
<value-type>java.util.List</value-type> <!-- 캐시 저장 값 타입 -->
<expiry>
<ttl unit="minutes">3</ttl> <!-- 만료 시간 -->
</expiry>
<listeners>
<listener>
<class>org.egovframe.cloud.userservice.config.CacheEventLogger</class> <!-- 캐시 이벤트 리스너 -->
<event-firing-mode>ASYNCHRONOUS</event-firing-mode>
<event-ordering-mode>UNORDERED</event-ordering-mode>
<events-to-fire-on>CREATED</events-to-fire-on>
<events-to-fire-on>EXPIRED</events-to-fire-on>
</listener>
</listeners>
<resources>
<heap unit="entries">2000</heap> <!-- 힙 사이즈 -->
<offheap unit="MB">1</offheap> <!-- 힙 사이즈가 부족할 경우 디스크 사용 용량 -->
</resources>
</cache>
</config>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %thread %-5level %logger - %m%n</pattern>
</encoder>
</appender>
<!-- 로컬에서는 로그를 전송하지 않도록 설정 -->
<springProfile name="default">
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</springProfile>
<springProfile name="!default">
<!-- java -Ddestination="localhost:8088" 와 같이 변경할 수 있다. cf 환경에서는 manifest.yml 파일에 환경변수로 추가 -->
<property name="destination" value="localhost:8088" />
<property name="app_name" value="${app_name}" />
<!-- ELK - Logstash 로 로그를 전송하기 위한 appender -->
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>${destination}</destination><!-- native profile => localhost:8088 -->
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"app.name":"${app_name}"}</customFields>
</encoder>
</appender>
<root level="WARN">
<appender-ref ref="LOGSTASH" />
<appender-ref ref="STDOUT" />
</root>
</springProfile>
</configuration>