Ideally, no punishment at all, and only rehabilitation.
Criminals are always either made by environmental pressures, or they are made by bad genetics. There is no reason for anyone to be criminal other than these two.
If a person is made to commit a crime by their environment, well it is not very fair to punish them, is it? It is the fault of their environment - you should try and fix that instead and make sure that the person does not commit another crime again. If I had a hungry child and the only way I could feed them was by assaulting a security guard and shoplifting, you can't really blame me for doing that. No sane person could guarantee that they wouldn't do the same if they were in my shoes.
On the other hand, if a person commits a crime because they just can't help it and they are 'broken' in some way, it is still not fair to punish them for it, is it? They just can't help it. If, hypothetically, my body was defective such that I breathe out chlorine gas and people near me die because of that, you can't really blame me for that, can you? I can't help but breathe. It is not fair to punish people for that which they can't help but do. You should instead make sure they cannot hurt others without punishing them.
Therefore, it logically follows that punishing a criminal is always morally unjust. Preventing crimes is the moral responsibility of society as a whole, and punishment is the state lashing out to mask its incompetence.