spring-projects / spring-projects/spring-security

SEC-2986: AbstractPreAuthenticatedProcessingFilter could offer a way to reevaluate incoming requests

Open
#3,195 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: web type: enhancement type: jira
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Jordi Llach Fernandez (Migrated from SEC-2986) said:

By now a previously authenticated request can be reevaluated by spring security filter chain if AbstractSecurityInterceptor.alwaysReauthenticate is to true.

Then when working with a DaoAuthenticationProvider the UserCache reference that AbstractUserDetailsAuthenticationProvider has can be customized in order to avoid hitting the database per each incoming request, AND allowing you to "refresh/reload" user roles for instance from time to time.

To achieve this behaviour one just needs to override
DaoAuthenticationProvider.additionalAuthenticationChecks(UserDetails, UsernamePasswordAuthenticationToken ) the following way

@Override
    @SuppressWarnings("deprecation")
    protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
        if (!authentication.isAuthenticated()) {
            super.additionalAuthenticationChecks(userDetails, authentication);
        }
    }

So far so good.

The same behaviour described above can not be achieved when working with AbstractPreAuthenticatedProcessingFilter in your spring's security filter chain because this class does not offer you a way to "force" the reevaluation of the incoming request. Because method requiresAuthentication is private and the class does not has any boolean like the one mentioned in AbstractSecurityInterceptor

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 with AbstractPreAuthenticatedProcessingFilter and its private requiresAuthentication path, then compare its behavior with AbstractSecurityInterceptor.alwaysReauthenticate and the described UserCache flow. Define what an exposed reevaluation option should mean for incoming requests and verify that the resulting behavior supports periodic authentication rechecks without changing normal pre-authentication processing.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.