11package org .openpodcastapi .opa .config ;
22
3- import lombok .RequiredArgsConstructor ;
43import org .openpodcastapi .opa .auth .ApiBearerTokenAuthenticationConverter ;
54import org .openpodcastapi .opa .auth .JwtAuthenticationProvider ;
65import org .springframework .context .annotation .Bean ;
2524/// Security configuration for the Spring application
2625@ Configuration
2726@ EnableWebSecurity
28- @ RequiredArgsConstructor
2927@ EnableMethodSecurity
3028public class SecurityConfig {
3129
@@ -44,12 +42,12 @@ public class SecurityConfig {
4442
4543 /// API-related security configuration
4644 ///
47- /// @param http the [HttpSecurity] object to be configured
48- /// @param jwtAuthenticationProvider the [JwtAuthenticationProvider] used to handle JWT auth
45+ /// @param http the security object to be configured
46+ /// @param jwtAuthenticationProvider the JWT provider used to handle JWT auth
4947 /// @param entryPoint the entrypoint that commences the JWT auth
50- /// @param deniedHandler the [AccessDeniedHandler] that handles auth failures
51- /// @param converter the [ApiBearerTokenAuthenticationConverter] that manages JWT validation
52- /// @return the configured [HttpSecurity] object
48+ /// @param deniedHandler the handler that handles auth failures
49+ /// @param converter the bearer token converter that manages JWT validation
50+ /// @return the configured security object
5351 @ Bean
5452 @ Order (1 )
5553 public SecurityFilterChain apiSecurity (
@@ -60,9 +58,9 @@ public SecurityFilterChain apiSecurity(
6058 ApiBearerTokenAuthenticationConverter converter
6159 ) {
6260
63- AuthenticationManager jwtManager = new ProviderManager (jwtAuthenticationProvider );
61+ final var jwtManager = new ProviderManager (jwtAuthenticationProvider );
6462
65- BearerTokenAuthenticationFilter bearerFilter =
63+ final var bearerFilter =
6664 new BearerTokenAuthenticationFilter (jwtManager , converter );
6765
6866 bearerFilter .setAuthenticationFailureHandler (
@@ -90,8 +88,8 @@ public SecurityFilterChain apiSecurity(
9088
9189 /// Web-related security configuration
9290 ///
93- /// @param http the [HttpSecurity] object to be configured
94- /// @return the configured [HttpSecurity] object
91+ /// @param http the security object to be configured
92+ /// @return the configured security object
9593 @ Bean
9694 @ Order (2 )
9795 public SecurityFilterChain webSecurity (HttpSecurity http ) {
@@ -119,29 +117,29 @@ public SecurityFilterChain webSecurity(HttpSecurity http) {
119117
120118 /// The default password encoder used for hashing and encoding user passwords and JWTs
121119 ///
122- /// @return a configured [BCryptPasswordEncoder]
120+ /// @return a configured password encoder
123121 @ Bean
124122 public BCryptPasswordEncoder passwordEncoder () {
125123 return new BCryptPasswordEncoder ();
126124 }
127125
128126 /// An authentication provider for password-based authentication
129127 ///
130- /// @param userDetailsService the [UserDetailsService] for loading user data
128+ /// @param userDetailsService the service for loading user data
131129 /// @param passwordEncoder the default password encoder
132- /// @return the configured [DaoAuthenticationProvider]
130+ /// @return the configured authentication provider
133131 @ Bean
134132 public DaoAuthenticationProvider daoAuthenticationProvider (UserDetailsService userDetailsService ,
135133 BCryptPasswordEncoder passwordEncoder ) {
136- DaoAuthenticationProvider provider = new DaoAuthenticationProvider (userDetailsService );
134+ final var provider = new DaoAuthenticationProvider (userDetailsService );
137135 provider .setPasswordEncoder (passwordEncoder );
138136 return provider ;
139137 }
140138
141139 /// An authentication provider for JWT-based authentication
142140 ///
143- /// @param provider a configured [JwtAuthenticationProvider]
144- /// @return a configured [ProviderManager] that uses the JWT auth provider
141+ /// @param provider a configured provider
142+ /// @return a configured manager that uses the JWT auth provider
145143 /// @see JwtAuthenticationProvider for provider details
146144 @ Bean (name = "jwtAuthManager" )
147145 public AuthenticationManager jwtAuthenticationManager (JwtAuthenticationProvider provider ) {
@@ -150,8 +148,8 @@ public AuthenticationManager jwtAuthenticationManager(JwtAuthenticationProvider
150148
151149 /// An authentication provider for API POST login
152150 ///
153- /// @param daoProvider a configured [DaoAuthenticationProvider]
154- /// @return a configured [ProviderManager] that uses basic username/password auth
151+ /// @param daoProvider a configured auth provider
152+ /// @return a configured manager that uses basic username/password auth
155153 @ Bean (name = "apiLoginManager" , defaultCandidate = false )
156154 public AuthenticationManager apiLoginAuthenticationManager (
157155 DaoAuthenticationProvider daoProvider ) {
0 commit comments