This is a project template using Java and Spring Boot, configured with Spring Security and OAuth2. The project includes an Authorization Server for token generation and a Resource Server for authentication and authorization of requests, with token validation at the route level. The project uses the H2 database for data storage.
- JDK 21
- Spring 3.3.0
- Maven 3.8+
-
config: Responsible for managing authentication and token issuance.
-
controllers: Contains application controllers responsible for handling HTTP requests and returning appropriate responses.
-
entities: Domain entities representing objects persisted in the database.
-
projections: Projections used to efficiently transfer data for specific operations.
-
repositories: Data repositories responsible for interacting with the database or other data sources.
-
services: Application services containing business logic and coordinating interaction between controllers, repositories, and other layers.
-
Clone the repository:
git clone https://github.com/Rudersonvf/spring-security-oauth2.git cd seu-repositorio
-
Import the project into your IDE:
- For IntelliJ IDEA:
File -> Open -> Select the project folder
. - For Eclipse:
File -> Import -> Existing Maven Projects -> Select the project folder
.
- For IntelliJ IDEA:
-
Start the project:
- Run the project according to your IDE.
-
Endpoints:
- [ Post ] Login: /oauth2/token
- [ Get ] Admin request: /test/admin
- [ Get ] User request: /test/user
- [ Get ] Free request: /test/free
-
Globals:
- host: http://localhost:8080
- client-id: myclientid
- client-secret: myclientsecret
- token: ""
Fork collection in Postman:
Ruderson Florentino