0f6e5c2116 | ||
---|---|---|
.mvn/wrapper | ||
src | ||
.gitignore | ||
HELP.md | ||
LICENSE | ||
README.md | ||
mvnw | ||
mvnw.cmd | ||
pom.xml |
README.md
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
- Clone the repository to your local machine:
git clone https://git.armin-wolf.de/generalbgh/spring-protected-area-example.git
-
Open the project in your IDE.
-
Configure the database connection in the
application.yaml
file located in thesrc/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
- 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: