Skip to content

Commit d8eefda

Browse files
authored
feat: added jwt config (#2)
2 parents 25ef860 + 77cf54f commit d8eefda

File tree

5 files changed

+50
-1
lines changed

5 files changed

+50
-1
lines changed

pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
<description>FIAP SOAT1 2023 - Group 63 - Payment microservice</description>
1616
<properties>
1717
<java.version>17</java.version>
18+
19+
<sonar.coverage.exclusions>
20+
**/config/*
21+
</sonar.coverage.exclusions>
1822
</properties>
1923

2024
<repositories>
@@ -28,7 +32,7 @@
2832
<dependency>
2933
<groupId>com.github.soat-tech-challenge</groupId>
3034
<artifactId>service-common</artifactId>
31-
<version>4.1.0</version>
35+
<version>4.2.0</version>
3236
</dependency>
3337
<dependency>
3438
<groupId>org.springframework.boot</groupId>
@@ -178,6 +182,8 @@
178182
<exclude>**/br/com/grupo63/techchallenge/payment/api/controller/dto/PaymentStatusResponseDTO.class</exclude>
179183
<exclude>**/br/com/grupo63/techchallenge/payment/api/controller/dto/QRCodeResponseDTO.class</exclude>
180184
<exclude>**/br/com/grupo63/techchallenge/payment/gateway/order/dto/OrderDTO.class</exclude>
185+
<exclude>**/br/com/grupo63/techchallenge/payment/config/JwtFilterConfig.class</exclude>
186+
<exclude>**/br/com/grupo63/techchallenge/payment/config/JwtService.class</exclude>
181187
<exclude>**/br/com/grupo63/techchallenge/payment/ServicePaymentApplication.class</exclude>
182188
</excludes>
183189
</configuration>

src/main/java/br/com/grupo63/techchallenge/payment/ServicePaymentApplication.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
package br.com.grupo63.techchallenge.payment;
22

3+
import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn;
4+
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
5+
import io.swagger.v3.oas.annotations.security.SecurityScheme;
36
import org.springframework.boot.SpringApplication;
47
import org.springframework.boot.autoconfigure.SpringBootApplication;
58
import org.springframework.cloud.openfeign.EnableFeignClients;
69

710
@SpringBootApplication
811
@EnableFeignClients
12+
@SecurityScheme(
13+
name = "bearerAuth",
14+
type = SecuritySchemeType.HTTP,
15+
scheme = "bearer",
16+
bearerFormat = "JWT",
17+
in = SecuritySchemeIn.HEADER
18+
)
919
public class ServicePaymentApplication {
1020

1121
public static void main(String[] args) {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package br.com.grupo63.techchallenge.payment.config;
2+
3+
import br.com.grupo63.techchallenge.common.config.JwtFilter;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.boot.web.servlet.FilterRegistrationBean;
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.context.annotation.Configuration;
8+
9+
import java.util.List;
10+
11+
@Configuration
12+
public class JwtFilterConfig {
13+
14+
@Autowired
15+
private JwtService jwtService;
16+
17+
@Bean
18+
public FilterRegistrationBean<JwtFilter> jwtFilterFilterRegistrationBean() {
19+
FilterRegistrationBean<JwtFilter> jwtFilterFilterRegistrationBean = new FilterRegistrationBean<>();
20+
jwtFilterFilterRegistrationBean.setFilter(new JwtFilter(jwtService));
21+
jwtFilterFilterRegistrationBean.setUrlPatterns(List.of("/payments/initialize"));
22+
return jwtFilterFilterRegistrationBean;
23+
}
24+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package br.com.grupo63.techchallenge.payment.config;
2+
3+
import org.springframework.stereotype.Service;
4+
5+
@Service
6+
public class JwtService extends br.com.grupo63.techchallenge.common.config.JwtService {
7+
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sonar.exclusions=src/java/br/com/grupo63/techchallenge/payment/config/**

0 commit comments

Comments
 (0)