-f
Build docker and publish / build (20.15.1) (push) Failing after 25s

This commit is contained in:
2025-10-14 08:17:02 -07:00
parent 42061e38c0
commit dca32cd11c
21 changed files with 374 additions and 85 deletions
+15 -7
View File
@@ -28,22 +28,30 @@ const (
func DeviceMiddleware(srvCtx *svc.ServiceContext) func(c *gin.Context) {
return func(c *gin.Context) {
loginType := c.GetString(string(constant.LoginType))
if loginType == "" {
loginType = c.GetHeader("Login-Type")
}
if loginType != "device" {
if !srvCtx.Config.Device.Enable {
c.Next()
return
}
c.Request = c.Request.WithContext(context.WithValue(c.Request.Context(), constant.LoginType, loginType))
if srvCtx.Config.Device.SecuritySecret == "" {
result.HttpResult(c, nil, errors.Wrapf(xerr.NewErrCode(xerr.SecretIsEmpty), "Secret is empty"))
c.Abort()
return
}
if !srvCtx.Config.Device.Enable || srvCtx.Config.Device.SecuritySecret == "" {
ctx := c.Request.Context()
if ctx.Value(constant.CtxKeyUser) == nil && c.GetHeader("Login-Type") != "" {
ctx = context.WithValue(ctx, constant.LoginType, c.GetHeader("Login-Type"))
c.Request = c.Request.WithContext(ctx)
}
loginType, ok := ctx.Value(constant.LoginType).(string)
if !ok || loginType != "device" {
c.Next()
return
}
rw := NewResponseWriter(c, srvCtx)
if !rw.Decrypt() {
result.HttpResult(c, nil, errors.Wrapf(xerr.NewErrCode(xerr.InvalidCiphertext), "Invalid ciphertext"))