Rework authentication.

- Use json.
- Use a new transaction mechanism for multi step commands.