Implement password reset UI and backend APIfeat(auth): Connect React Frontend Authentication UI to Spring Boot JWT Backend API#71
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| } | ||
| public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { | ||
| http | ||
| .csrf(csrf -> csrf.disable()) |
Check failure
Code scanning / CodeQL
Disabled Spring CSRF protection High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
In general, to fix this issue you should not disable Spring Security’s CSRF protection unless the application is guaranteed to be accessed only by non-browser clients that do not rely on cookies. Removing the explicit disablement will cause Spring to apply its default CSRF protection, which issues CSRF tokens and validates them on state-changing requests, mitigating CSRF attacks while preserving existing routing/authorization logic.
The best minimal fix here is to remove the .csrf(csrf -> csrf.disable()) call from the securityFilterChain configuration. This re-enables Spring Security’s default CSRF protection without altering which endpoints are permitted or authenticated. Since there is no visible custom CSRF configuration or alternative protection, we should simply let Spring manage CSRF. No other code changes in this file are required for the fix. Precisely, in src/main/java/com/greencode/config/SecurityConfig.java, edit the securityFilterChain method to delete line 24 and start the configuration directly with .authorizeHttpRequests(...). No new methods or imports are needed.
| @@ -19,22 +19,21 @@ | ||
| public class SecurityConfig { | ||
|
|
||
| @Bean | ||
| public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { | ||
| http | ||
| .csrf(csrf -> csrf.disable()) | ||
| .authorizeHttpRequests(auth -> auth | ||
| .requestMatchers( | ||
| "/auth/reset-request", | ||
| "/auth/reset-validate", | ||
| "/auth/reset-password", | ||
| "/auth/password-reset/**" | ||
| ).permitAll() | ||
| public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { | ||
| http | ||
| .authorizeHttpRequests(auth -> auth | ||
| .requestMatchers( | ||
| "/auth/reset-request", | ||
| "/auth/reset-validate", | ||
| "/auth/reset-password", | ||
| "/auth/password-reset/**" | ||
| ).permitAll() | ||
|
|
||
| .anyRequest().authenticated() | ||
| ); | ||
| .anyRequest().authenticated() | ||
| ); | ||
|
|
||
| return http.build(); | ||
| } | ||
| return http.build(); | ||
| } | ||
|
|
||
|
|
||
|
|
📌 Related Issue
Closes #8
📋 Summary
This PR wires up the existing React authentication UI to the Spring Boot
JWT backend. Users can now log in, reset passwords, and access protected
routes through the frontend. A shared Axios instance handles token
injection and automatic 401 responses. Auth state is managed globally
via React Context.
🔧 Changes Made
New Files
greencode-frontend/src/services/authService.js— login, logout,token refresh calls
greencode-frontend/src/context/AuthContext.jsx— global authstate management
greencode-frontend/src/api/axiosInstance.js— shared Axiosinstance with interceptors
greencode-frontend/src/routes/ProtectedRoute.jsx— guardsauthenticated routes
Modified Files
greencode-frontend/src/components/Login.jsx— wired to authServicegreencode-frontend/src/components/PasswordReset.jsx— wired tobackend reset API
greencode-frontend/src/App.jsx— wrapped routes with AuthContextdocs/— updated authentication documentation🔐 Authentication Flow
🧪 How to Test
✅ Checklist
docs/feat(auth): connect React frontend authentication UI to Spring Boot JWT backend
Closes #8
What changed
Why
The React frontend had authentication UI components but was not
connected to the Spring Boot JWT backend. Users could not log in
or reset passwords. This change completes the full-stack auth flow.
Tests
Breaking changes
None — all existing backend endpoints remain unchanged.