Major Enhancements to SAML2 and OAuth2 Integration with Simplified Security Configurations #2040
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Overview
This PR introduces major enhancements to the SPDF project's security configurations, specifically focusing on SAML2 and OAuth2 integrations. The changes include improvements to security, user experience, maintainability, and the overall structure of the codebase for authentication and authorization functionalities. The adjustments also align the security logic with the latest standards and best practices for managing identity providers.
Main Changes and Improvements
Dependencies related to OpenSAML and SAML2 have been added to the
build.gradle
file to facilitate SAML2 integration.Added constraints for
org.opensaml
libraries.Added spring-security-saml2-service-provider and com.coveo:saml-client libraries to support SAML2-related functionalities.
Introduced a new baseUrl configuration to dynamically determine the server base URL.
Changes were made to use baseUrlStatic and serverPortStatic in the SPdfApplication class, ensuring the URLs used throughout the application are consistent and configurable
The CustomLogoutSuccessHandler has been significantly improved to handle various scenarios such as SAML2, OAuth2, and Username/Password logouts:
getRedirect_saml2
,getRedirect_oauth2
) based on the type of authentication.Certificate Utility Class:
CertificateUtils
) to handle certificate reading operations for SAML2 configurations.Security Configuration Simplification:
SecurityConfiguration
class was enhanced to incorporate SAML2 configurations more flexibly.RelyingPartyRegistrationRepository
and authentication providers, ensuring SAML2-related components are properly initialized.SAMLLogoutSuccessHandler
,ConvertResponseToAuthentication
,CustomSAMLAuthenticationFailureHandler
, etc.) and replaced them with newer, more cohesive implementations.ClientRegistrationRepository
for various providers, such as Google, Keycloak, and GitHub, thus centralizing the configuration logic for better management (rollback)OAuth2 Enhancements:
SAML2 Enhancements:
CustomSaml2ResponseAuthenticationConverter
to handle the conversion of SAML2 response tokens into Saml2Authentication objects.RelyingPartyRegistration
beans to handle metadata for SAML2 logins, providing a clean and efficient way to manage SAML2 service providersCustom Principal Implementation:
CustomSaml2AuthenticatedPrincipal
for storing information about the authenticated SAML user.Checklist