Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Login to access Swagger documentation #7496

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/init/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func Routers() *gin.Engine {

swaggerRouter := Router.Group("1panel")
docs.SwaggerInfo.BasePath = "/api/v1"
swaggerRouter.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
swaggerRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
PublicGroup := Router.Group("")
{
PublicGroup.GET("/health", func(c *gin.Context) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided diff shows changes that need to be addressed concerning function parameters and middleware usage:

  1. Middleware Usage Update:
    The line swaggerRouter.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler)) has been updated with middleware.JwtAuth(), middleware.SessionAuth(). This suggests adding authentication middleware before serving Swagger UI.

  2. Security Considerations:
    Adding authentication via JWT (middleware.JwtAuth()) ensures that only authorized users can access the Swagger interface, improving security.

  3. Session Authentication (if applicable):
    Ensuring session authenticity using middleware.SessionAuth() is another layer of protection, though this would depend on how session handling is implemented elsewhere in the application.

  4. Potential Performance Impact:
    While these changes improve security, they might introduce some performance overhead due to added HTTP handlers (authentication checks). It's important to measure if there's any significant impact and consider caching strategies where appropriate.

Overall, these modifications enhance both functionality and security but should be thoroughly tested to ensure they meet expectations without negatively affecting other parts of the system.

Expand Down
Loading