Configuration
Before you're able to use Doorkeeper, you need to configure how resource owners (users) can be authenticated and who can manage such applications.
Resource Owner Authentication
This configuration should do two things:
Return the user is currently authenticated
Redirect the user to the authentication page
If you're using devise, one option is to write the following:
Doorkeeper.configure do
resource_owner_authenticator do
current_user || warden.authenticate!(scope: :user)
end
endThe block above runs in the context of your application so you have access to your models, session and routes helpers. However, it is not run in the context of the ApplicationController which means that it doesn't have access to the methods defined over there.
You may want to check other ways of authentication here.
Application Management Authentication
By default, the applications list in /oauth/applications is unavailable. To let users see and manage all applications, you should configure admin_authenticator block:
Doorkeeper.configure do
admin_authenticator do |_routes|
current_user || warden.authenticate!(scope: :user)
end
endThe block follows the same rules as resource_owner_authenticator block.
Configuration overview
The Doorkeeper.configure block in config/initializers/doorkeeper.rb is the central place for all Doorkeeper settings. Below is a high-level summary of the configuration categories available. For detailed information on each topic, follow the cross-links.
Token settings — expiration times, token generation, reuse, and revocation policies. See Other Configurations and Token Revocation.
Grant flows — enabled grant types (authorization code, client credentials, implicit, password) and per-client grant flow restrictions. See Other Configurations.
Scopes — default and optional scopes, scope enforcement, and scopes by grant type. See Scopes.
Redirect URIs — SSL enforcement, forbidden URI schemes, and blank redirect URI handling. See Other Configurations.
Application ownership — opt-in application owner association with optional confirmation. See Models.
Token introspection — custom introspection response fields and access control. See Token Introspection.
ORM and models — ORM selection (
:active_record), custom model classes forAccessToken,AccessGrant, andApplication. See Models.Controllers — base controller class, API-only mode, and custom controller overrides. See Other Configurations.
Security and hashing — token and application secret hashing (SHA256, BCrypt), PKCE enforcement, and client authentication methods. See Token and Application Secrets.
Last updated