Minor fix to security middleware