I've never seen it at city-owned libraries, but IME it's fairly common for state universities to require a student ID before entering their libraries, classroom buildings, and even sometimes before entering the campus at all.
I know universities are somewhat of a different environment, but it does point out that restricting public access to publicly-funded property isn't as wildly farfetched and unacceptable as some other comments in this thread portray.