Go to file
Armin Wolf 0f6e5c2116 Adjusted README 2024-04-22 11:18:55 +02:00
.mvn/wrapper add state from Spring initializer 2024-04-21 08:58:36 +02:00
src Some refactoring 2024-04-22 11:03:18 +02:00
.gitignore add state from Spring initializer 2024-04-21 08:58:36 +02:00
HELP.md FIX: adjusted the groupId 2024-04-21 09:04:56 +02:00
LICENSE Initial commit 2024-04-21 06:42:36 +00:00
README.md Adjusted README 2024-04-22 11:18:55 +02:00
mvnw add state from Spring initializer 2024-04-21 08:58:36 +02:00
mvnw.cmd add state from Spring initializer 2024-04-21 08:58:36 +02:00
pom.xml Add MapStruct to remove Boilerplate-Code. Adjust Authorization. 2024-04-22 10:49:04 +02:00

README.md


LaTeX Logo
Spring Protected Area
Example Project

This is a sample project implementing a Spring Boot application with Spring Security and JWT (JSON Web Token) for authentication. PostgreSQL is used as the database.

Requirements

To run this project, you'll need the following:

  • Java Development Kit (JDK) version 21
  • Apache Maven
  • An IDE of your choice (e.g., IntelliJ IDEA, Eclipse)
  • PostgreSQL database

Configuration

  1. Clone the repository to your local machine:
git clone https://git.armin-wolf.de/generalbgh/spring-protected-area-example.git
  1. Open the project in your IDE.

  2. Configure the database connection in the application.yaml file located in the src/main/resources directory:

spring:
  datasource:
    platform: postgres
    url: jdbc:postgresql://localhost:5432/CHANGE_ME
    driver-class-name: org.postgresql.Driver
    username: CHANGE_ME
    password: CHANGE_ME
  jpa:
    database-platform: org.hibernate.dialect.PostgreSQLDialect
    hibernate:
      ddl-auto: update
    show-sql: false
  1. Start the application:
mvn spring-boot:run

The application should now be accessible at http://localhost:8080.

Usage

Once the application is running, you can access various endpoints to retrieve or create resources. Here are some examples:

  • POST /login: Authenticate using username and password. This endpoint returns a JWT token.
  • POST /register: Register a new user with a username and password.

Note that for protected endpoints, you'll need to provide a valid JWT token in the Authorization header. You can do this by sending the token in the format Bearer <TOKEN>.

Further Information

For more information on Spring Boot, Spring Security, and JWT, refer to the official documentation: