— ruby — 1 min read
A brief note and tutorial about OmniAuth Identity. How to use it in conjunction with Sinatra. With no to minor modifications you can use it with Padrino as well.
This Railcast on Omniauth helped to understand most of it.
I would like to highlight the major bits of source here, although, you can clone working App and tailor it to your fit. The sample app uses sqlite for storage.
The important bits of it are User
model, Authentication
class and auth callback in the controller. Create user model that extends OmniAuth::Identity::Models::ActiveRecord
Authentication model for User class should look like
Finally the sinatra app definition which defines basic role based auth.