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

Use strong parameters within pre-authorization #1266

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ User-visible changes worth mentioning.
## master

- [#PR ID] Add your description here.
- [#1266]: Use strong parameters within pre-authorization.
- [#1264] Add :before_successful_authorization and :after_successful_authorization hooks in TokensController
- [#1263]: Response properly when introspection fails and fix configurations's user guide.

Expand Down
7 changes: 6 additions & 1 deletion app/controllers/doorkeeper/authorizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ def redirect_or_render(auth)
def pre_auth
@pre_auth ||= OAuth::PreAuthorization.new(Doorkeeper.configuration,
server.client_via_uid,
params)
pre_auth_params)
end

def pre_auth_params
params.permit(:response_type, :redirect_uri, :scope, :state,
:code_challenge, :code_challenge_method)
end

def authorization
Expand Down
13 changes: 13 additions & 0 deletions spec/controllers/authorizations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -524,4 +524,17 @@ def translated_error_message(key)
post :create
end
end

describe "strong parameters" do
it "ignores non-scalar scope parameter" do
get :new, params: {
client_id: client.uid,
response_type: "token",
redirect_uri: client.redirect_uri,
scope: { "0" => "profile" },
}

expect(response).to be_successful
end
end
end