Rails is the most widely used framework in the ruby ecosystem. Its feature and capabilities are wide, and as a consequence, most of the OAuth libraries which work in rails, only work in Rails (ex: doorkeeper). The same can be said of the authentication case (ex: devise)
rodauth-rails changed that for rodauth
. It integrates rodauth
with the rails feature set, by bringing:
and everything that one can expect from a rails app.
First thing you’ll have to do is install and integrate rodauth-rails.
Once you do it, you can then:
> rails generate rodauth:oauth:install
This will:
rodauth-oauth
does not use them internally, so feel free to update and use them yourself);> rails generate rodauth:oauth:views
This will:
app/views
with the authorize form;-a
or --features oauth_applications
;which you can then tweak according to your requirements.
rodauth
-specific configuration can be found under lib/rodauth_app.rb
. It’s there where you’ll have to enable the feature:
# in lib/rodauth_app.rb
plugin :rodauth do
enable :oauth_authorization_code_grant
# ...
# you can also add these overrides, so that +current_oauth_account+ and
# +current_oauth_application+ controller helpers retur active record
# instances instead:
oauth_account_ds { |id| Account.where(account_id_column => id) }
oauth_application_ds { |id| OAuthApplication.where(oauth_applications_id_column => id) }
And that’s it, really.
Check out this blog post on how to use rodauth-oauth with rails and rodauth.