spring-projects / spring-projects/spring-security-samples
Multi-factor authentication: The second factor can be skipped
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 797
- Avg merge
- 3m
- Merged PRs (30d)
- 5
Description
Simply remove the second factor part from mfaWhenWrongCodeThenRedirects and the test fails:
@Test
void mfaWhenSecondFactorSkippedThenRedirects() throws Exception {
// @formatter:off
MvcResult result = this.mockMvc.perform(formLogin()
.user("user@example.com")
.password("password"))
.andExpect(redirectedUrl("/second-factor"))
.andReturn();
HttpSession session = result.getRequest().getSession();
// skip the second factor
this.mockMvc.perform(post("/third-factor")
.session((MockHttpSession) session)
.param("answer", "smith")
.with(csrf()))
.andExpect(redirectedUrl("/login?error"));
// @formatter:on
}
Test output:
Redirected URL expected:</login?error> but was:</>
Expected :/login?error
Actual :/
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the test containing mfaWhenWrongCodeThenRedirects and mfaWhenSecondFactorSkippedThenRedirects, then run the latter to reproduce the failure. Trace the /third-factor request after formLogin() redirects to /second-factor. Done means the skipped second-factor submission redirects to /login?error rather than /.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, backend, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100