Generally, everything is legal until some government body writes and passes legislation making it illegal. It is legal because it hasn't been made illegal. If you donate money to a political candidate or party, that gets published online as well; it's actually illegal not to make that information public.