Skip to content

Switch sudo mode response to 401 Unauthorized #11145

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion app/controllers/sudo_mode_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def render_reauthentication_page(login: find_or_create_login!)
default_factor:,
forwarded_params:
},
status: :unprocessable_entity
status: :unauthorized
)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/ach_transfers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def ach_transfer_params
}
)

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unauthorized)
expect(event.ach_transfers).to be_empty
expect(response.body).to include("Confirm Access")

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/features_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

post(:disable_feature, params: { feature: "sudo_mode_2015_07_21" })

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unauthorized)
expect(Flipper.enabled?(:sudo_mode_2015_07_21, user)).to eq(true)

post(
Expand Down
20 changes: 10 additions & 10 deletions spec/controllers/sudo_mode_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def stub_login_code_service(email:, sms:)

post(:create)

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unauthorized)
expect(response.body).to include("Confirm Access")
end

Expand All @@ -84,7 +84,7 @@ def stub_login_code_service(email:, sms:)

post(:create)

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unauthorized)
expect(response.body).to include("Confirm Access")
expect(extract_submit_method(response)).to eq("email")
end
Expand All @@ -98,7 +98,7 @@ def stub_login_code_service(email:, sms:)

post(:create)

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unauthorized)
expect(response.body).to include("Confirm Access")
expect(extract_submit_method(response)).to eq("sms")
end
Expand All @@ -114,7 +114,7 @@ def stub_login_code_service(email:, sms:)

post(:create)

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unauthorized)
expect(response.body).to include("Confirm Access")
expect(extract_submit_method(response)).to eq("email")
end
Expand All @@ -128,7 +128,7 @@ def stub_login_code_service(email:, sms:)

post(:create, params: { _sudo: { switch_method: "email" } })

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unauthorized)
expect(response.body).to include("Confirm Access")
expect(extract_submit_method(response)).to eq("email")
end
Expand All @@ -154,7 +154,7 @@ def stub_login_code_service(email:, sms:)

post(:create)

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unauthorized)
expect(response.body).to include("Confirm Access")

# If there isn't an explicit user preference we favor WebAuthn
Expand Down Expand Up @@ -185,7 +185,7 @@ def stub_login_code_service(email:, sms:)

post(:create, params:)

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unauthorized)
expect(response.body).to include("Confirm Access")

form_params =
Expand All @@ -211,7 +211,7 @@ def stub_login_code_service(email:, sms:)

post(:create)

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unauthorized)
expect(response.body).to include("Confirm Access")

login_id = response.parsed_body.css("[name='_sudo[login_id]']").sole.attr("value")
Expand All @@ -229,7 +229,7 @@ def stub_login_code_service(email:, sms:)

post(:create, params: { _sudo: { login_id: "nope", submit_method: "email" } })

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unauthorized)
expect(response.body).to include("Confirm Access")
expect(flash[:error]).to eq("Login has expired. Please try again.")
end
Expand Down Expand Up @@ -413,7 +413,7 @@ def stub_login_service(&)
}
)

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unauthorized)
expect(response.body).to include("Confirm Access")
expect(flash[:error]).to eq("Turn it off and on again")
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
}
)

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unauthorized)
expect(response.body).to include("Confirm Access")
expect(user.reload.use_two_factor_authentication).to eq(true)

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/wires_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def wire_params
)

expect(event.wires).to be_empty
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(:unauthorized)
expect(response.body).to include("Confirm Access")

post(
Expand Down