Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to set null secret value for Applications if it's public #1727

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

nbulaj
Copy link
Member

@nbulaj nbulaj commented Aug 13, 2024

Aims to fix #1724

rails generate doorkeeper:remove_applications_secret_not_null_constraint

Copy link
Contributor

@ThisIsMissEm ThisIsMissEm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, also, fwiw, I would've been happy to work on a PR, but was a bit stumped by the test failures. With the gemfile change I'll see if I can get the tests running locally with this branch.

@nbulaj nbulaj force-pushed the fixes/allow-null-app-secret branch 2 times, most recently from 0e88e2c to 2ba429c Compare August 16, 2024 14:32
@nbulaj
Copy link
Member Author

nbulaj commented Aug 16, 2024

The only thing which makes me worry is legacy apps which already had NOT NULL constraint. If they will add a public app DB will throw an error for NULL secret. I have to think how to make these changes backward compatible.

@nbulaj
Copy link
Member Author

nbulaj commented Aug 16, 2024

Maybe it can be done via:

def self.null_secret_allowed?
  return @null_secret_allowed if defined?(@null_secret_allowed)

  @null_secret_allowed = model_class.columns.detect { |column| column.name == "secret" }&.null
end

UPD: yeah we already have almost similar check for PKCE - pkce_supported?

@ThisIsMissEm
Copy link
Contributor

Perhaps we could modify the migration / generator for enabling public clients to check that secret is nullable?

@nbulaj
Copy link
Member Author

nbulaj commented Aug 21, 2024

Perhaps we could modify the migration / generator for enabling public clients to check that secret is nullable?

You mean add a custom constraint into database migration? I already added a check on a model level, but custom constraints are DB-dependant so I;m not sure if we wanna to support all possible variants.

@nbulaj nbulaj force-pushed the fixes/allow-null-app-secret branch from 020bcd2 to 5ccff1d Compare August 21, 2024 14:29
@ThisIsMissEm
Copy link
Contributor

ThisIsMissEm commented Aug 21, 2024

I mean, create a migration that can be applied (like adding PKCE) that drops the not-null constrain on client_secret, since it's currently marked as not-null, and we can say that that's how you enable public clients.

@@ -23,7 +23,7 @@ gem "rubocop-rspec", require: false
gem "bcrypt", "~> 3.1", require: false

gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
gem "sqlite3", "~> 2.0", platform: %i[ruby mswin mingw x64_mingw]
gem "sqlite3", "~> 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I tried this locally on main and still can't get the tests passing, per #1721

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me and GitHub CI 🤔
Sorry I don't use dev-containers / docker / other local setups, not sure what can happen there

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't either!

@doorkeeper-gem doorkeeper-gem deleted a comment from guardrails bot Aug 29, 2024
@nbulaj nbulaj force-pushed the fixes/allow-null-app-secret branch from 3d74d83 to f282c25 Compare August 29, 2024 08:56
@nbulaj nbulaj merged commit 5133d76 into main Aug 29, 2024
42 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Doorkeeper shouldn't generate a secret for public clients
2 participants