commit
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package kiz.app.api;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import kiz.app.dto.LoginRequest;
|
||||
@@ -12,15 +14,19 @@ import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/auth-service")
|
||||
public class LoginController {
|
||||
|
||||
private final LoginService loginService;
|
||||
|
||||
@GetMapping("/welcome")
|
||||
public String welcome(){
|
||||
return "welcome to the first service";
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
public TokenInfo login(@RequestBody LoginRequest loginRequest) {
|
||||
String memberId = loginRequest.getMemberId();
|
||||
String password = loginRequest.getPassword();
|
||||
public TokenInfo login(@Valid @RequestBody LoginRequest loginRequest) {
|
||||
String memberId = loginRequest.memberId();
|
||||
String password = loginRequest.password();
|
||||
TokenInfo tokenInfo = loginService.login(memberId, password);
|
||||
return tokenInfo;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package kiz.app.config;
|
||||
|
||||
import org.springframework.boot.autoconfigure.security.servlet.PathRequest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
@@ -15,7 +16,6 @@ import kiz.app.provider.JwtTokenProvider;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@RequiredArgsConstructor
|
||||
public class SecurityConfig {
|
||||
|
||||
@@ -29,9 +29,9 @@ public class SecurityConfig {
|
||||
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
.antMatchers("/auth/login").permitAll()
|
||||
.antMatchers("/**").permitAll()
|
||||
.antMatchers("/auth/test").hasRole("USER")
|
||||
.anyRequest().authenticated()
|
||||
//.anyRequest().authenticated()
|
||||
.and()
|
||||
.addFilterBefore(new JwtAuthenticationFilter(jwtTokenProvider), UsernamePasswordAuthenticationFilter.class);
|
||||
return http.build();
|
||||
@@ -42,4 +42,9 @@ public class SecurityConfig {
|
||||
return PasswordEncoderFactories.createDelegatingPasswordEncoder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WebSecurityCustomizer webSecurityCustomizer() {
|
||||
return (web -> web.ignoring().requestMatchers(PathRequest.toStaticResources().atCommonLocations()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package kiz.app.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
public record LoginRequest(
|
||||
@NotEmpty String memberId,
|
||||
@NotEmpty String password
|
||||
) {}
|
||||
|
||||
@Getter
|
||||
public class LoginRequest {
|
||||
private String memberId;
|
||||
private String password;
|
||||
}
|
||||
|
||||
@@ -20,17 +20,28 @@ public class GatewayConfig {
|
||||
@Bean
|
||||
public RouteLocator routes(RouteLocatorBuilder builder) {
|
||||
return builder.routes()
|
||||
.route("auth-service", r -> r.path("/auth-service/**")
|
||||
.route("auth-service", r -> r.path("/auth/**").and().method("GET")
|
||||
.filters(f -> f
|
||||
.filter(globalFilter.apply(new GlobalFilter.Config("auth", true, false)))
|
||||
.rewritePath("/auth-service/(?<segment>.*)", "/$\\{segment}"))
|
||||
.uri("lb://AUTH-SERVICE"))
|
||||
.route("member-service", r -> r.path("/member-service/**")
|
||||
.filter(globalFilter.apply(new GlobalFilter.Config("auth", true, true)))
|
||||
.rewritePath("/auth/(?<segment>.*)", "/$\\{segment}"))
|
||||
.uri("lb://AUTH-SERVICE/"))
|
||||
.route("member-service", r -> r.path("/member/**").and().method("GET")
|
||||
.filters(f -> f
|
||||
.filter(globalFilter.apply(new GlobalFilter.Config("member", true, false)))
|
||||
.filter(authFilter)
|
||||
.rewritePath("/member-service/(?<segment>.*)", "/$\\{segment}"))
|
||||
.filter(globalFilter.apply(new GlobalFilter.Config("member", true, true)))
|
||||
//.filter(authFilter)
|
||||
.rewritePath("/member/(?<segment>.*)", "/$\\{segment}"))
|
||||
.uri("lb://MEMBER-SERVICE"))
|
||||
.route("member-signup", r -> r.path("/member/signup").and().method("POST")
|
||||
.filters(f -> f
|
||||
.filter(globalFilter.apply(new GlobalFilter.Config("member", true, true)))
|
||||
.rewritePath("/member/(?<segment>.*)", "/$\\{segment}"))
|
||||
.uri("lb://MEMBER-SERVICE/"))
|
||||
.route("order-service", r -> r.path("/order/**").and().method("GET")
|
||||
.filters(f -> f
|
||||
.filter(globalFilter.apply(new GlobalFilter.Config("order", true, true)))
|
||||
//.filter(authFilter)
|
||||
.rewritePath("/order/(?<segment>.*)", "/$\\{segment}"))
|
||||
.uri("lb://ORDER-SERVICE"))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,12 @@ spring:
|
||||
config:
|
||||
activate:
|
||||
on-profile: local
|
||||
cloud:
|
||||
gateway:
|
||||
discovery:
|
||||
locator:
|
||||
enabled: true
|
||||
lowerCaseServiceId: true
|
||||
# cloud:
|
||||
# gateway:
|
||||
# default-filters:
|
||||
|
||||
28
http.rest
Normal file
28
http.rest
Normal file
@@ -0,0 +1,28 @@
|
||||
### LOGIN
|
||||
POST http://mindol.synology.me:8081/auth/login
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"memberId": "sample"
|
||||
}
|
||||
|
||||
|
||||
### POST
|
||||
POST http://mindol.synology.me:8081/member/signup
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"memberId": "test2",
|
||||
"password": "1234",
|
||||
"memberName" : "이민재",
|
||||
"email": "test@test.com"
|
||||
}
|
||||
|
||||
### GET
|
||||
http://mindol.synology.me:8081/auth/welcome
|
||||
|
||||
### GET
|
||||
http://mindol.synology.me:8081/member/welcome
|
||||
|
||||
### test
|
||||
https://openapi.naver.com/v1/nid/me
|
||||
@@ -2,7 +2,6 @@ package kiz.app.member.adapter.in.web;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import kiz.app.common.WebAdapter;
|
||||
@@ -11,7 +10,6 @@ import kiz.app.member.adapter.in.web.mapper.MemberWebMapper;
|
||||
import kiz.app.member.application.port.in.FindMemberUseCase;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequestMapping("/member-service")
|
||||
@WebAdapter
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package kiz.app.member.adapter.in.web;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import kiz.app.common.WebAdapter;
|
||||
@@ -10,7 +11,6 @@ import kiz.app.member.application.port.in.SignUpUseCase;
|
||||
import kiz.app.member.application.port.in.command.SignUpCommand;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequestMapping("/member-service")
|
||||
@WebAdapter
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -19,7 +19,7 @@ public class SignUpController {
|
||||
private final SignUpUseCase signUpUseCase;
|
||||
|
||||
@PostMapping("/signup")
|
||||
public Long signUp(@RequestBody SignUpCommand command) {
|
||||
public Long signUp(@Valid @RequestBody SignUpCommand command) {
|
||||
return signUpUseCase.signUp(command).getValue();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class MemberEntity {
|
||||
@Column(name = "password", length = 50, nullable = false)
|
||||
private String password;
|
||||
|
||||
@Column(name = "name", length = 20, nullable = false)
|
||||
@Column(name = "memberName", length = 20, nullable = false)
|
||||
private String memberName;
|
||||
|
||||
@Column(name = "email", length = 50, nullable = false)
|
||||
|
||||
@@ -3,51 +3,20 @@ package kiz.app.member.application.port.in.command;
|
||||
import java.time.LocalDate;
|
||||
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
import kiz.app.common.SelfValidating;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class SignUpCommand extends SelfValidating<SignUpCommand> {
|
||||
|
||||
@NotBlank
|
||||
private final String memberId;
|
||||
@NotBlank
|
||||
private final String password;
|
||||
@NotBlank
|
||||
private final String memberName;
|
||||
public record SignUpCommand (
|
||||
@NotEmpty
|
||||
String memberId,
|
||||
@NotEmpty
|
||||
String password,
|
||||
@NotEmpty
|
||||
String memberName,
|
||||
@Email
|
||||
private final String email;
|
||||
private final String phone;
|
||||
private final String zipCode;
|
||||
private final String address1;
|
||||
private final String address2;
|
||||
private final LocalDate birthday;
|
||||
|
||||
public SignUpCommand(
|
||||
String memberId,
|
||||
String password,
|
||||
String memberName,
|
||||
String email,
|
||||
String phone,
|
||||
String zipCode,
|
||||
String address1,
|
||||
String address2,
|
||||
LocalDate birthday
|
||||
) {
|
||||
this.memberId = memberId;
|
||||
this.password = password;
|
||||
this.memberName = memberName;
|
||||
this.email = email;
|
||||
this.phone = phone;
|
||||
this.zipCode = zipCode;
|
||||
this.address1 = address1;
|
||||
this.address2 = address2;
|
||||
this.birthday = birthday;
|
||||
this.validateSelf();
|
||||
}
|
||||
|
||||
}
|
||||
String email,
|
||||
String phone,
|
||||
String zipCode,
|
||||
String address1,
|
||||
String address2,
|
||||
LocalDate birthday
|
||||
) {}
|
||||
|
||||
@@ -18,15 +18,15 @@ public class SignUpService implements SignUpUseCase {
|
||||
public MemberId signUp(SignUpCommand command) {
|
||||
return signUpPort.signUp(
|
||||
Member.createMember(
|
||||
command.getMemberId(),
|
||||
command.getPassword(),
|
||||
command.getMemberName(),
|
||||
command.getEmail(),
|
||||
command.getPhone(),
|
||||
command.getZipCode(),
|
||||
command.getAddress1(),
|
||||
command.getAddress2(),
|
||||
command.getBirthday()));
|
||||
command.memberId(),
|
||||
command.password(),
|
||||
command.memberName(),
|
||||
command.email(),
|
||||
command.phone(),
|
||||
command.zipCode(),
|
||||
command.address1(),
|
||||
command.address2(),
|
||||
command.birthday()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ spring:
|
||||
url: jdbc:mariadb://mindol.synology.me:3307/kiz_space
|
||||
driver-class-name: org.mariadb.jdbc.Driver
|
||||
username: mindolangel
|
||||
password: $awlswn1318a
|
||||
password: $awlswn1318A
|
||||
# driver-class-name: org.h2.Driver
|
||||
# url: jdbc:h2:mem:userdb;DB_CLOSE_DELAY=-1
|
||||
# username: sa
|
||||
|
||||
@@ -25,6 +25,7 @@ ext {
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
||||
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
|
||||
compileOnly 'org.projectlombok:lombok'
|
||||
developmentOnly 'org.springframework.boot:spring-boot-devtools'
|
||||
|
||||
14
order-service/src/main/java/kiz/app/api/OrderController.java
Normal file
14
order-service/src/main/java/kiz/app/api/OrderController.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package kiz.app.api;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class OrderController {
|
||||
|
||||
@GetMapping("/welcome")
|
||||
public String welcome(){
|
||||
return "welcome to the first service";
|
||||
}
|
||||
|
||||
}
|
||||
15
rest-response.http
Normal file
15
rest-response.http
Normal file
@@ -0,0 +1,15 @@
|
||||
HTTP/1.1 500 Internal Server Error
|
||||
Vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers
|
||||
Content-Type: application/json
|
||||
Content-Length: 1981
|
||||
connection: close
|
||||
|
||||
{
|
||||
"timestamp": 1672027020277,
|
||||
"path": "/auth/login",
|
||||
"status": 500,
|
||||
"error": "Internal Server Error",
|
||||
"message": "finishConnect(..) failed: Connection refused: mindol.synology.me/121.143.34.232:33983",
|
||||
"requestId": "9867d1f6-36",
|
||||
"trace": "io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: mindol.synology.me/121.143.34.232:33983\n\tSuppressed: The stacktrace has been enhanced by Reactor, refer to additional information below: \nError has been observed at the following site(s):\n\t*__checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]\n\t*__checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]\n\t*__checkpoint ⇢ HTTP POST \"/auth/login\" [ExceptionHandlingWebHandler]\nOriginal Stack Trace:\nCaused by: java.net.ConnectException: finishConnect(..) failed: Connection refused\n\tat io.netty.channel.unix.Errors.newConnectException0(Errors.java:155)\n\tat io.netty.channel.unix.Errors.handleConnectErrno(Errors.java:128)\n\tat io.netty.channel.unix.Socket.finishConnect(Socket.java:359)\n\tat io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.doFinishConnect(AbstractEpollChannel.java:710)\n\tat io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.finishConnect(AbstractEpollChannel.java:687)\n\tat io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.epollOutReady(AbstractEpollChannel.java:567)\n\tat io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:489)\n\tat io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:397)\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)\n\tat io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\n\tat io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)\n\tat java.base/java.lang.Thread.run(Unknown Source)\n"
|
||||
}
|
||||
BIN
zulu-repo_1.0.0-3_all.deb
Normal file
BIN
zulu-repo_1.0.0-3_all.deb
Normal file
Binary file not shown.
Reference in New Issue
Block a user