From 3b8e2d17df600de2c22c6a254016eb10ce62df02 Mon Sep 17 00:00:00 2001 From: safalifter Date: Fri, 18 Aug 2023 22:28:27 +0300 Subject: [PATCH 1/2] test commit --- README.md | 1 + .../authservice/config/OpenApiConfig.java | 38 +++++++++++-------- .../src/main/resources/application.properties | 3 -- config/application.properties | 6 ++- .../jobservice/config/OpenApiConfig.java | 38 +++++++++++-------- .../src/main/resources/application.properties | 3 -- .../userservice/config/OpenApiConfig.java | 38 +++++++++++-------- .../src/main/resources/application.properties | 3 -- 8 files changed, 72 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 889e613..af2afa8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +# Link: https://github.com/devxsb/spring-boot-microservices # Spring Boot Microservices Project (Eureka Server, Config Server, API Gateway, Kafka, File Storage, JWT, Authentication, Authorization, Redis, Docker) diff --git a/auth-service/src/main/java/com/safalifter/authservice/config/OpenApiConfig.java b/auth-service/src/main/java/com/safalifter/authservice/config/OpenApiConfig.java index 5c0934e..9b83737 100644 --- a/auth-service/src/main/java/com/safalifter/authservice/config/OpenApiConfig.java +++ b/auth-service/src/main/java/com/safalifter/authservice/config/OpenApiConfig.java @@ -1,30 +1,36 @@ package com.safalifter.authservice.config; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; -import io.swagger.v3.oas.annotations.security.SecurityScheme; +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.info.License; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration -@SecurityScheme( - name = "Bearer Authentication", - type = SecuritySchemeType.HTTP, - bearerFormat = "JWT", - scheme = "bearer") public class OpenApiConfig { @Bean - public OpenAPI customOpenAPI(@Value("${application-description}") String description, - @Value("${application-version}") String version, - @Value("${application-license}") String license, - @Value("${application-title}") String title) { - return new OpenAPI() - .info(new Info().title(title) + public OpenAPI openAPI(@Value("${application-title}") String title, + @Value("${application-description}") String description, + @Value("${application-version}") String version, + @Value("${application-license}") String license) { + return new OpenAPI().addSecurityItem(new SecurityRequirement() + .addList("Bearer Authentication")) + .components(new Components().addSecuritySchemes + ("Bearer Authentication", createAPIKeyScheme())) + .info(new Info() + .title(title) .description(description) - .license(new License().name(license)) - .version(version)); + .version(version) + .license(new License().name(license))); } -} + + private SecurityScheme createAPIKeyScheme() { + return new SecurityScheme().type(SecurityScheme.Type.HTTP) + .bearerFormat("JWT") + .scheme("bearer"); + } +} \ No newline at end of file diff --git a/auth-service/src/main/resources/application.properties b/auth-service/src/main/resources/application.properties index 26d6feb..f00fa77 100644 --- a/auth-service/src/main/resources/application.properties +++ b/auth-service/src/main/resources/application.properties @@ -1,8 +1,5 @@ server.port=0 -application-description=Its Done UK Application -application-license=API Licence -application-version=1.0 application-title=Auth Service spring.application.name=auth-service diff --git a/config/application.properties b/config/application.properties index 7bdd698..f5eae18 100644 --- a/config/application.properties +++ b/config/application.properties @@ -5,4 +5,8 @@ spring.datasource.username=${POSTGRES_USER:postgres} spring.datasource.password=${POSTGRES_PASSWORD:55} eureka.instance.prefer-ip-address=true -eureka.client.service-url.default-zone=${EUREKA_URI:http://localhost:8761/eureka} \ No newline at end of file +eureka.client.service-url.default-zone=${EUREKA_URI:http://localhost:8761/eureka} + +application-description=Its Done UK Application +application-license=API Licence +application-version=1.0 \ No newline at end of file diff --git a/job-service/src/main/java/com/safalifter/jobservice/config/OpenApiConfig.java b/job-service/src/main/java/com/safalifter/jobservice/config/OpenApiConfig.java index e16aaad..b3375dd 100644 --- a/job-service/src/main/java/com/safalifter/jobservice/config/OpenApiConfig.java +++ b/job-service/src/main/java/com/safalifter/jobservice/config/OpenApiConfig.java @@ -1,30 +1,36 @@ package com.safalifter.jobservice.config; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; -import io.swagger.v3.oas.annotations.security.SecurityScheme; +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.info.License; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration -@SecurityScheme( - name = "Bearer Authentication", - type = SecuritySchemeType.HTTP, - bearerFormat = "JWT", - scheme = "bearer") public class OpenApiConfig { @Bean - public OpenAPI customOpenAPI(@Value("${application-description}") String description, - @Value("${application-version}") String version, - @Value("${application-license}") String license, - @Value("${application-title}") String title) { - return new OpenAPI() - .info(new Info().title(title) + public OpenAPI openAPI(@Value("${application-title}") String title, + @Value("${application-description}") String description, + @Value("${application-version}") String version, + @Value("${application-license}") String license) { + return new OpenAPI().addSecurityItem(new SecurityRequirement() + .addList("Bearer Authentication")) + .components(new Components().addSecuritySchemes + ("Bearer Authentication", createAPIKeyScheme())) + .info(new Info() + .title(title) .description(description) - .license(new License().name(license)) - .version(version)); + .version(version) + .license(new License().name(license))); } -} + + private SecurityScheme createAPIKeyScheme() { + return new SecurityScheme().type(SecurityScheme.Type.HTTP) + .bearerFormat("JWT") + .scheme("bearer"); + } +} \ No newline at end of file diff --git a/job-service/src/main/resources/application.properties b/job-service/src/main/resources/application.properties index e212ebf..059199b 100644 --- a/job-service/src/main/resources/application.properties +++ b/job-service/src/main/resources/application.properties @@ -1,8 +1,5 @@ server.port=0 -application-description=Its Done UK Application -application-license=API Licence -application-version=1.0 application-title=Job Service spring.application.name=job-service diff --git a/user-service/src/main/java/com/safalifter/userservice/config/OpenApiConfig.java b/user-service/src/main/java/com/safalifter/userservice/config/OpenApiConfig.java index addcb07..5abe487 100644 --- a/user-service/src/main/java/com/safalifter/userservice/config/OpenApiConfig.java +++ b/user-service/src/main/java/com/safalifter/userservice/config/OpenApiConfig.java @@ -1,30 +1,36 @@ package com.safalifter.userservice.config; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; -import io.swagger.v3.oas.annotations.security.SecurityScheme; +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.info.License; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration -@SecurityScheme( - name = "Bearer Authentication", - type = SecuritySchemeType.HTTP, - bearerFormat = "JWT", - scheme = "bearer") public class OpenApiConfig { @Bean - public OpenAPI customOpenAPI(@Value("${application-description}") String description, - @Value("${application-version}") String version, - @Value("${application-license}") String license, - @Value("${application-title}") String title) { - return new OpenAPI() - .info(new Info().title(title) + public OpenAPI openAPI(@Value("${application-title}") String title, + @Value("${application-description}") String description, + @Value("${application-version}") String version, + @Value("${application-license}") String license) { + return new OpenAPI().addSecurityItem(new SecurityRequirement() + .addList("Bearer Authentication")) + .components(new Components().addSecuritySchemes + ("Bearer Authentication", createAPIKeyScheme())) + .info(new Info() + .title(title) .description(description) - .license(new License().name(license)) - .version(version)); + .version(version) + .license(new License().name(license))); } -} + + private SecurityScheme createAPIKeyScheme() { + return new SecurityScheme().type(SecurityScheme.Type.HTTP) + .bearerFormat("JWT") + .scheme("bearer"); + } +} \ No newline at end of file diff --git a/user-service/src/main/resources/application.properties b/user-service/src/main/resources/application.properties index 76233dd..6098ecf 100644 --- a/user-service/src/main/resources/application.properties +++ b/user-service/src/main/resources/application.properties @@ -2,9 +2,6 @@ server.port=0 spring.application.name=user-service -application-description=Its Done UK Application -application-license=API Licence -application-version=1.0 application-title=User Service spring.config.import=configserver:http://localhost:8888/ \ No newline at end of file From 2b14ddda7a02d1a0df860616821c2bce3d36a1bb Mon Sep 17 00:00:00 2001 From: son1999tmgl <120165137+son1999tmgl@users.noreply.github.com> Date: Sat, 16 Nov 2024 10:15:02 +0700 Subject: [PATCH 2/2] b --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af2afa8..0c9404f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Link: https://github.com/devxsb/spring-boot-microservices +# Link: https://github.com/devxsb/spring-boot-microservices # Spring Boot Microservices Project (Eureka Server, Config Server, API Gateway, Kafka, File Storage, JWT, Authentication, Authorization, Redis, Docker)