// IsAuthRequired return true if authorization is required for the given endpoint/method.
IsAuthRequired return true if authorization is required for the given endpoint/method.
// IsAuthRequired return true if authorization is required for the given endpoint / method .
func (m *TokenManager) IsAuthRequired(endpoint, method string) (bool, error) {
	for _, def := range m.tokenDefs {
		ok := def.expr.MatchString(endpoint)
		if !ok {
			continue
		}
		switch method {
		case http.MethodGet:
			if len(def.readTokens) > 0 {
				logger.Debugf("[%s] Authorization token(s) required for %s: %s", endpoint, method, def.readTokens)
				return true, nil
			}
		case http.MethodPost:
			if len(def.writeTokens) > 0 {
				logger.Debugf("[%s] Authorization token(s) required for %s: %s", endpoint, method, def.writeTokens)
				return true, nil
			}
		default:
			return false, fmt.Errorf("unsupported HTTP method [%s]", method)
		}
	}
	logger.Debugf("[%s] Authorization not required for %s", endpoint, method)
	return false, nil
}
func ( m * TokenManager ) IsAuthRequired ( endpoint , method string ) ( bool , error ) { for _ , def := range m . tokenDefs { ok := def . expr . MatchString ( endpoint ) if ! ok { continue } switch method { case http . MethodGet : if len ( def . readTokens ) > 0 { logger . Debugf ( " " , endpoint , method , def . readTokens ) return true , nil } case http . MethodPost : if len ( def . writeTokens ) > 0 { logger . Debugf ( " " , endpoint , method , def . writeTokens ) return true , nil } default : return false , fmt . Errorf ( " " , method ) } } logger . Debugf ( " " , endpoint , method ) return false , nil }
IsAuthRequired return true if authorization is required for the given endpoint/method.
IsAuthRequired return true if authorization is required for the given endpoint / method .