Skip to content

Latest commit

Β 

History

History
167 lines (105 loc) Β· 3.47 KB

File metadata and controls

167 lines (105 loc) Β· 3.47 KB

πŸ” Authentication & Role Management

This application implements JWT-based authentication with role-based access control using Spring Security and MongoDB.


🧱 Technologies Used

  • Spring Security
  • JWT (JSON Web Token)
  • MongoDB
  • Spring Boot
  • Lombok

πŸ”‘ User Authentication Flow

  1. Signup

    • Users register via /api/auth/signup.
    • During signup, they are assigned a default role (ROLE_USER) unless otherwise specified.
    • The User object stores email, password (hashed), and a set of roles.
  2. 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.
  3. JWT Handling

    • The JwtTokenFilter extracts and validates the JWT from incoming requests.
    • If valid, Spring Security sets the user in the context for authorization.

🧾 Role Management

  • Roles are stored in the MongoDB roles collection.
  • Defined in the ERole enum:
    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. πŸ€–βœ¨

πŸ“¦ Models

User πŸ‘€

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)

Ticket 🎫

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 βœ…

Role 🏷

Represents a user role.

Fields:

id : ObjectId

name : ERole enum (ROLE_USER, ROLE_ASSISTANT, ROLE_ADMIN)

πŸ“¬ Payloads

AddPersonalDataRequest πŸ“

Used to update user personal info.

{ "name": "Vladik", "bio": "network and software engineering expert", "expertiseTags": { "network": 0.9, "software": 0.8, "hardware": 0.1 } }

TicketCreationRequest πŸ†•

Used to create a new ticket.

{ "headline": "Internet is down", "description": "Cannot connect to router in office", "generalCategory": "network" }

πŸ›  Controllers & API Endpoints

UserDataController πŸ‘€

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.

TicketController 🎫

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.