Skip to content

Commit

Permalink
swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
JuseungL committed Jul 31, 2024
1 parent 5421723 commit 6cc868e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
22 changes: 4 additions & 18 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,8 @@ jobs:
port: ${{ secrets.SSH_PORT }}
script: |
docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" -p "${{ secrets.DOCKERHUB_TOKEN }}"
CONTAINER_NAME="backend"
sudo docker stop $(sudo docker ps -q) || true
sudo docker rm $(sudo docker ps -a -q) || true
sudo docker rmi $(sudo docker images -q) || true
cd /workspace
sudo docker-compose down
sudo docker rmi "${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:backend" || true
sudo docker pull "${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:backend"
sudo docker run -d \
--name "$CONTAINER_NAME" \
-p 80:8080 \
--log-driver=awslogs \
--log-opt awslogs-group=/fledge/backend \
--log-opt awslogs-region=ap-northeast-2 \
--log-opt awslogs-stream="$CONTAINER_NAME" \
"${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:backend"
sudo docker-compose up -d
31 changes: 24 additions & 7 deletions src/main/java/lion6/DrinkGuide/common/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,40 @@
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;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI openAPI() {
return new OpenAPI()
.components(new Components())
.info(apiInfo());
}

private static final String BEARER_TOKEN_PREFIX = "Bearer";
private Info apiInfo() {
return new Info()
.title("DrinkGuide API Specification")
.description("API specification for the \"DrinkGuide\" Service.\n\n" +
"Health Check - [https://www.drinkguide.store/api/v1/health](https://www.drinkguide.store/api/v1/health)")
.version("1.0.0");
}
@Bean
public OpenAPI openAPI() {
String securityJwtName = "JWT";
SecurityRequirement securityRequirement = new SecurityRequirement().addList(securityJwtName);
Components components = new Components()
.addSecuritySchemes(securityJwtName, new SecurityScheme()
.name(securityJwtName)
.type(SecurityScheme.Type.HTTP)
.scheme(BEARER_TOKEN_PREFIX)
.bearerFormat(securityJwtName));

return new OpenAPI()
.info(apiInfo())
.addServersItem(new Server().url("/"))
.addSecurityItem(securityRequirement)
.components(components);
}



}
1 change: 1 addition & 0 deletions src/main/java/lion6/DrinkGuide/common/jwt/JwtFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
Member jwtInfo = Member.builder()
.roleType(role)
.build();

CustomOAuth2User customOAuth2User = new CustomOAuth2User(jwtInfo);
Authentication authentication = new UsernamePasswordAuthenticationToken(memberId, null, customOAuth2User.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authentication);
Expand Down

0 comments on commit 6cc868e

Please sign in to comment.