Skip to content

Commit

Permalink
Merge pull request #24 from depromeet/feat/LS-13-2
Browse files Browse the repository at this point in the history
feat/LS-13: 스페이스 API 구현
  • Loading branch information
clean2001 authored Jul 13, 2024
2 parents 175492d + e62b438 commit 80514fa
Show file tree
Hide file tree
Showing 35 changed files with 605 additions and 269 deletions.
169 changes: 86 additions & 83 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,138 +1,141 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.1'
id 'io.spring.dependency-management' version '1.1.5'
id 'java'
id 'org.springframework.boot' version '3.3.1'
id 'io.spring.dependency-management' version '1.1.5'
}

jar.enabled = false
bootJar.enabled = false

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

repositories {
mavenCentral()
mavenCentral()
}

subprojects {
group 'org.layer'
version '0.0.1'
sourceCompatibility = '17'
group 'org.layer'
version '0.0.1'
sourceCompatibility = '17'

apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}
repositories {
mavenCentral()
}

dependencies { // 모든 하위 모듈에 추가 될 의존성 목록입니다.
dependencies { // 모든 하위 모듈에 추가 될 의존성 목록입니다.

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'

implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'

}
}

test {
useJUnitPlatform()
}
test {
useJUnitPlatform()
}
}

project(":layer-api") {
version '0.0.1'
dependencies {
implementation project(path: ':layer-common')
implementation project(path: ':layer-domain')
implementation project(path: ':layer-external')
version '0.0.1'
dependencies {
implementation project(path: ':layer-common')
implementation project(path: ':layer-domain')
implementation project(path: ':layer-external')


implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-validation'

//== jwt ==//
implementation 'io.jsonwebtoken:jjwt-api:0.12.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.5'
//== jwt ==//
implementation 'io.jsonwebtoken:jjwt-api:0.12.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.5'

// oauth2-client 라이브러리
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
// oauth2-client 라이브러리
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'

// redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
testImplementation 'org.springframework.boot:spring-boot-starter-test'


// swagger
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0")
// swagger
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0")

// jpa
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
// jpa
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

// mysql
runtimeOnly 'com.mysql:mysql-connector-j'
}
// mysql
runtimeOnly 'com.mysql:mysql-connector-j'
}

jar.enabled = false
bootJar.enabled = true
jar.enabled = false
bootJar.enabled = true
}

project(":layer-common") {
bootJar.enabled = false
jar.enabled = true
bootJar.enabled = false
jar.enabled = true

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
dependencies {
// swagger
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0")

implementation 'org.springframework.boot:spring-boot-starter-web'
// implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
}
}

}


