Skip to content

Commit 6e7c21c

Browse files
committed
Allow NULL oauth_applications.redirect_uri in db
Generate and apply migration to remove NOT NULL constraint from `oauth_applications.redirect_uri`. This works in conjunction with `allow_blank_redirect_uri true` in `config/initializers/doorkeeper.rb`, allowing us to save `OAuthApplications` with blank `redirect_uri` values for URI-less flows like client_credentials or password grant flows. NOTE: Applications using `authorization_code` (or other flows that require a redirect URI) must still have a non-blank `redirect_uri`. Otherwise, `/oauth/authorize` requests with `response_type=code` will fail. More info is available here: https://github.com/doorkeeper-gem/doorkeeper/wiki/Allow-blank-redirect-URI-for-Applications
1 parent 416d7d3 commit 6e7c21c

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class AllowNullRedirectUriInOauthApplications < ActiveRecord::Migration[7.1]
2+
def change
3+
# We currently have `allow_blank_redirect_uri true` in
4+
# `config/initializers/doorkeeper.rb`. Removing the NOT NULL constraint
5+
# allows us to save OAuthApplications with blank redirect_uri values
6+
# https://github.com/doorkeeper-gem/doorkeeper/wiki/Allow-blank-redirect-URI-for-Applications
7+
change_column_null :oauth_applications, :redirect_uri, true
8+
end
9+
end

db/schema.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[7.1].define(version: 2025_11_19_131055) do
13+
ActiveRecord::Schema[7.1].define(version: 2026_02_19_185224) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "plpgsql"
1616

@@ -280,7 +280,7 @@
280280
t.string "name", null: false
281281
t.string "uid", null: false
282282
t.string "secret", null: false
283-
t.text "redirect_uri", null: false
283+
t.text "redirect_uri"
284284
t.string "scopes", default: "", null: false
285285
t.boolean "confidential", default: true, null: false
286286
t.datetime "created_at", null: false

0 commit comments

Comments
 (0)