Skip to content

Commit

Permalink
Merge pull request #91 from TravelCompass-UMC/refactor/90
Browse files Browse the repository at this point in the history
[#90] 배포 도메인 변경
  • Loading branch information
persi0815 authored Apr 7, 2024
2 parents 79499ff + 2bceb13 commit cbdbbb4
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class NaverPathController {
@Parameter(name = "start", description = "출발지의 location-id"),
@Parameter(name = "goal", description = "도착지의 location-id"),
})
@GetMapping("/getCarDuration") // http://dev.enble.site:8080/getCarDuration?start=1&goal=2
@GetMapping("/getCarDuration")
public ApiResponse<Integer> getDuration(@RequestParam("start") Long startLocationId,
@RequestParam("goal") Long goalLocationId) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,60 @@
package com.travelcompass.api.global.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI openAPI() {
public OpenAPI api() {
Info info = new Info()
.version("v1.0.0")
.title("Travel Compass API")
.description("Travel Compass API 명세서")
.version("v1.0.0");
.description("Travel Compass API 명세서");


// SecuritySecheme명
String jwtSchemeName = "AccessToken";
// API 요청헤더에 인증정보 포함
SecurityRequirement securityRequirement = new SecurityRequirement().addList(jwtSchemeName);
// SecuritySchemes 등록
Components components = new Components()
.addSecuritySchemes(jwtSchemeName, new SecurityScheme()
.name(jwtSchemeName)
.type(SecurityScheme.Type.HTTP) // HTTP 방식
.scheme("bearer")
.bearerFormat("JWT")); // 토큰 형식을 지정하는 임의의 문자(Optional

return new OpenAPI()
.components(new io.swagger.v3.oas.models.Components())
.info(info);
.info(info)
.addSecurityItem(securityRequirement)
.components(components);
}

@Bean
public GroupedOpenApi allGroup(){
return GroupedOpenApi.builder()
.group("All")
.pathsToMatch("/**")
.build();
}

// CORS 설정 추가
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("*").allowedMethods("GET", "POST", "PUT", "DELETE");
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected SecurityFilterChain securityFilterChain(
)
.oauth2Login(oauth2Login -> oauth2Login
//.loginPage("/users/login")
//.loginPage("http://dev.enble.site:8080/oauth2/authorization/naver") //비인증 사용자를 이동시킬 로그인 페이지
//.loginPage("http://umc.persi0815.site:8080/oauth2/authorization/naver") //비인증 사용자를 이동시킬 로그인 페이지
.successHandler(oAuth2SuccessHandler) //인증 성공 후 jwt 생성, 사용자 정보 db에 등록
//.defaultSuccessUrl("/users/main") //로그인(일정 부분) 성공하면 특정 화면으로 이동
.userInfoEndpoint(userInfo -> userInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public void onAuthenticationSuccess(
refreshTokenRepository.save(
RefreshToken.builder()
.id(username)
.ip(IpUtil.getClientIp(request))
.ttl(validPeriod)
.refreshToken(jwt.getRefreshToken())
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ public class RefreshToken {
@Id
private String id;

private String ip;

@ElementCollection
private Collection<String> authorities; // 권한을 문자열 형태로 저장
// private Collection<? extends GrantedAuthority> authorities;

private String refreshToken;

private Long ttl;
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spring:
# 서비스 제공자측에 저희가 어떤 서비스인지 인증하기 위한 값
client-id: 3tVKSO15tNGbkeZJf8eE #서비스 제공자측에 저희가 어떤 서비스인지 인증하기 위한 값
client-secret: zHvANLwWHH
redirect-uri: http://dev.enble.site:8080/login/oauth2/code/naver
redirect-uri: http://umc.persi0815.site:8080/login/oauth2/code/naver
# redirect-uri: http://localhost:8080/login/oauth2/code/naver
authorization-grant-type: authorization_code # 어떤 방식으로 access token을 받을지 정의
client-authentication-method: client_secret_post # Client Id, Client Secret를 요청의 어디에 포함할지 정의. Body
Expand Down

0 comments on commit cbdbbb4

Please sign in to comment.