https://github.com/daniellaera/spring-security
https://github.com/daniellaera/spring-security
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/daniellaera/spring-security
- Owner: daniellaera
- Created: 2019-12-24T15:47:34.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-06-14T22:29:32.000Z (almost 2 years ago)
- Last Synced: 2025-01-18T04:26:40.185Z (3 months ago)
- Language: Java
- Size: 81.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spring Boot, Spring Security, PostgreSQL: JWT Authentication & Authorization example
## Configure Docker Container for PostgreSQL
Click on `docker-compose.yml` and play or run `docker compose up -d`
## Configure Spring Datasource, JPA, App properties
Open `src/main/resources/application.properties`
```
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=123456
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.hibernate.ddl-auto=update
spring.datasource.initialization-mode=alwaysapplication.jwt.secretKey=69MyGwigg5jNTpUEzWhSpQPjfHFH8k5f
application.jwt.tokenPrefix=Bearer
application.jwt.tokenExpirationAfterDays=86400000
```## Run Spring Boot application
```
mvn spring-boot:run
```## Run Maven Compile
```
clean package -U
```## Run following SQL insert statements
```
INSERT INTO roles(name) VALUES('ROLE_USER');
INSERT INTO roles(name) VALUES('ROLE_MODERATOR');
INSERT INTO roles(name) VALUES('ROLE_ADMIN');
```## Run Swagger Rest Tests
``http://localhost:8080/swagger-ui/``
example endpoint `/api/auth/signin`
```
{
"username": "usernam",
"password": "password"
}
```