Should your advisor be an author on your papers?

Authorship seems to be a complicated business in science.  What is required to qualify for authorship?  The first time I gave my thesis advisor a draft with his name on it, he politely told me that he liked it very much but it wasn't necessary to include him as an author since the research and writing had been done by me (this even despite the fact that the original idea for the project was his).  In the end, he became more closely involved in some of the work and the revision of the paper, and we agreed that he should be an author.  But that experience reinforced for me the high threshold for authorship that is usually expected in mathematics.
I was surprised to find that the "accepted" answer to this question on academia.stackexchange.com
What are the requirements for a supervisor to be included as an author on a paper, as opposed to just appearing in the acknowledgements?
says
As a graduate student, you can expect that your advisor will appear as an author on all of your papers.  He is providing your funding, your resources, and (ostensibly) is the Primary Investigator on whatever project you happen to be working on. Even if he does not contribute, you are working on his project, and he wrote the grant for it, not you.
Really?
I was relieved to see that the currently highest-voted answer (though by a narrow margin) states
In theoretical computer science (and mathematics), it is generally considered unethical to list someone as a co-author who has not made a novel and significant intellectual contribution to the paper. In particular, merely funding the research is not considered an intellectual contribution. Adding a supervisor's name to a paper to which they have not directly, intellectually contributed is lying.
Clearly, the difference in perspective is based on different understandings of what authorship means.  However, it seems clear that one cannot be an author of a document that one did not write any part of.  And apparently KAUST's administration agrees with me on that count; in KAUST's "Code of Practice on Responsible Conduct of Research", one finds the following:
...the practice of gift or honorary authorship (that is the listing as an author by virtue of their reputation or seniority, e.g. as head of the laboratory, of someone who does not qualify as an author) [is] unacceptable.
And furthermore
The list of authors should be limited to those researchers who have made a substantial and identifiable intellectual contribution to the research upon which a publication is based.
At mathoverflow, more interesting answers are given, including this highly-voted point of view:
...as a rule the supervisor should not be a co-author in the main paper taken from a student's thesis, even if he has contributed substantially to it...
and this one, which aligns with my own perspective:
...if I suggest a problem and react to discussions with a student by giving suggestions and helping with background and helping with proofs, then I will not be a co-author.  If I do work by myself on the paper, doing important technical work, then I must be a co-author.