Package me.josephsf.jobportaljosephsfeir.security


package me.josephsf.jobportaljosephsfeir.security
Provides security configuration and authentication components for the Job Portal application.

This package contains classes that implement authentication and authorization mechanisms using Spring Security and JWT (JSON Web Tokens). It follows a token-based authentication approach where users are issued JWT tokens upon successful authentication, which they include in subsequent requests to access protected resources.

The key components in this package include:

  • JwtUtils - Utility class for creating, validating, and parsing JWT tokens
  • JwtAuthTokenFilter - Filter that intercepts requests to validate JWT tokens and establish security context
  • UserDetailsServiceImpl - Implementation of Spring Security's UserDetailsService for loading user data
  • UserPrincipal - Implementation of Spring Security's UserDetails interface representing authenticated users

The security flow is as follows:

  1. A user authenticates by sending credentials to the authentication endpoint
  2. Upon successful authentication, a JWT token is generated and returned to the client
  3. The client includes this token in the Authorization header of subsequent requests
  4. The JwtAuthTokenFilter validates the token and sets up the security context
  5. Protected endpoints use method security annotations to enforce authorization

This package also works with the security configuration in the config package, particularly with SecurityConfig, which sets up the security filter chain and defines security rules for different URL patterns.

Since:
2025-05-15
  • Classes
    Class
    Description
    JWT Authentication Filter for validating tokens in requests.
    Utility class for handling JWT (JSON Web Token) operations.
    Implementation of Spring Security's UserDetailsService for authentication.
    Custom implementation of Spring Security's UserDetails interface.