If using dried beans, soak them overnight in plenty of water, then drain and rinse.
Heat olive oil in a large pot over medium heat.
Add pancetta or bacon and cook until lightly browned and fragrant.
Stir in leeks, onion, carrots, celery, garlic, and rosemary.
Cook over medium-low heat for about 10 minutes, stirring occasionally, until vegetables are softened.
Add the beans, broth, bay leaves, salt, and pepper.
Bring to a gentle boil, then reduce heat and simmer partially covered.
Simmer for about 90 minutes if using dried beans, or 45 minutes if using canned beans, until beans are tender and flavors are well developed.
Remove bay leaves and let the soup rest off the heat for 10 minutes.
Taste and adjust seasoning if needed.
Serve hot with grated Parmesan and a drizzle of olive oil.