spring-projects / spring-projects/spring-security

Add 'hited' filed to ConfigAttribute

Open
#4,244 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Can we add a boolean isHited(); method in ConfigAttribute interface and its implementations?
Add a boolean isHited(); method in ConfigAttribute interface and its implementations, and set it to true when the relative Voter vote ACCESS_GRANTED. If we have this feature, we can do further check after the normal access decision process. Really want this method when I implement two step authentication.
In my implementation, after the subject pass the first step of authentication, grant it a 'ROLE_2FA_PRE_AUTH' authority, and after the subject pass the second step authentication, grant it a 'ROLE_2FA_POST_AUTH' authority and all of its business authorities. But when the subject pass the first step authentication, it gets a authenticated authentication (Session), so in the <intercept-url> i need to set 'ROLE_2FA_POST_AUTH' access attribute for all of the resources (URLs) that Anonymous Subject is not allowed to access, that is a little silly. Because the subject is not Authenticated actually (Dose not pass the second step authentication). So if we have this isHited() method, I can check whether the hited ConfigAttribute is Anonymous one or not, If it is not , and the subject does not granted with 'ROLE_2FA_POST_AUTH' , access denied. Bingo, i don't need to set the 'ROLE_2FA_POST_AUTH' access attribute any more!
Finally I implement this by extend the AuthenticatedVoter, and check whether the subject is granted with 'ROLE_2FA_POST_AUTH' authority in the if (IS_AUTHENTICATED_FULLY.equals(attribute.getAttribute())) and if (IS_AUTHENTICATED_REMEMBERED.equals(attribute.getAttribute())) sections.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the ConfigAttribute interface, its implementations, and AuthenticatedVoter to understand how attributes are evaluated. Trace where a voter returns ACCESS_GRANTED; done means the new isHited() contract is consistently implemented and exposes the intended two-step-authentication signal without breaking existing access decisions.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
authorization, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.