spring-projects / spring-projects/spring-security
Document how to tell BindAuthenticator which attributes to fetch
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
As requested, I am splitting the long and unclear #8560 into several issues. This issue is about documenting how one tells BindAuthenticator which attributes to fetch.
Behaviour
I've explained BindAuthenticator's general behaviour in #8725.
With the search-and-bind strategy, you can tell BindAuthenticator which attributes to return by calling setReturningAttributes on a search which you then pass to BindAuthenticator.setUserSearch.
With the dnPatterns strategy, you can call setUserAttributes on your authenticator to tell it which attributes to return.
(There is no way to tell it which attributes to return -- regardless of strategy -- if you're using LdapAuthenticationProviderConfigurer, aka the AuthenticationProviderManager.ldapAuthentication().and.other.methods way of configuring security. You need to define beans or use an object postprocessor. See #4309.)
The attributes configured on the search are ignored when the dnPatterns strategy is used. To see this, go here, follow the README, and check out the dnpatterns-setattrs-search-searchattrs branch. You'll see the uid attribute, which is what setUserAttributes was called with, but not the cn attribute, which is what the search passed to the authenticator was told to return.
What setReturningAttributes was called with is ignored when the search-and-bind strategy is used. To see this, go to the repository linked above, follow the README, and check out the no-dnpatterns-setattrs-search-searchattrs branch. You'll see the cn attribute, which is what the search passed to the authenticator was told to return, but not the uid attribute, which is what setUserAttributes was called with.
Why document?
This has potential for confusion -- someone might use a search-and-bind strategy but call setUserAttributes on the authenticator (or conversely), and not understand why it doesn't work. So it should be documented.
Document where?
The javadocs for setReturningAttributes and setUserSearch. On setReturningAttributes, you could say that this method is respected only if one has also called setUserDnPatterns, and similar things on setUserSearch. You might also add a sentence or two here.
Contributor guide
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 javadocs for setReturningAttributes and setUserSearch, then review the servlet LDAP bind reference section linked in the issue. Document which attributes each strategy uses, including the configuration limitation, and make the strategy-specific behavior clear to users.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100