{"id":18410084,"url":"https://github.com/shinjimc/spring_security_thymeleaf","last_synced_at":"2026-04-10T04:49:20.267Z","repository":{"id":210494340,"uuid":"726697428","full_name":"ShinjiMC/Spring_Security_Thymeleaf","owner":"ShinjiMC","description":" The Spring_Security_Thymeleaf project utilizes Java, Spring Boot, and Thymeleaf for a hardware store's invoicing system. It allows employees to generate invoices and admins to manage product data efficiently. Key technologies include Spring Security for authentication and MySQL for database management, all deployable via Docker.","archived":false,"fork":false,"pushed_at":"2024-04-21T04:15:11.000Z","size":150,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T21:58:39.842Z","etag":null,"topics":["authentication","authorization","crud","docker","hardware-store","invoice-management","java","mysql","pdf-generation","role-based-access-control","spring-boot","spring-boot-3","spring-security","spring-security-jwt","tailwindcss","thymeleaf","web-application"],"latest_commit_sha":null,"homepage":"https://spring-security-thymeleaf.onrender.com","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ShinjiMC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-03T05:25:24.000Z","updated_at":"2024-12-16T13:11:45.000Z","dependencies_parsed_at":"2023-12-03T06:27:56.480Z","dependency_job_id":"32afb2b1-662e-43c6-8505-f14719873f61","html_url":"https://github.com/ShinjiMC/Spring_Security_Thymeleaf","commit_stats":null,"previous_names":["shinjimc/spring_security_thymeleaf"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShinjiMC%2FSpring_Security_Thymeleaf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShinjiMC%2FSpring_Security_Thymeleaf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShinjiMC%2FSpring_Security_Thymeleaf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShinjiMC%2FSpring_Security_Thymeleaf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShinjiMC","download_url":"https://codeload.github.com/ShinjiMC/Spring_Security_Thymeleaf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637784,"owners_count":21137538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","authorization","crud","docker","hardware-store","invoice-management","java","mysql","pdf-generation","role-based-access-control","spring-boot","spring-boot-3","spring-security","spring-security-jwt","tailwindcss","thymeleaf","web-application"],"created_at":"2024-11-06T03:29:01.414Z","updated_at":"2025-12-30T20:22:09.716Z","avatar_url":"https://github.com/ShinjiMC.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring_Security_Thymeleaf\n\n[![Deploy Docker](https://github.com/ShinjiMC/Spring_Security_Thymeleaf/actions/workflows/docker.yml/badge.svg)](https://github.com/ShinjiMC/Spring_Security_Thymeleaf/actions/workflows/docker.yml)\n\n![Java](https://img.shields.io/badge/Java-D54E4C?style=for-the-badge\u0026logo=openjdk\u0026logoColor=white)\n![Tailwind](https://img.shields.io/badge/Tailwind_CSS-38B2AC?style=for-the-badge\u0026logo=tailwind-css\u0026logoColor=white)\n![SpringBoot](https://img.shields.io/badge/SpringBoot-6DB33F?style=for-the-badge\u0026logo=spring\u0026logoColor=white)\n![MySQL](https://img.shields.io/badge/MySQL-343434?style=for-the-badge\u0026logo=mysql\u0026logoColor=white)\n![Docker](https://img.shields.io/badge/Docker-005571?style=for-the-badge\u0026logo=Docker\u0026logoColor=white)\n![Render](https://img.shields.io/badge/Render-2800ff?style=for-the-badge\u0026logo=render\u0026logoColor=white)\n\nBy Braulio Maldonado Casilla \u0026 Sergio Daniel Mogollon Caceres\n\nThe project simulates the process of generating invoices for a hardware store. When users log in (or create an account), they are assigned different roles according to their position in the company. Standard employees can generate invoices by selecting products and their respective quantities, which culminates in the automatic creation of a PDF file ready for printing.\n\nOn the other hand, users with the ADMIN role have additional privileges. They have access to the complete management of product data, which includes Create, Read, Update, and Delete (CRUD) operations, allowing them to edit, add, and delete products from the hardware store's database.\n\nThis system offers a comprehensive solution that streamlines the generation of invoices for employees and facilitates the efficient management of products for administrators, thus optimizing the hardware store's daily operations.\n\n## Accounts\n\nFor standard user access:\n\n- Email: user@gmail.com\n- Password: user\n\nFor administrative access:\n\n- Email: example@gmail.com\n- Password: admin\n\n## Installation and Configuration\n\nTo run the project locally, you will need to have the following installed:\n\n1. **Java Development Kit (JDK)** - Version 17.\n2. **Maven** - Java project management tool.\n\nThe project makes use of the following tools and libraries:\n\n- Spring Boot 3.2.0\n- Thymeleaf\n- Spring Boot Starter Data JPA\n- Spring Boot Starter Security\n- Spring Boot Starter Web\n- iText 7 Core\n- MySQL Connector/J\n- Lombok\n- Spring Boot Starter Validation (Hibernate)\n\n## Database Configuration\n\nIn the `application.yml` file, you will find the database connection configuration. You can modify the following fields according to your credentials and specific database configuration:\n\n```yaml\nspring:\n  datasource:\n    url: jdbc:mysql://MYSQLHOST:MYSQLPORT/MYSQLDATABASE\n    username: MYSQLUSER\n    password: MYSQLPASSWORD\n```\n\n## Main Features\n\nDetailed description of the main functionalities of the project, including how to access them and their utility.\n\n## Technologies Used\n\n### Thymeleaf\n\nThymeleaf is used in HTML files for data integration in views:\n\nFile: `login.html`\n\n```html\n\u003c!-- Link to the Thymeleaf library --\u003e\n\u003chtml lang=\"en\" xmlns:th=\"https://www.thymeleaf.org\"\u003e\n  \u003c!-- Using Thymeleaf to configure the form action --\u003e\n  \u003cform class=\"space-y-4 md:space-y-6\" th:action=\"@{/login}\" method=\"post\"\u003e\n    \u003c!-- Using Thymeleaf to handle attributes and display data --\u003e\n    \u003clabel\n      for=\"username\"\n      class=\"block mb-2 text-sm font-medium text-gray-900 dark:text-white\"\n      \u003eYour email\u003c/label\n    \u003e\n    \u003cinput\n      type=\"email\"\n      name=\"username\"\n      id=\"username\"\n      th:placeholder=\"name@company.com\"\n      required\n    /\u003e\n    \u003c!-- ... --\u003e\n    \u003clabel\n      for=\"password\"\n      class=\"block mb-2 text-sm font-medium text-gray-900 dark:text-white\"\n      \u003ePassword\u003c/label\n    \u003e\n    \u003cinput\n      type=\"password\"\n      name=\"password\"\n      id=\"password\"\n      th:placeholder=\"••••••••\"\n      required\n    /\u003e\n    \u003c!-- ... --\u003e\n    \u003cbutton\n      type=\"submit\"\n      class=\"w-full text-white bg-primary-600 hover:bg-primary-700 ...\"\n    \u003e\n      Log in\n    \u003c/button\u003e\n  \u003c/form\u003e\n\u003c/html\u003e\n```\n\n### Hibernate Validator\n\nHibernate Validator is used in entities to apply validation constraints:\n\nFile: `Customer.java`\n\n```java\nimport jakarta.validation.constraints.Email;\nimport jakarta.validation.constraints.NotEmpty;\nimport jakarta.validation.constraints.Size;\n\n@Entity\n@Table(name = \"customer\")\npublic class Customer {\n    // ... other attributes\n    @Column(name = \"email\")\n    @NotEmpty(message = \"The email cannot be empty\")\n    @Email(message = \"The email must be valid\")\n    private String email;\n    // ... other attributes\n}\n```\n\n### Spring Security\n\nSpring Security is used to configure authentication and authorization:\nThe file is configured to define security rules. In this code snippet, authorization directives with HTTP are set up, allowing access to certain routes like `/`, `register`, `/profile`, among others. Additionally, the login form is specified at `/login`, the login request processing at the same URL, and the redirection to `/profile` after a successful login. Finally, the logout functionality is enabled at `/logout`, with redirection to the login page.\n\nFile: `SpringSecurityConfig.java`\n\n```java\n@Configuration\n@EnableMethodSecurity\npublic class SpringSecurityConfig {\n    // ... other methods and configurations\n    @Bean\n    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {\n        // Authorization configuration with HTTP\n        http.csrf(AbstractHttpConfigurer::disable);\n        http.authorizeHttpRequests(httpRequest -\u003e\n            // Configuration of specific routes and permissions\n            httpRequest.requestMatchers(\"/\", \"register\", \"/profile**\", \"/agregateProduct**\",\n                    \"/newProduct**\", \"/editProduct**\")\n                    .permitAll()\n                    .anyRequest().authenticated())\n                .formLogin(formLogin -\u003e formLogin\n                    .loginPage(\"/login\")\n                    .loginProcessingUrl(\"/login\")\n                    .defaultSuccessUrl(\"/profile\")\n                    .permitAll())\n                .logout(logout -\u003e logout\n                    .logoutUrl(\"/logout\")\n                    .logoutSuccessUrl(\"/login\")\n                    .permitAll());\n        return http.build();\n    }\n    // ... other attributes\n}\n```\n\n### Spring Data JPA\n\nSpring Data JPA is used to handle data persistence.\n\nFile: `Boleta.java`\n\n```java\n@Entity\n@Data\n@NoArgsConstructor\n@AllArgsConstructor\npublic class Boleta {\n    @Id\n    @GeneratedValue(strategy = GenerationType.IDENTITY)\n    private Long id;\n\n    @OneToMany(cascade = CascadeType.ALL)\n    @JoinColumn(name = \"boleta_id\")\n    private List\u003cProductoDetalle\u003e detalles;\n    private Double precioTotal;\n    // ... other attributes\n}\n```\n\n## Spring Boot Starter Web\n\nSpring Boot Starter Web is a dependency that provides features for building web applications. Here's an example of how it's used:\n\nFile: `CustomerController.java`\n\n```java\nimport lombok.RequiredArgsConstructor;\nimport org.springframework.stereotype.Controller;\nimport org.springframework.web.bind.annotation.*;\n\n@Controller\n@RequestMapping(\"api/v1/customers\")\n@RequiredArgsConstructor\npublic class CustomerController {\n    private final CustomerService customerService;\n    @PostMapping(\"/register\")\n    public String createCustomer(@ModelAttribute(\"customer\") Customer customer) {\n        customerService.createCustomer(customer);\n        return \"redirect:/profile\";\n    }\n}\n```\n\n## Lombok\n\nLombok is a library that reduces code verbosity by automatically generating methods like getters, setters, constructors, etc. Here's an example of how it's used:\n\nFile: `Customer.java`\n\n```java\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\nimport lombok.NoArgsConstructor;\nimport lombok.Setter;\n\n@Getter\n@Setter\n@AllArgsConstructor\n@NoArgsConstructor\n@Entity\n@Table(name = \"customer\")\npublic class Customer {\n    @Id\n    @GeneratedValue\n    private Long customerId;\n    @Column(name = \"first_name\")\n    private String firstName;\n    @Column(name = \"last_name\")\n    private String lastName;\n    @Column(name = \"email\")\n    private String email;\n    @Transient\n    private String password;\n    @OneToOne(mappedBy = \"customer\", cascade = CascadeType.ALL, fetch = FetchType.LAZY)\n    private UserAccount userAccount;\n}\n```\n\n## Project Structure\n\nIn the project structure, each directory contains files related to specific system functionalities, such as authentication (`auth`), invoice management (`boleta`), configuration (`config`), customers (`customer`), products (`product`), security (`security`), and HTML resource files for views in templates. Additionally, the main project configuration file is located in `application.yml` within the `resources` directory.\n\n- `src/main/java/com/tecsup/ferreteria/`\n  - `auth/`\n    - `Authority.java`\n    - `Role.java`\n    - `RoleRepository.java`\n    - `RoleService.java`\n    - `RoleServiceImpl.java`\n  - `boleta/`\n    - `Boleta.java`\n    - `BoletaController.java`\n    - `BoletaRepository.java`\n    - `BoletaService.java`\n    - `BoletaServiceImpl.java`\n    - `ProductoDetalle.java`\n  - `config/`\n    - `SpringSecurityConfig.java`\n  - `customer/`\n    - `Customer.java`\n    - `CustomerController.java`\n    - `CustomerRepository.java`\n    - `CustomerService.java`\n    - `CustomerServiceImpl.java`\n  - `product/`\n    - `Product.java`\n    - `ProductController.java`\n    - `ProductDTO.java`\n    - `ProductRepository.java`\n    - `ProductService.java`\n    - `ProductServiceImpl.java`\n  - `security/`\n    - `AccountService.java`\n    - `UserAccount.java`\n    - `UserAccountController.java`\n    - `UserAccountDetails.java`\n    - `UserAccountPasswordEncoder.java`\n    - `UserAccountRepository.java`\n    - `UserAccountService.java`\n  - `SpringSecurityApplication.java` (main)\n- `src/main/resources/`\n  - `templates/`\n    - `agregateProduct.html`\n    - `chooseProducts.html`\n    - `descargarBoleta.html`\n    - `editProduct.html`\n    - `login.html`\n    - `products.html`\n    - `profile.html`\n    - `register.html`\n  - `application.yml`\n\n## Screenshots\n\n### Login Menu\n\n[![Login Menu](https://i.postimg.cc/7L2zy1yb/login.png)](https://postimg.cc/f3Myc9yh)\n\n### Register Menu\n\n[![Register Menu](https://i.postimg.cc/qMvC7HdP/register.png)](https://postimg.cc/3WzwL6N1)\n\n### Initial USER Menu\n\n[![Initial USER Menu](https://i.postimg.cc/RhX6TXwp/home.png)](https://postimg.cc/zHHGzwtT)\n\n### Initial Menu Searching for Product\n\n[![Initial Menu Searching for Product](https://i.postimg.cc/0j8KmLKJ/home-buscando.png)](https://postimg.cc/zbcfY2jJ)\n\n### Menu for Choosing Products to Buy\n\n[![Menu for Choosing Products to Buy](https://i.postimg.cc/PxnwfLty/choose-Product.png)](https://postimg.cc/GBz2qmTT)\n\n### Menu to Confirm Sale and Generate Invoice\n\n[![Menu to Confirm Sale and Generate Invoice](https://i.postimg.cc/DwDGDjHt/descargando-Boleta.png)](https://postimg.cc/3kXW0BKB)\n\n### Resulting Invoice PDF\n\n[![Resulting Invoice PDF](https://i.postimg.cc/xT6MGTRj/boleta-PDF.png)](https://postimg.cc/gn6xmpQ1)\n\n### Initial ADMIN Menu\n\n[![Initial ADMIN Menu](https://i.postimg.cc/qRcCNkqT/home-ADMIN.png)](https://postimg.cc/JDnhgCj6)\n\n### Product Management Menu\n\n[![Product Management Menu](https://i.postimg.cc/L4T1R6Gk/products.png)](https://postimg.cc/ThKwJGdh)\n\n### Menu for Adding a New Product\n\n[![Menu for Adding a New Product](https://i.postimg.cc/tCqFVVFm/add-Product.png)](https://postimg.cc/z3Qysvtn)\n\n### Menu for Editing a Product\n\n[![Menu for Editing a Product](https://i.postimg.cc/y8W9L4Qm/edit-Product.png)](https://postimg.cc/TKMpPSX1)\n\n## License\n\nThis project is licensed under the [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International](http://creativecommons.org/licenses/by-nc-sa/4.0/).\n\n\u003ca rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc-sa/4.0/\"\u003e\n  \u003cimg alt=\"Licencia Creative Commons\" style=\"border-width:0\" src=\"https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png\" /\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinjimc%2Fspring_security_thymeleaf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinjimc%2Fspring_security_thymeleaf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinjimc%2Fspring_security_thymeleaf/lists"}