๐ PII Data Masking in Spring Boot
Welcome ๐! This project is part of my YouTube tutorial where I show how to mask sensitive customer data (PII) like phone numbers and club card numbers in a Spring Boot application.
๐ง What is PII Masking?
PII stands for Personally Identifiable Information โ things like phone numbers, card numbers, email addresses, etc.
โก๏ธ If we expose them directly from our API, itโs a security risk. โก๏ธ Masking means we hide part of the value before sending it back to the client.
Example:
Phone number 9876543210 โ xxxxxx3210
Club card 1234-5678-9012-3456 โ XXXX-XXXX-XXXX-3456
๐ Features of this Project
โ Spring Boot REST API
โ JPA + H2 (in-memory DB)
โ Custom annotation @MaskData
โ Jackson Serializer PIIHide for masking
โ Demo API tested with Postman
๐ ๏ธ Tech Stack
Java 17+ Spring Boot 3+ Maven Lombok Jackson
Clone this repo
git clone https://github.com/youtube-cwc/code.git cd code
Build and run with Maven
./mvnw spring-boot:run
API Endpoint
GET http://localhost:8080/customer/1
๐ธ Demo ๐ด Before Masking (unsafe response) { "id": 1, "name": "John Doe", "phoneNumber": "9876543210", "clubCardNumber": "1234-5678-9012-3456" }
๐ข After Masking (safe response) { "id": 1, "name": "John Doe", "phoneNumber": "xxxxxx3210", "clubCardNumber": "XXXX-XXXX-XXXX-3456" }
๐ (Insert Postman screenshots here for better engagement)
๐ฅ YouTube Tutorial
๐บ Watch the full tutorial here ๐ [Your YouTube Link]
๐ค Contributing
Found a bug? Open an issue.
Have a suggestion? Create a pull request.
๐ License
Licensed under MIT License โ free to use & modify.