-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSpringWebConfig.java
67 lines (59 loc) · 2.5 KB
/
SpringWebConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.oing.config;
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.gson.GsonFactory;
import com.oing.config.filter.WebRequestInterceptor;
import com.oing.config.support.AppKeyResolver;
import com.oing.util.security.LoginFamilyIdArgumentResolver;
import com.oing.util.security.LoginMemberIdArgumentResolver;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.Collections;
import java.util.List;
/**
* no5ing-server
* User: CChuYong
* Date: 2023/11/21
* Time: 5:46 PM
*/
@RequiredArgsConstructor
@Configuration
public class SpringWebConfig implements WebMvcConfigurer {
final WebRequestInterceptor webRequestInterceptor;
final AppKeyResolver appKeyResolver;
final LoginFamilyIdArgumentResolver familyIdArgumentResolver;
final LoginMemberIdArgumentResolver loginMemberIdArgumentResolver;
@Value("${app.oauth.google-client-id}")
private String googleClientId;
@Bean
public GoogleIdTokenVerifier googleIdTokenVerifier() {
return new GoogleIdTokenVerifier.Builder(new NetHttpTransport(), new GsonFactory())
.setAudience(Collections.singletonList(googleClientId))
.build();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(webRequestInterceptor);
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(appKeyResolver);
resolvers.add(familyIdArgumentResolver);
resolvers.add(loginMemberIdArgumentResolver);
}
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("https://bibbi.app", "https://no5ing.kr", "https://dev.no5ing.kr")
.allowedMethods("GET", "POST", "PUT", "DELETE")
.allowedHeaders("Authorization", "Content-Type")
.allowCredentials(true)
.maxAge(3600);
}
}