// Verify verifies that the request has the required bearer token. If not, false is returned.
Verify verifies that the request has the required bearer token. If not, false is returned.
// Verify verifies that the request has the required bearer token . If not false is returned .
func (h *TokenVerifier) Verify(req *http.Request) bool {
	if len(h.authTokens) == 0 {
		logger.Debugf("[%s] No auth token required.", h.endpoint)
		return true
	}
	logger.Debugf("[%s] Auth tokens required: %s", h.endpoint, h.authTokens)
	actHdr := req.Header.Get(authHeader)
	if actHdr == "" {
		logger.Debugf("[%s] Bearer token not found in header", h.endpoint)
		return false
	}
	for _, token := range h.authTokens {
		logger.Debugf("[%s] Checking token %s", h.endpoint, token)
		if subtle.ConstantTimeCompare([]byte(actHdr), []byte(tokenPrefix+token)) == 1 {
			logger.Debugf("[%s] Found token %s", h.endpoint, token)
			return true
		}
	}
	return false
}
func ( h * TokenVerifier ) Verify ( req * http . Request ) bool { if len ( h . authTokens ) == 0 { logger . Debugf ( " " , h . endpoint ) return true } logger . Debugf ( " " , h . endpoint , h . authTokens ) actHdr := req . Header . Get ( authHeader ) if actHdr == " " { logger . Debugf ( " " , h . endpoint ) return false } for _ , token := range h . authTokens { logger . Debugf ( " " , h . endpoint , token ) if subtle . ConstantTimeCompare ( [ ] byte ( actHdr ) , [ ] byte ( tokenPrefix + token ) ) == 1 { logger . Debugf ( " " , h . endpoint , token ) return true } } return false }
Verify verifies that the request has the required bearer token.
Verify verifies that the request has the required bearer token .
// Open access. // Compare the header against all tokens. If any match then we allow the request.