Keep in mind this isn't a body search or anything. Security has you form a line, and they have you open up all your bags/ backpacks/ purses, etc. and they do a quick scan of the contents. Nobody gets "patted down" or has their stuff dumped out on a table.
Whether it is legal or not...got me. However, since 9/11 Disney has implemented certain security procedures, this "bag search" being one of them. Remember afer 9/11 there was a lot of hype about how vunerable theme parks would be to attacks, so Disney got as pro-active as they could while trying to "keep the magic".
In my opinion, this is not a big deal. The search is done kind of flipantly, and I have never seen anyone have any problems getting through (this includes people who bring food, drinks, and other "prohibited" items), and it takes a whopping five minutes to be processed.
Hope this helps -
Mel