spring-projects / spring-projects/spring-security
Document the end-to-end Servlet OAuth2 Login authentication flow
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Summary
This is a documentation enhancement proposal. No behavioral or API change is requested.
The Servlet OAuth2 Login documentation currently explains the individual components involved in authentication, but it is difficult to follow how those components interact across the complete login lifecycle.
I would like to contribute documentation that connects the OAuth2 Login components in execution order and identifies the extension points available to applications.
Proposed Documentation
The proposed section would explain the following flow:
- A client initiates login through
/oauth2/authorization/{registrationId}. OAuth2AuthorizationRequestRedirectFiltercreates the authorization request.OAuth2AuthorizationRequestRepositorytemporarily stores the request, including values used for request correlation and PKCE.- The authorization server redirects the user agent to
/login/oauth2/code/{registrationId}with an authorization code. OAuth2LoginAuthenticationFilterprocesses the authorization response.- The filter delegates authentication to
AuthenticationManager. OAuth2LoginAuthenticationProviderexchanges the authorization code for an access token.OAuth2UserServiceretrieves the user information and returns anOAuth2User.- Spring Security creates an authenticated
OAuth2AuthenticationToken. - The resulting authentication is stored through
SecurityContextRepository. - The configured
AuthenticationSuccessHandleris invoked.
A compact sequence diagram could illustrate the relationship between the browser, client application, authorization server, filters, authentication provider, user service, and security context.
Extension Points
The documentation could also identify the primary extension points available at each stage:
OAuth2AuthorizationRequestResolverAuthorizationRequestRepositoryOAuth2UserServiceGrantedAuthoritiesMapperAuthenticationSuccessHandlerAuthenticationFailureHandlerSecurityContextRepository
Motivation
The individual classes are documented in the reference and API documentation, but their relationship is distributed across multiple sections.
In particular, it is not immediately clear:
- Which filter processes each of the default OAuth2 endpoint patterns
- Where the authorization request,
state, and PKCE data are stored - Which component performs the authorization-code exchange
- When
OAuth2UserServiceis invoked - How a custom
OAuth2Userbecomes the authenticated principal - When the resulting
Authenticationis stored in theSecurityContext - When the success handler is invoked
An end-to-end lifecycle section would make it easier for users to understand where custom OAuth2 login logic belongs without requiring them to trace the filter and provider implementations.
Contribution
I would be happy to contribute this documentation.
Would this addition be welcome? If so, which existing Servlet OAuth2 Login documentation section would be the preferred location?
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 reading the existing Servlet OAuth2 Login documentation and tracing the named filters, providers, services, and security-context components in the proposed execution order. Add an end-to-end lifecycle section, a compact sequence diagram, and the listed extension points; done means the endpoint flow and customization locations are understandable without tracing implementations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- documentation, security
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100