Skip to content

The project is a web application using Spring Boot and Spring Security. It features a custom login page and an in-memory user details service, securing certain pages for authenticated users while allowing public access to the login and index pages.

License

Notifications You must be signed in to change notification settings

JohannBulls/WebSecurity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web Security Application

The project is a simple web application built with Spring Boot and Spring Security. It demonstrates how to secure web applications using Spring Security, featuring a custom login page and an in-memory user details service. The application ensures that only authenticated users can access certain pages, while allowing unrestricted access to the login and index pages. Additionally, it provides functionality for a shared drawing board, enabling users to collaborate in real-time within a secure environment.

Features

  • Secure Login: User authentication with a custom login page.
  • In-memory Users: Two users (user and admin) are predefined in the application.
  • Access Control: Restricts access to authenticated users for all pages except the index and login pages.

Getting Started

Prerequisites

  • Java: Ensure Java Development Kit (JDK) version 17 is installed.
  • Maven: Automate and standardize the lifecycle of software construction.
  • Git: Decentralized Configuration Manager.

Installing

  1. Maven

    • Download Maven from here.
    • Follow the installation instructions here.
  2. Git

    • Download Git from here.
    • Follow the installation instructions here.

Clone the Repository

You can clone the project repository using the following command:

git clone https://github.com/yourusername/your-repo.git

Run the Application

  1. Open a terminal and navigate to the folder where you cloned the repository.

  2. Use the following command to remove files generated in previous builds, compile the code, and package the project into a JAR file:

    mvn clean package
  3. Now, run the project using the following command:

    mvn spring-boot:run

alt text

  1. Open a browser and go to the following link to access the login page:

    Login Page

alt text

Project Structure

Backend (Spring Boot)

BBAppStarter

  • Description: Main application class for the Spring Boot application.
  • Purpose: Defines the primary entry point of the Spring Boot application using the @SpringBootApplication annotation.

BBConfigurator

  • Description: Configuration class for WebSocket server endpoint and scheduling.
  • Purpose: Configures WebSocket server endpoint export using @Configuration and enables scheduling using @EnableScheduling.

BBEndpoint

  • Description: WebSocket endpoint for handling drawing actions via WebSocket protocol.
  • Purpose: Manages WebSocket sessions, message processing, and error handling, enabling real-time communication between clients and the server.

DrawingServiceController

  • Description: REST controller for handling status requests.
  • Purpose: Provides a REST endpoint /status returning server status in JSON format, including the current date and time.

MvcConfig

  • Description: MVC configuration class for registering view controllers.
  • Purpose: Configures view controllers to handle specific URLs (/, /index, /login, /error) and assigns corresponding view names.

TicketController

  • Description: REST controller class for handling ticket generation requests.
  • Purpose: Provides a REST endpoint /ticket/generate generating a new ticket for WebSocket authorization based on the user ID.

TicketService

  • Description: Service managing generation, validation, and removal of tickets.
  • Purpose: Manages tickets stored in memory, verifying their validity and removing them upon expiration.

WebSecurityConfig

  • Description: Configuration class for web security using Spring Security.
  • Purpose: Configures HTTP security policies, user authentication, and secure access to pages using custom login forms and an in-memory user details service.

Architectural Design

Data Flow

  1. Initialization:

    • The WebSecurityConfig class initializes the security configuration.
    • Defines in-memory users with roles.
  2. Login:

    • Users access the login page at /login.
    • Users authenticate with predefined usernames and passwords.
  3. Access Control:

    • Authenticated users can access secured pages.
    • Unauthenticated users are redirected to the login page.

Built with

  • Spring Security - Framework for securing Spring-based applications.
  • Spring Boot - Backend framework
  • Maven - Dependency management

Authors

License

This project is licensed under the GNU License - see the LICENSE.txt file for details.

About

The project is a web application using Spring Boot and Spring Security. It features a custom login page and an in-memory user details service, securing certain pages for authenticated users while allowing public access to the login and index pages.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published