Today, I talked with Rick Betzel (https://www.richardfbetzel.com) about authorship.
Authorship is the most important academic currency. It is the main way of performance evaluation and rankings for positions. There are many differences between disciplines, but generally, the first (usually the person who did the work) and last (usually the person who advised and oversaw the project from start to end) author position are the most important. The middle authors should have made significant intellectual contributions to the project. Everybody else goes in the acknowledgement section.
But of course it is not always that easy. Watch our discussion for many different cases with conflict potential:
The most important thing is to discuss authorship with the other people involved, ideally already when distributing the work and responsibilities. Never take for granted that other people agree with you on this.
Further readings:
General recommendations: http://www.icmje.org/icmje-recommendations.pdf
Interesting point system of the Kosslyn lab: https://kosslynlab.fas.harvard.edu/files/kosslynlab/files/authorship_criteria_nov02.pdf