Demonstrate the Simple Token Authentication usage in a Rails 5 app.
This application aims at demonstrating how token authentication can be implemented and tested and documented in a Rails 5 application.
- Implementation: makes use of Simple Token Authentication
- Testing and documentation: are performed using RSpec
rackup -p 3000 # see http://localhost:3000
Click the button below to automatically set up the demo in an app running on your Heroku account.
Alternatively, you can manually create a Heroku app and use Git to push and deploy.
The application specification can be read online or generated locally:
# Run the test suite and output the app specification
rake
The demo user is called Alice, she doesn't need to authenticate to accede /
, however she can do it through token authentication. See the home page with authentication and without authentication.
On the contrary, she must authenticate in ordder to accede to /restricted_index
. Of course, she can do it through token authentication. See the restricted home page with authentication and without authentication.
Interested in using hooks? Check your server logs for messages of successful token authentication!
This application is meant to be used as an example (think "Hello, World!") to implement token authentication features. The main goal is then to keep the implmenetation of each feature as simple as possible to make it as easy to follow as possible. Please keep that in mind when enhancing this demo!
Only one of the [many possible token authentication scenarios][scenarios] is demonstrated so far. Contributions are welcome!
Thank you to @johnmosesman for contributing testing documentation to Simple Token Authentication, that was the inspiration of this demo!
Demo: Rails 5 Token Authentication
Copyright (C) 2016 Gonzalo Bulnes Guilpain
This application code is placed in the public domain.