First working version of token-based security