![](/james126/mgm-server/raw/master/readme/man.png)
Spring Boot Web App
![](/james126/mgm-server/raw/master/readme/java.png)
![](/james126/mgm-server/raw/master/readme/spring.png)
![](/james126/mgm-server/raw/master/readme/postgres.png)
![](/james126/mgm-server/raw/master/readme/junit.png)
![](/james126/mgm-server/raw/master/readme/jwt.png)
- Add new endpoints
- Remove redundant endpoints
- Unit testing
- Deploy
First attempt at client server architecture - been developing it on/off since 2022.
- Client uses Angular
- mgm-client
- Server uses Spring Boot
- mgm-server
- local postgres database
- Previous hosted on AWS
- server port 8080
- Postgres port 5432
- client port 80
Application is stateless - user details stored on a database
-
Custom Authentication
CustomUserDetailsFilter
extracts username/password from HTTP request bodyCustomUserDetailsServer
gets user details from the databaseCustomAuthenticationProvider
authenticates user and adds user authorities/priviledges
-
Login Authorization
- Handled by Spring Security
- Requires user authority role ADMIN
- HTTP response contains a JWT cookie
- Handled by Spring Security
-
Custom Authorization
- Verifies user details extracted from JWT cookie
CustomJwtUtility
validates the cookie and extracts user details- Proceeds with custom authentication
- Verifies user details extracted from JWT cookie
-
Custom JWT Cookies
- Creates a JWT cookie using the username and appends it to the HTTP response
CustomJwtUtility
creates response cookie
- Creates a JWT cookie using the username and appends it to the HTTP response
-
Custom Logging
- Logs all HTTP requests to file
- Logs successful authentication attempts
- Logs errors sent by the Angular client to file angular.log
Logback
-
Injection attack mitigation
HTML/JavaScript injection
form input is sanitised to remove HTML/JavaScriptSQL Injection
input is inserted into the database as String parameters
-
Database
postgresl
use to store data - contact forms, user details
-
Custom HTTP request caching
- Caches content type application/json requests to prevent IllegalStateException: “getInputStream() has already been called for this request.
- Caches content type application/json requests to prevent IllegalStateException: “getInputStream() has already been called for this request.
-
Custom Header Filter
- Adds custom HTTP response headers to the http-response - required by Angular front-end
- Adds custom HTTP response headers to the http-response - required by Angular front-end
Previously hosted on AWS ec2 - no longer
AWS Route53 routes requests for server.mrgrassmaster.com to the instance
- ec2 details
- instance type t3a.micro
ubuntu
- instance type t3a.micro
- Install packages
openjdk-17-jdk
,tomcat
, certbot
- Add files
- add Spring war file and SSL certificate files
- add Spring war file and SSL certificate files
- tomcat configuration
- enable ssl
- ssl certificate and key
- java war file
- Configure firewall
- enable ssh, http, https, database port
- Uses
logback
- Spring Boot (mgm-server) to all.log
- log exceptions, HTTP-requests, login attempts
- Angular (mgm-client) to angular.log sent via HTTP request
- Spring Boot (mgm-server) to all.log
![](/james126/mgm-server/raw/master/readme/logging.png)
- Unit Tests
![](/james126/mgm-server/raw/master/readme/unit_tests.png)