mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2026-05-06 22:12:23 +08:00
- Added `InitTokenRouter` to define the `/token/short` endpoint for issuing short tokens. - Created `IssueShortToken` function to handle short token generation and response. - Updated WebSocket middleware to require short token for authentication, preventing CSWSH attacks. - Modified user store and login handling to integrate short token functionality. - Enhanced documentation to reflect changes in WebSocket security requirements.
22 lines
370 B
Go
22 lines
370 B
Go
package middleware
|
|
|
|
import (
|
|
"io"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func init() {
|
|
gin.SetMode(gin.TestMode)
|
|
}
|
|
|
|
func newTestGinContext(t *testing.T, method, url string, body io.Reader) *gin.Context {
|
|
t.Helper()
|
|
w := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(w)
|
|
c.Request = httptest.NewRequest(method, url, body)
|
|
return c
|
|
}
|