spring-projects / spring-projects/spring-security

Explore introducing a hierarchy of factor authorities

Open
#17,960 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

for: team-attention in: core type: enhancement
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

NOTE: This is a ticket that the Spring Security team is reviewing for inclusion. It's not considered ready to implement yet. When it is, this disclaimer will be removed and the title may change


LdapAuthenticationProvider, JaasAuthenticationProvider, and DaoAuthenticationProvider all issue FACTOR_PASSWORD as their factory authority.

This makes sense since that is the kind of credential that was used (a username and password), and this is typically what will be important when deciding level of authority.

There may be value, though, in specifically differentiating the type of authentication that was performed, and this information is available neither in the authority nor in the authentication type.

One way to address this would be to resolve authorities hierarchically, as is already done with roles. For example, LdapAuthenticationProvider could issue FACTOR_PASSWORD_LDAP, JaasAuthenticationProvider could issue FACTOR_PASSWORD_JAAS, and so on. Each of these would imply FACTOR_PASSWORD, allowing authorization rules to focus on the credential type.

Some places where this might be helpful are when similar credentials have differing security profiles. An example of this is with Bearer and DPoP tokens. For some requests, it may be valuable to indicate they require elevated security:

@EnableGlobalMultifactorAuthentication(authorities = { FACTOR_X509_AUTHORITY, FACTOR_BEARER_AUTHORITY })

// ...

@Bean
ThrowingCustomizer<HttpSecurity> sensitiveEndpoints() {
    return (http) -> http
        .authorizeHttpRequests((authorize) -> authorize
            .requestMatchers("/sensitive/endpoints/**").hasAuthority("FACTOR_BEARER_DPOP")
            .anyRequest().authenticated()
        );
}

Another example may be considering the subsystem that the user is registered in:

@Bean
ThrowingCustomizer<HttpSecurity> sensitiveEndpoints() {
    return (http) -> http
        .authorizeHttpRequests((authorize) -> authorize
            .requestMatchers("/appone/**").hasAuthority("FACTOR_PASSWORD_LDAP") 
            .anyRequest().authenticated()
        );
}

That is, only the users that are registered in LDAP may use this part of the application.

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

The issue names LdapAuthenticationProvider, JaasAuthenticationProvider, and DaoAuthenticationProvider, and compares hierarchical authority resolution with roles. Start by reviewing those providers and the existing role-hierarchy behavior; no files or tests are identified. The work is not ready to implement until the Spring Security team agrees on the authority model and scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
authentication, authorization, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.