-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Customizing routes
felipeelias edited this page Jun 4, 2012
·
7 revisions
Version > 0.5
Doorkeeper routes accepts few customization options for generating routes in your application:
The basic generated routes are:
# routes.rb
Rails.application.routes.draw do
use_doorkeeper
end
generates:
GET /oauth/authorize
POST /oauth/authorize
DELETE /oauth/authorize
POST /oauth/token
resources /oauth/applications
You may want to change the controllers to you custom controllers with:
Rails.application.routes.draw do
use_doorkeeper do
# it accepts :authorizations, :tokens, :applications and :authorized_applications
controllers :applications => 'custom_applications'
end
end
You'll need a CustomApplicationsController
class in your app/controllers
. If you want to extend the default behaviour, just inherit from Doorkeeper::ApplicationsController
, for example:
class CustomApplicationsController < Doorkeeper::ApplicationsController
end
If can change the alias options with as
:
Rails.application.routes.draw do
use_doorkeeper do
# it accepts :authorizations, :tokens, :applications and :authorized_applications
as :authorizations => 'custom_auth', :tokens => 'custom_token'
end
end
If you want to skip some routes and provide your own routes, use skip_controllers
option:
Rails.application.routes.draw do
use_doorkeeper do
# it accepts :authorizations, :tokens, :applications and :authorized_applications
skip_controllers :applications, :authorized_applications
end
end
You can namespace doorkeeper routes just like you do in the usual rails routes:
Rails.application.routes.draw do
scope 'space' do
use_doorkeeper
end
end
This will generate:
GET /space/oauth/authorize
POST /space/oauth/authorize
DELETE /space/oauth/authorize
POST /space/oauth/token
resources /space/oauth/applications
This also applies to constraints too.