I believe the Iraq war had Congressional approval. Whether or not their was UN approval is a matter of debate. Libya had UN approval, but Obama never ran it by Congress first (who probably would have gone along with it anyway).
With regards to Congress: Technically, I'm not sure how much the Congressional thing really matters since we've pretty much abandoned the notion of a formal declaration of war. We weren't technically at war with Korea, Vietnam, Iraq either time, or anybody else we've fought since WWII. It has become customary to get congressional approval for "police actions", but I don't know if it's actually required. Like everything else in Washington, it honestly depends on who's in power and who's complaining. .
As for the UN: (like anybody really gives a shit). The legality of a war has a lot to do with whether or not it would constitute a war crime. In this instance, the US is pretty much in line with international law. The Afghan war, probably, as one could articulate a threat from the large AQ presence. Iraq is a pretty big question mark. As I understand it, for a war to be lawful there has to be approval form the UN or an imminent threat. Barring that, it would be considered a war of aggression and therefore a war crime. The nutshell version as I understand it is that the UN issued a laundry list of resolutions pertaining to Iraq after Gulf War I. These were specific to maintaining peace in the region. Colin Powell's waving around of that anthrax vial was the precursor to UN 1441, which basically said that Iraq was in violation of the earlier resolutions and constituted a breech of the peace. However, the consensus appears to be that 1441 did not authorized a use of force. Presumably, another resolution would have been called for specifically authorizing military action. Dumbass's justifications were that Iraq was not in compliance with the UN and that automatically authorized military intervention, and, that the provisions of the 1990 resolutions which he was in violation of also allowed for that intervention. There is a legal rationale behind it, it's not something they just pulled out of their ass, but the opinion seems to be that if it were questioned in international court, the invasion would have been considered unlawful. The 1990 resolutions were likely confined to the resolution to GWI, and 1441 didn't designate the US as the enforcer of any provisions. Basically he had a legal leg to stand on, but it was really wobbly.
Honestly, SnakeEyes probably has a better understanding of W's justification under the UN. I'd be curious to here the pro-Bush side from a true-believer.