spring-projects / spring-projects/spring-security

SEC-2218: JEE preauth : make mappable-roles non-mandatory and default to WebXmlMappableAttributesRetriever strategy

Open
#2,395 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Gaetan Pitteloud (Migrated from SEC-2218) said:

When using the http/jee element, the mappable-roles attributes is mandatory, and the MappableAttributesRetriever implementation is set to a SimpleMappableAttributesRetriever with injected mappable-roles.

Since the jee pre-authentication scenario is most often (or even always ?) based on security-roles declared in web.xml, it would be nice to automatically support a WebXmlMappableAttributesRetriever when no mappable-roles are provided.

In order to achieve this, mappable-roles use must be changed to optional in XSD, and AuthenticationConfigBuilder.createJeeFilter(BeanReference) must be changed this way:

  RootBeanDefinition mappableRolesRetriever;
  String roles = jeeElt.getAttribute(ATT_MAPPABLE_ROLES);
  if (roles != null) {
    BeanDefinitionBuilder rolesBuilder = BeanDefinitionBuilder.rootBeanDefinition(StringUtils.class);
    rolesBuilder.addConstructorArgValue(roles);
    rolesBuilder.setFactoryMethod("commaDelimitedListToSet");

    mappableRolesRetriever = new RootBeanDefinition(SimpleMappableAttributesRetriever.class);
    mappableRolesRetriever.getPropertyValues().addPropertyValue("mappableAttributes", rolesBuilder.getBeanDefinition());
  } else {
    mappableRolesRetriever = new RootBeanDefinition(WebXmlMappableAttributesRetriever.class);
  }
  adsBldr.addPropertyValue("mappableRolesRetriever", mappableRolesRetriever);

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 the JEE pre-authentication XSD declaration and AuthenticationConfigBuilder.createJeeFilter(BeanReference). Trace how mappable-roles is read and how SimpleMappableAttributesRetriever and WebXmlMappableAttributesRetriever are configured. Done means the attribute is optional, with the existing explicit-role behavior preserved and the web.xml strategy used when it is omitted.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
authentication, authorization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.