This application developed for Spring Security capabilities. At the beginning there exist only one endpoint without
security.
In time I will add new branches with different capabilities.
With this branch integrated oauth2 with a Third Party Identity and Access Management. Related articles about install IAM
as Docker, Initialize Configuration's of IAM and Integrate Sprint Boot Security
Keycloak : link
Initialize and Integrate : link
File | Description |
---|---|
create.sql | Table changed to a private resource which only authenticate user can select |
data | Removed old repository, add new repository |
service | Removed old service, add new service |
application.yml | Added new Keycloak configurations under keycloak |
templates | Added basic html pages |
WebSecurityConfig.java | Updated according to oauh2 and Keycloak |
WebController.java | Added html's controllers |
pom.xml | Added new dependencies |
** Some files deleted. You can check these files over history or other branches.
With this branch jdbcAuthentication
customized specific user table. With new table need to implement new table
repository.
Changelog
File | Description |
---|---|
create.sql | Create Table and Insert Queries changed according to column's names |
data | Added data package for JPA flows |
service | Added service package to access repository |
CustomAuthenticationProvider.java | Added CustomAuthenticationProvider to check over custom table |
application.yml | Added new database name and added minor hibernate config physical-strategy |
With this branch inMemoryAuthentication
convert to jdbcAuthentication
.
For jdbc authentication you need valid database and tables structure.
If you have valid database, you can run create.sql for creating tables and relations.
After that you need to update application.yml related datasource
details.
spring:
datasource:
url: jdbc:mysql://localhost:3306/workshop_security
username: root
password: pass
driver-class-name: com.mysql.cj.jdbc.Driver
If you don't have valid database, you can use docker-compose.yml
for creating database, tables and relations in a container.
Run the below command in the docker
directory.
docker-compose -f "docker-compose.yml" up -d --build
If you use this solution, you don't need to update application.yml
With this branch added features detailed below.
Feature | Description |
---|---|
pom.xml | Added Spring Security dependencies to pom.xml |
WebSecurityConfig.java | Added inMemoryAuthentication to REST API |
The project is built on Spring Boot architecture. Maven used as build automation tool.
-
You need valid database, tables and relations. At branch change notes there is two solutions for database requirements.
-
Make sure to be in the root directory
-
Run the command to run the project locally:
mvnw spring-boot:run
- Run the command to run the tets:
mvnw test
- Run the command to create runnable jar file:
mvnw package
This endpoint return SecurityResponse object. That means successfully access the resource.
Authentication Type | User Name | Password |
---|---|---|
Basic Authentication | user | pass |
{
"id": 7919202912837799685,
"key": "Resource Key",
"value": "Resource Value"
}
This endpoint return SecurityResponse object. That means successfully access the resource.
Authentication Type | User Name | Password |
---|---|---|
Basic Authentication | user | pass |
{
"key": "Resource Key",
"value": "Resource Value"
}
{
"id": 7919202912837799685,
"key": "Resource Key",
"value": "Resource Value"
}