Skip to content

shamail-kais/SpringBoot-Security-Role-Based

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Security (JWT) + Role-Based Access (Admin/User) + Flutter Client

A secure authentication & authorization system built with Java Spring Boot using JWT (token-based authentication). Implements Role-Based Access Control (RBAC) for Admin and User roles and supports a Flutter mobile app frontend via REST APIs.


Features

  • ✅ Register & Login (JWT token-based)
  • ✅ Stateless authentication (no server session)
  • ✅ Role-based authorization (ADMIN / USER)
  • ✅ Secure endpoints (Admin-only vs User-only)
  • ✅ REST API integration for Flutter mobile app
  • ✅ Clean structure (Controller / Service / Repository)

Tech Stack

Backend

  • Java + Spring Boot
  • Spring Security
  • JWT Authentication
  • JPA/Hibernate (if used)
  • MySQL/PostgreSQL/H2 (update based on your DB)

Frontend

  • Flutter (Mobile App)
  • HTTP client for REST calls
  • Secure token storage (recommended: flutter_secure_storage)

Project Structure (Backend)

Update package names if needed.

  • controller/ - API endpoints
  • service/ - Business logic
  • repository/ - Database access
  • security/ - JWT filters, configs, utilities
  • model/ - Entities / DTOs
  • config/ - App configs

API Endpoints (Example)

Auth

  • POST /auth/register → register user
  • POST /auth/login → login and receive JWT token

Role-based

  • GET /admin/** → ADMIN only
  • GET /user/** → USER only
  • GET /common/** → public or authenticated (based on your config)

If your actual endpoints differ, replace these with your real paths.


How JWT Works (High Level)

  1. User logs in with credentials
  2. Server returns a JWT token
  3. Flutter app stores token securely
  4. Token is sent in headers for protected calls: Authorization: Bearer <token>
  5. Spring Security validates token and grants role-based access

Run Backend Locally

Prerequisites

  • Java (recommended: 17)
  • Maven/Gradle
  • Database (if applicable)

Steps

# clone
git clone https://github.com/shamail-kais/SpringBoot-Security-Role-Based.git
cd SpringBoot-Security-Role-Based

# run
./mvnw spring-boot:run
# or
mvn spring-boot:run

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages