This application implements JWT-based authentication with role-based access control using Spring Security and MongoDB.
- Spring Security
- JWT (JSON Web Token)
- MongoDB
- Spring Boot
- Lombok
-
Signup
- Users register via
/api/auth/signup. - During signup, they are assigned a default role (
ROLE_USER) unless otherwise specified. - The
Userobject stores email, password (hashed), and a set of roles.
- Users register via
-
Login
- Users authenticate via
/api/auth/signin. - If credentials are valid, the server:
- Generates a JWT using
JwtUtils. - Stores the JWT in an HTTP-only cookie (configured as
aissistant_id). - Returns user info (roles, email, etc.) in the response body.
- Generates a JWT using
- Users authenticate via
-
JWT Handling
- The
JwtTokenFilterextracts and validates the JWT from incoming requests. - If valid, Spring Security sets the user in the context for authorization.
- The
- Roles are stored in the MongoDB
rolescollection. - Defined in the
ERoleenum:public enum ERole { ROLE_USER, ROLE_ASSISTANT, ROLE_ADMIN }
π AIssistant IT Ticket System API
An IT ticketing system using Spring Boot + MongoDB, with LLM-powered ticket tagging and automatic assignment to IT Assistants based on expertise probability. π€β¨
Represents users of the system.
Fields:
id : ObjectId
username : String
email : String
password : String (hashed, ignored in JSON) π
name : String
bio : String
expertiseTags : Map<String, Double> β tag β probability π
tickets : List β solved tickets β
roles : Set β roles of the user (ROLE_USER, ROLE_ASSISTANT, ROLE_ADMIN)
Represents a ticket submitted by a user.
Fields:
id : ObjectId
headline : String
description : String
date : Date π
issuer : User β who created the ticket π€
solver : User β assigned IT Assistant (nullable) π
generalCategory : String β main category
tags : List β tags extracted via LLM π·
isSolved : Boolean β true if solved β
Represents a user role.
Fields:
id : ObjectId
name : ERole enum (ROLE_USER, ROLE_ASSISTANT, ROLE_ADMIN)
Used to update user personal info.
{ "name": "Vladik", "bio": "network and software engineering expert", "expertiseTags": { "network": 0.9, "software": 0.8, "hardware": 0.1 } }
Used to create a new ticket.
{ "headline": "Internet is down", "description": "Cannot connect to router in office", "generalCategory": "network" }
POST /api/userdata/add_personal_data βοΈ Update user name, bio, and expertise tags. Requires authentication via JWT cookie.
GET /api/userdata/my_user_data π Returns logged-in user data.
POST /api/ticket/create/ticket β Create a new ticket.
Flow:
Verify user is logged in. π
Save ticket to database. πΎ
Call TicketMatcherService to assign best-fit assistants using LLM + MongoDB aggregation. π€
Return created ticket. β
GET /api/ticket/all π Returns all tickets.
GET /api/ticket/{id} π Returns details of a specific ticket.
PATCH /api/ticket/{id}/mark_solved βοΈ Marks ticket as solved and updates solver data.