Skip to content

Commit 4faf9a2

Browse files
committed
Switch sudo mode response to 401 Unauthorized
1 parent cd71be7 commit 4faf9a2

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

app/controllers/sudo_mode_handler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def render_reauthentication_page(login: find_or_create_login!)
216216
default_factor:,
217217
forwarded_params:
218218
},
219-
status: :unprocessable_entity
219+
status: :unauthorized
220220
)
221221
end
222222

spec/controllers/features_controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

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

19-
expect(response).to have_http_status(:unprocessable_entity)
19+
expect(response).to have_http_status(:unauthorized)
2020
expect(Flipper.enabled?(:sudo_mode_2015_07_21, user)).to eq(true)
2121

2222
post(

spec/controllers/sudo_mode_handler_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def stub_login_code_service(email:, sms:)
6666

6767
post(:create)
6868

69-
expect(response).to have_http_status(:unprocessable_entity)
69+
expect(response).to have_http_status(:unauthorized)
7070
expect(response.body).to include("Confirm Access")
7171
end
7272

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

8585
post(:create)
8686

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

9999
post(:create)
100100

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

115115
post(:create)
116116

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

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

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

155155
post(:create)
156156

157-
expect(response).to have_http_status(:unprocessable_entity)
157+
expect(response).to have_http_status(:unauthorized)
158158
expect(response.body).to include("Confirm Access")
159159

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

186186
post(:create, params:)
187187

188-
expect(response).to have_http_status(:unprocessable_entity)
188+
expect(response).to have_http_status(:unauthorized)
189189
expect(response.body).to include("Confirm Access")
190190

191191
form_params =
@@ -211,7 +211,7 @@ def stub_login_code_service(email:, sms:)
211211

212212
post(:create)
213213

214-
expect(response).to have_http_status(:unprocessable_entity)
214+
expect(response).to have_http_status(:unauthorized)
215215
expect(response.body).to include("Confirm Access")
216216

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

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

232-
expect(response).to have_http_status(:unprocessable_entity)
232+
expect(response).to have_http_status(:unauthorized)
233233
expect(response.body).to include("Confirm Access")
234234
expect(flash[:error]).to eq("Login has expired. Please try again.")
235235
end
@@ -413,7 +413,7 @@ def stub_login_service(&)
413413
}
414414
)
415415

416-
expect(response).to have_http_status(:unprocessable_entity)
416+
expect(response).to have_http_status(:unauthorized)
417417
expect(response.body).to include("Confirm Access")
418418
expect(flash[:error]).to eq("Turn it off and on again")
419419
end

spec/controllers/users_controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
}
5858
)
5959

60-
expect(response).to have_http_status(:unprocessable_entity)
60+
expect(response).to have_http_status(:unauthorized)
6161
expect(response.body).to include("Confirm Access")
6262
expect(user.reload.use_two_factor_authentication).to eq(true)
6363

spec/controllers/wires_controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def wire_params
8181
)
8282

8383
expect(event.wires).to be_empty
84-
expect(response).to have_http_status(:unprocessable_entity)
84+
expect(response).to have_http_status(:unauthorized)
8585
expect(response.body).to include("Confirm Access")
8686

8787
post(

0 commit comments

Comments
 (0)