github.com/TeaOSLab/EdgeNode@v1.3.8/internal/waf/checkpoints/request_remote_user.go (about)

     1  package checkpoints
     2  
     3  import (
     4  	"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
     5  	"github.com/TeaOSLab/EdgeNode/internal/waf/utils"
     6  	"github.com/iwind/TeaGo/maps"
     7  )
     8  
     9  type RequestRemoteUserCheckpoint struct {
    10  	Checkpoint
    11  }
    12  
    13  func (this *RequestRemoteUserCheckpoint) RequestValue(req requests.Request, param string, options maps.Map, ruleId int64) (value any, hasRequestBody bool, sysErr error, userErr error) {
    14  	username, _, ok := req.WAFRaw().BasicAuth()
    15  	if !ok {
    16  		value = ""
    17  		return
    18  	}
    19  	value = username
    20  	return
    21  }
    22  
    23  func (this *RequestRemoteUserCheckpoint) ResponseValue(req requests.Request, resp *requests.Response, param string, options maps.Map, ruleId int64) (value any, hasRequestBody bool, sysErr error, userErr error) {
    24  	if this.IsRequest() {
    25  		return this.RequestValue(req, param, options, ruleId)
    26  	}
    27  	return
    28  }
    29  
    30  func (this *RequestRemoteUserCheckpoint) CacheLife() utils.CacheLife {
    31  	return utils.CacheMiddleLife
    32  }