Skip to content

πŸ“ŠπŸ”’πŸ“ˆProtect Internal Dashboards or Admin Panels accessed without proper login or permission with Oauth2 using Spring Security

Notifications You must be signed in to change notification settings

engripaye/secure-internal-admin-portal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ Secure Internal Admin Portal

A secure and role-based internal portal for managing sensitive company tools, built with Java 21 and Spring Boot 3.5. This portal ensures only authorized internal staff can log in and access features, with granular permission control for different admin roles.

Secure Admin Portal Interface Design

πŸš€ Features

  • OAuth2 Login with Google Workspace (internal staff only)
  • Role-Based Access Control (RBAC) for granular permissions (VIEW, EDIT, DELETE)
  • Secure Session Management with Spring Security
  • Dashboard UI for internal operations
  • Audit Logging for admin actions
  • API Protection with Bearer Tokens
  • CSRF & XSS Protection enabled by default

πŸ“‚ Project Structure

secure-internal-admin-portal/
β”‚
β”œβ”€β”€ src/main/java/com/company/adminportal/
β”‚   β”œβ”€β”€ config/         # Security and OAuth2 configurations
β”‚   β”œβ”€β”€ controller/     # MVC Controllers for UI and APIs
β”‚   β”œβ”€β”€ service/        # Business logic and permission checks
β”‚   β”œβ”€β”€ repository/     # Data access layer
β”‚   β”œβ”€β”€ model/          # Entities and DTOs
β”‚   └── AdminPortalApplication.java
β”‚
β”œβ”€β”€ src/main/resources/
β”‚   β”œβ”€β”€ templates/      # Thymeleaf HTML pages (dashboard, login, error)
β”‚   β”œβ”€β”€ static/         # CSS, JS, Images
β”‚   └── application.yml # Configurations
β”‚
β”œβ”€β”€ pom.xml
└── README.md

πŸ” Security Flow

  1. Login β†’ User logs in via Google OAuth2 (restricted to company domain)
  2. Token Exchange β†’ OAuth2 provider sends authorization code β†’ backend exchanges for ID Token & Access Token
  3. Domain Validation β†’ Backend validates email domain (e.g., @company.com)
  4. RBAC Enforcement β†’ Only allowed roles can access certain endpoints or UI sections
  5. Audit Logging β†’ Every admin action is logged

πŸ› οΈ Tech Stack

Layer Technology
Backend Java 21, Spring Boot 3.5
Security Spring Security, OAuth2 Client
View Thymeleaf, Bootstrap
Database MySQL / PostgreSQL
Build Tool Maven / Gradle
Deployment Docker, Kubernetes (optional)

βš™οΈ Setup & Installation

1️⃣ Clone the Repository

git clone https://github.com/your-username/secure-internal-admin-portal.git
cd secure-internal-admin-portal

2️⃣ Configure Environment Variables

Create a .env file or set environment variables:

GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
APP_BASE_URL=http://localhost:8080
ALLOWED_DOMAIN=company.com

3️⃣ Run the Application

./mvnw spring-boot:run

Access the portal at: http://localhost:8080


πŸ”‘ Role-Based Access Example

Role Permissions
ROLE_ADMIN View, Edit, Delete, Create
ROLE_MANAGER View, Edit
ROLE_VIEWER View Only

πŸ“Έ Screenshots

πŸ” Login Page

Login Page

πŸ“Š Dashboard

Dashboard


πŸ§ͺ Running Tests

./mvnw test

πŸ“œ License

This project is licensed under the MIT License.


🌟 Real-World Impact

βœ… Prevents unauthorized access to sensitive internal tools βœ… Reduces risk of data breaches βœ… Provides an audit trail for compliance


If you want, I can also add code snippets inside the README so that new developers can quickly understand the OAuth2 configuration and role-based access control setup. That would make it even more developer-friendly.

About

πŸ“ŠπŸ”’πŸ“ˆProtect Internal Dashboards or Admin Panels accessed without proper login or permission with Oauth2 using Spring Security

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published