project(":layer-domain"){
bootJar.enabled = false
jar.enabled = true
project(":layer-domain") {
bootJar.enabled = false
jar.enabled = true

dependencies {
implementation project(path: ':layer-common')
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
dependencies {
implementation project(path: ':layer-common')
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'

// h2
runtimeOnly 'com.h2database:h2'
// h2
runtimeOnly 'com.h2database:h2'

testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
}
testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
}
}

project(":layer-external"){
bootJar.enabled = false
jar.enabled = true
project(":layer-external") {
bootJar.enabled = false
jar.enabled = true

dependencies {
implementation project(path: ':layer-common')
implementation project(path: ':layer-domain')

testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
}
testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
}
}
19 changes: 19 additions & 0 deletions layer-api/src/main/java/org/layer/config/SecurityConfig.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package org.layer.config;


import io.swagger.v3.oas.models.Operation;
import lombok.RequiredArgsConstructor;
import org.layer.common.annotation.DisableSwaggerSecurity;
import org.layer.domain.jwt.JwtAuthenticationFilter;
import org.springdoc.core.customizers.OperationCustomizer;
import org.springframework.boot.autoconfigure.security.ConditionalOnDefaultWebSecurity;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
Expand All @@ -12,10 +16,14 @@
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.web.method.HandlerMethod;

import java.util.Collections;

@RequiredArgsConstructor
@Configuration
@EnableWebSecurity
@ConditionalOnDefaultWebSecurity
public class SecurityConfig {
private final JwtAuthenticationFilter jwtAuthenticationFilter;

Expand Down Expand Up @@ -53,4 +61,15 @@ private void permitSwaggerUri(HttpSecurity http) throws Exception {
.requestMatchers(new AntPathRequestMatcher("/swagger-ui/**")).permitAll()
.requestMatchers(new AntPathRequestMatcher("/docs/**")).permitAll());
}

@Bean
public OperationCustomizer customize() {
return (Operation operation, HandlerMethod handlerMethod) -> {
DisableSwaggerSecurity methodAnnotation = handlerMethod.getMethodAnnotation(DisableSwaggerSecurity.class);
if (methodAnnotation != null) {
operation.setSecurity(Collections.emptyList());
}
return operation;
};
}
}
10 changes: 6 additions & 4 deletions layer-api/src/main/java/org/layer/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@
@Configuration
public class SwaggerConfig {

private static final String AUTH_TOKEN = "Authorization";

SecurityScheme apiAuth = new SecurityScheme()
.type(SecurityScheme.Type.APIKEY)
.in(SecurityScheme.In.HEADER)
.name("authorization-token");
.name(AUTH_TOKEN);

SecurityRequirement addSecurityItem = new SecurityRequirement()
.addList("authorization-token");
.addList(AUTH_TOKEN);

@Bean
public OpenAPI openAPI(){
public OpenAPI openAPI() {
var info = new Info();
info.title("Layer API");
info.description("Layer API 문서에요.");
Expand All @@ -39,7 +41,7 @@ public OpenAPI openAPI(){
info.license(new License().name("MIT"));
return new OpenAPI()
.components(new Components()
.addSecuritySchemes("authorization-token", apiAuth)
.addSecuritySchemes(AUTH_TOKEN, apiAuth)
)
.addSecurityItem(addSecurityItem)
.info(info);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.layer.common.annotation.DisableSwaggerSecurity;
import org.layer.domain.auth.controller.dto.*;
import org.layer.domain.auth.service.AuthService;
import org.layer.domain.auth.service.dto.SignInServiceResponse;
Expand All @@ -12,9 +13,6 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequiredArgsConstructor
Expand All @@ -26,16 +24,20 @@ public class AuthController implements AuthApi {
private final KakaoService kakaoService;
private final MemberRepository memberRepository;

private static final String SOCIAL_TOKEN_NAME = "X-AUTH-TOKEN";

// 로그인
@DisableSwaggerSecurity
@PostMapping("/sign-in")
public ResponseEntity<SignInResponse> signIn(@RequestHeader("Authorization") final String socialAccessToken, @RequestBody final SignInRequest signInRequest) {
public ResponseEntity<SignInResponse> signIn(@RequestHeader(SOCIAL_TOKEN_NAME) final String socialAccessToken, @RequestBody final SignInRequest signInRequest) {
SignInServiceResponse signInServiceResponse = authService.signIn(socialAccessToken, signInRequest.socialType());
return new ResponseEntity<>(SignInResponse.of(signInServiceResponse), HttpStatus.OK);
}

// 회원가입 => 소셜로그인 했는데 유효한 유저가 없을 때 이름 입력하고 회원가입하는 과정
@DisableSwaggerSecurity
@PostMapping("/sign-up")
public ResponseEntity<SignUpResponse> signUp(@RequestHeader("Authorization") final String socialAccessToken, @RequestBody final SignUpRequest signUpRequest) {
public ResponseEntity<SignUpResponse> signUp(@RequestHeader(SOCIAL_TOKEN_NAME) final String socialAccessToken, @RequestBody final SignUpRequest signUpRequest) {
SignUpServiceResponse signUpServiceResponse = authService.signUp(socialAccessToken, signUpRequest);
return new ResponseEntity<>(SignUpResponse.of(signUpServiceResponse), HttpStatus.CREATED);
}
Expand Down Expand Up @@ -63,12 +65,14 @@ public ResponseEntity<ReissueTokenResponse> reissueToken(ReissueTokenRequest rei
HttpStatus.CREATED);
}

@DisableSwaggerSecurity
//== google OAuth2 test용 API 액세스 토큰 발급 ==//
@GetMapping("oauth2/google")
public String googleTest(@RequestParam("code") String code) {
return googleService.getToken(code);
}

@DisableSwaggerSecurity
//== kakao OAuth2 test용 API 액세스 토큰 발급 ==//
@GetMapping("oauth2/kakao")
public Object kakaoLogin(@RequestParam(value = "code", required = false) String code) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.layer.retrospect.controller;
package org.layer.domain.retrospect.controller;

import org.layer.retrospect.controller.dto.request.RetrospectCreateRequest;
import org.layer.domain.retrospect.controller.dto.request.RetrospectCreateRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -12,7 +12,7 @@
@Tag(name = "회고", description = "회고 관련 API")
public interface RetrospectApi {

@Operation(summary = "회고 생성", description = "")
ResponseEntity<Void> createRetrospect(@PathVariable("spaceId") Long spaceId,
@RequestBody @Valid RetrospectCreateRequest request);
@Operation(summary = "회고 생성", description = "")
ResponseEntity<Void> createRetrospect(@PathVariable("spaceId") Long spaceId,
@RequestBody @Valid RetrospectCreateRequest request);
}
Loading

0 comments on commit 80514fa

Please sign in to comment.