Skip to content

Commit

Permalink
swagger configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
indraniBan authored and indraniBan committed Jun 18, 2024
1 parent e9c0285 commit 8d28f74
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/main/java/com/iemr/mmu/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.iemr.mmu.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

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;

@Configuration
public class SwaggerConfig {

@Bean
public OpenAPI customOpenAPI() {
return new OpenAPI().info(new
Info().title("MMU API").version("version").description("A microservice for the creation and management of beneficiaries."))
.addSecurityItem(new SecurityRequirement().addList("my security"))
.components(new Components().addSecuritySchemes("my security",
new SecurityScheme().name("my security").type(SecurityScheme.Type.HTTP).scheme("bearer")));
}

}
16 changes: 14 additions & 2 deletions src/main/java/com/iemr/mmu/utils/http/HttpInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
if (request.getRequestURI().toLowerCase().contains("swagger-ui"))
return status;

String authorization = request.getHeader("Authorization");
// String authorization = request.getHeader("Authorization");
String authorization = null;
String preAuth = request.getHeader("Authorization");
if(null != preAuth && preAuth.contains("Bearer "))
authorization=preAuth.replace("Bearer ", "");
else
authorization = preAuth;
if (!request.getMethod().equalsIgnoreCase("OPTIONS")) {
try {
String[] requestURIParts = request.getRequestURI().split("/");
Expand Down Expand Up @@ -108,7 +114,13 @@ public void postHandle(HttpServletRequest request, HttpServletResponse response,
logger.info("http interceptor - post Handle");
try {

String authorization = request.getHeader("Authorization");
// String authorization = request.getHeader("Authorization");
String authorization = null;
String postAuth = request.getHeader("Authorization");
if(null != postAuth && postAuth.contains("Bearer "))
authorization=postAuth.replace("Bearer ", "");
else
authorization = postAuth;
logger.debug("RequestURI::" + request.getRequestURI() + " || Authorization ::" + authorization);
if (authorization != null) {
// redisStorage.updateConcurrentSessionObject(redisStorage.getSessionObject(authorization));
Expand Down

0 comments on commit 8d28f74

Please sign in to comment.