Skip to content

Commit

Permalink
Remove a couple of the riskier Doorkeeper grant flows (#1772)
Browse files Browse the repository at this point in the history
* Remove a couple of the riskier Doorkeeper grant flows

Fixes #820

* update tests to not rely on the password grant flow

* linter
  • Loading branch information
jagthedrummer authored Nov 21, 2024
1 parent b3bbc62 commit c786dfe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
2 changes: 1 addition & 1 deletion config/initializers/doorkeeper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
# The user doesn't have control over the authorization process, so clients
# aren't limited by scope, and could potentially have the same capabilities
# as the user themselves. See the second link above for countermeasures.
grant_flows %w[authorization_code password implicit client_credentials]
grant_flows %w[authorization_code client_credentials]

# Allows to customize OAuth grant flows that +each+ application support.
# You can configure a custom block (or use a class respond to `#call`) that must
Expand Down
34 changes: 14 additions & 20 deletions test/controllers/api/test.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
class Api::Test < ActionDispatch::IntegrationTest
def access_token
params = {
client_id: @platform_application.uid,
client_secret: @platform_application.secret,
grant_type: "password",
scope: "read write delete"
}

post "/oauth/token", params: params
assert_response :success
response.parsed_body["access_token"]
access_token = Doorkeeper::AccessToken.create!(
resource_owner_id: @user.id,
token: SecureRandom.hex,
application: @platform_application,
scopes: "read write delete"
)
access_token.token
end

def another_access_token
params = {
client_id: @another_platform_application.uid,
client_secret: @another_platform_application.secret,
grant_type: "password",
scope: "read write delete"
}

post "/oauth/token", params: params
assert_response :success
response.parsed_body["access_token"]
access_token = Doorkeeper::AccessToken.create!(
resource_owner_id: @another_user.id,
token: SecureRandom.hex,
application: @another_platform_application,
scopes: "read write delete"
)
access_token.token
end

setup do
Expand Down

0 comments on commit c786dfe

Please sign in to comment.