The Supreme Court ruled in favour of the US government in a case that civil liberties groups said significantly diminished the due process rights of lawful permanent residents.