This project demonstrates how to integrate Supabase authentication with a Vue.js frontend and Spring Boot backend.
-
Frontend (Vue.js, Pinia)
- User registration with email/password
- Social login with Google
- Protected routes
- Authentication state management with Pinia
-
Backend (Spring Boot, Spring Security)
- JWT token validation
- Protected endpoints
- User registration handling
- Node.js and npm
- Java 17 or higher
- Maven
- Supabase account
- Create a new project at Supabase
- Enable Email Auth in Authentication settings
- Set up Google OAuth provider:
- Create OAuth credentials in Google Cloud Console
- Configure redirect URL:
https://[YOUR_PROJECT_ID].supabase.co/auth/v1/callback
- Note down your Supabase URL and anon key
- Get your JWT secret from Project Settings > Data API > JWT Settings
-
Install dependencies:
cd supabase-playground-frontend npm install -
Create a
.envfile based on.env.exampleand add your Supabase credentials:VITE_SUPABASE_URL=your-supabase-project-url VITE_SUPABASE_ANON_KEY=your-supabase-anon-key VITE_API_URL=http://localhost:8080/api -
Start the development server:
cd supabase-playground-frontend npm run dev
-
Update
application.propertieswith your Supabase credentials:supabase.url=https://your-project-id.supabase.co supabase.key=your-supabase-anon-key supabase.jwt.secret=your-supabase-jwt-secret -
Build and run the application:
cd supabase-playground-backend mvn spring-boot:run
- Open your browser and navigate to
http://localhost:5173 - Register a new user or sign in with Google
- Once authenticated, you can access the protected profile page
- The profile page has a button to fetch secret data from the backend
-
Email/Password Registration:
- User registers on the frontend
- Frontend calls Supabase Auth API
- Backend handles user creation in the database
-
Google Social Login:
- User clicks Google login button
- Supabase handles OAuth flow
- User is redirected back to the application
-
API Authentication:
- Frontend includes Supabase JWT token in API requests
- Backend validates the token
- If valid, the request is processed
- If invalid, a 401 Unauthorized response is returned
MIT