| Literature DB >> 35270850 |
Ayan Chatterjee1, Andreas Prinz1.
Abstract
In this study, we implemented an integrated security solution with Spring Security and Keycloak open-access platform (SSK) to secure data collection and exchange over microservice architecture application programming interfaces (APIs). The adopted solution implemented the following security features: open authorization, multi-factor authentication, identity brokering, and user management to safeguard microservice APIs. Then, we extended the security solution with a virtual private network (VPN), Blowfish and crypt (Bcrypt) hash, encryption method, API key, network firewall, and secure socket layer (SSL) to build up a digital infrastructure. To accomplish and describe the adopted SSK solution, we utilized a web engineering security method. As a case study, we designed and developed an electronic health coaching (eCoach) prototype system and hosted the system in the expanded digital secure infrastructure to collect and exchange personal health data over microservice APIs. We further described our adopted security solution's procedural, technical, and practical considerations. We validated our SSK solution implementation by theoretical evaluation and experimental testing. We have compared the test outcomes with related studies qualitatively to determine the efficacy of the hybrid security solution in digital infrastructure. The SSK implementation and configuration in the eCoach prototype system has effectively secured its microservice APIs from an attack in all the considered scenarios with 100% accuracy. The developed digital infrastructure with SSK solution efficiently sustained a load of (≈)300 concurrent users. In addition, we have performed a qualitative comparison among the following security solutions: Spring-based security, Keycloak-based security, and their combination (our utilized hybrid security solution), where SSK showed a promising outcome.Entities:
Keywords: API; Keycloak; REST; authentication; authorization; encryption; external attacks; spring-boot
Mesh:
Year: 2022 PMID: 35270850 PMCID: PMC8914669 DOI: 10.3390/s22051703
Source DB: PubMed Journal: Sensors (Basel) ISSN: 1424-8220 Impact factor: 3.576
Selected list of core security components of Spring Security Framework.
| Components | Description |
|---|---|
| SecurityContextHolder | It gives access to the SecurityContext. |
| SecurityContext | It contains the Authentication class and request-specific security information. |
| Authentication | This class stores user information for representing the principal in a way unique to Spring Security. |
| GrantedAuthority | The application-wide permissions given to a principal are to be reflected with this class. |
| UserDetails | It gives necessary information to create an authentication object from DAOs or other security data sources. |
| UserDetailsService | It helps to build UserDetails when a String-based username is passed (or certificate ID or similar). |
| AuthenticationManager | It loads the user authentication data (credentials or user store’s information) to verify authenticity of the users. |
| AuthenticationManagerBuilder | It is used to set up user information in memory, Java Database Connection (JDBC), Lightweight Directory Access Protocol (LDAP), or adding a custom UserDetailsService. |
| AbstractSecurityInterceptor | A central class of authorization helps to intercept secured resource access. |
| SecurityMetedataSource | It provides details about the current user and the item being protected along with SecurityContext class. |
| AccessDecisionManager | To decide dynamically if access can be granted to a user. |
| AbstractSecurityInterceptor | To perform access decisions. |
| WebSecurityConfig | It enables http security to access the HTTP Endpoints with basic authentication by extending WebSecurityConfigurerAdapter and overriding configure method. |
| PasswordEncoder | The PasswordEncoder interface of Spring Security is used to convert a password in a single way to allow the password to be securely stored. It can use any of the following encryption algorithms—MD5, SHA-256, and Bcrypt (recommended). |
| AuthenticationProvider | It helps to protect application with Spring Security and Basic Auth. |
| CorsRegistry | To set up global support for CORS configuration for the Spring Boot application. |
| HttpSecurity | It is like the Extensible Markup Language (XML) <http> feature of Spring Protection in the namespace configuration. It enables web-based authentication for individual http requests to be configured. It will apply to all requests by default. |
Selected list of Keycloak components for spring security framework integration.
| Components | Description |
|---|---|
| KeycloakWebSecurity | As a convenient base class, Keycloak provides a KeycloakWebSecurityConfigurerAdapter to build a WebSecurityConfigurer case. The execution enables customization by overriding techniques. It greatly simplifies context configuration for security. |
| KeycloakAuthenticationProvider | On a KeycloakAuthenticationToken, it performs authentication. |
| EnableGlobalMethodSecurity | The jsr250Enabled property allows the annotation of @RoleAllowed to be used. |
| KeycloakConfigResolver | It resolves the configuration of Keycloak Spring Boot Adaptor using “keycloak.json” configuration file. |
| sessionAuthenticationStrategy | This method defines the session authentication strategy. |
| RolesAllowed | This annotation is the JSR-250′s equivalent annotation of the @Secured annotation. |
Figure 1The developed digital infrastructure with extended SSK features.
Figure 2Deployment of eCoach system in the developed digital health infrastructure with extended SSK features.
Figure 3Data collection modules of the health eCoach prototype system.
Importance of the SDLC processes in eCoach context.
| Process | Importance in eCoach context |
|---|---|
| Requirement | Defining of eCoach scope, eCoach target audiences, user needs, functional requirements, external interface requirements (user, hardware, software, communications), system features, authentication, and authorization requirements to handle internal and/or external attacks, requirements for data integrity, and storage, and other non-functional requirements (performance, safety, security, and quality). |
| Design | Sufficient attention to role creation, data federation, password management, system modulation, API design, security configuration to integrate SSF with KeyCloak, UML modeling, database design, server configuration, and consideration for security vulnerabilities. |
| Implementation | Development of APIs using Spring Boot Framework, coding for UI design, data collection, data storage, password management, authentication, and authorization. |
| Functional Testing (unit testing) | In two levels, which are unit testing (unit testing) and non-functional penetration testing, we break down security testing of the eCoach system. |
| Maintenance | This phase involves bug fixing, infrastructure support, support to participants, addition/deletion of users, and upgradation. |
Figure 4Authorization Server (AS) use-case for eCoach prototype system.
Figure 5Resource Server (RS) use-case for eCoach prototype system.
Figure 6Access-token generation from the existing refresh-token.
Figure 7Sequence diagram of the login process for accessing web resources following the SSK security solution.
Scoped software, respective version, and usage.
| Software | Version | Purpose |
|---|---|---|
| Spring Boot Framework | 2.5.x | A framework for system development following the design pattern |
| Java compiler | JDK 15.x+ | To compile java codes |
| Mongo DB | 5.0.2 | To store and query PGDs |
| Mavens build tool | 3.8.2 | To build application and resolve dependencies |
| Spring Tool Suite | 4.7.0 | To Code in Java programming language |
| KeyCloak | 13.x | To work as identity provider server |
| Java Passay | 1.6.1 | To create initial systems generated password |
| Mockito | 3.12.x | To perform unit testing |
| Apache Tomcat | 10.x | To deploy eCoach modules |
| Microsoft Visio | Office16 | For UML modeling and drawing |
| Notepad ++ | 7.8.4 | For editing text, viewing log, and html coding |
| Bootstrap, Thymeleaf | 4.x | User interface design with HTML5 and CSS |
| Wireshark | 3.4.8 | To analyze network traffic or packets |
| Postman | 9.0.7 | To Perform manual testing for REST APIs |
| JMeter | 5.4.1 | To perform API scalability testing |
| Apache Log4j | 2.17.1 | To perform logging |
Scoped libraries and respective version.
| groupId | artifactId | Version |
|---|---|---|
| org.springframework.boot | spring-boot-starter-parent | 2.5.x |
| org.springframework.boot | spring-boot-starter-security | |
| org.springframework.boot | spring-boot-starter-web | |
| org.springframework.boot | spring-boot-devtools | |
| org.springframework.boot | spring-boot-starter-test | |
| org.springframework.security | spring-security-test | |
| org.keycloak | keycloak-spring-boot-starter | 13.x |
| org.keycloak | keycloak-admin-client | 13.x |
| org.bouncycastle | bcprov-jdk15on | 1.69 |
| org.springframework.boot | spring-boot-maven-plugin | |
| com.google.code.gson | gson | 2.8.7 |
| org.apache.commons | commons-csv | 1.8 |
| org.apache.maven.plugins | maven-compiler-plugin | 3.5.1 |
| org.apache.maven.plugins | maven-project-info-reports-plugin | 2.5.2 |
| commons-lang | commons-lang | 2.2 |
| org.apache.commons | commons-lang3 | 3.9 |
| org.springframework.boot | spring-boot-starter-thymeleaf | |
| org.springframework.boot | spring-boot-starter-mail | |
| com.twilio.sdk | twilio | 7.16.1 |
| javax.servlet | jstl | 1.2 |
| org.apache.tomcat | tomcat | 10.0.11 |
| org.springframework.boot | spring-boot-starter-actuator | |
| org.mockito | mockito-core | 3.12.4 |
Specification of the experimental environment.
| Specification | Windows System | Linux System |
|---|---|---|
| Memory | 8 GB | 15 GB |
| Operating System | Windows 10 | GNU/Linux |
| Disk (HDD) | 235 GB | 1023.9 GB |
| Socket endpoint | 127.0.0.1:8081 (localhost) | 10.225.147.186:8443 (Class A private IPV4) |
Explicit filter pattern to analyze network traffic.
| Filter | Purpose |
|---|---|
| ip.addr == xxxx/ip.dst == xxxx/ip.src == xxxx | To authorize API access based on bearer token |
| tcp.port == xxx/tcp.flags.reset == 1/tcp.stream eq X/tcp.seq == x/tcp.flags.push == 1/http.request/!(arp or icmp or dns)/(arp or icmp or dns)/udp contains xx:xx:xx/dns.flags.rcode ! = 0/http or dns/host xxx and not (port xx or port xx)/not broadcast and not multicast/broadcast and multicast/net xxx/port xx/ip.addr == x.x.x.x && ip.addr == x.x.x.x/tcp.stream eq xx/tcp.flags == 0x012/tcp.time_delta > .xx/tcp.analysis.flags && !tcp.analysis.window_update/ | To define MIME type (ex. application/json) |
| dst port 135 and tcp port 135 and ip[2:2] == 48 | To define the length of the request body |
| icmp[icmptype] == icmp-echo and ip[2:2] == 92 and icmp[8:4] == 0xAAAAAAAA | To define domain name for which the request is being sent |
| udp.srcport == 53 or udp.srcport == 123 | To define the form of response content type |
| tcp.flags.syn == 1 and tcp.flags.ack == 0 | To define compression algorithm as response |
| tcp.flags.syn == 1 and tcp.flags.ack == 1 | To keep underlying network connection (e.g., alive or close) |
Performance of unit-testing with Mockito framework.
| Scenario | Input | Mean Response | Category | ||
|---|---|---|---|---|---|
| Preferred | Acceptable | Delayed | |||
| User creation with a valid role | Email, mobile, role | 1–2 s | Yes | Yes | No |
| Retrieval of access token and refresh token | ClientID, client secret, grant type, UUID, password | 0.1–1 s | Yes | Yes | No |
| HTTP basic authentication | UUID, Password | 0.01–0.03 s | Yes | Yes | No |
| KeyCloak two-factor authentication | UUID, Password + OTP | 0.1–1 s | Yes | Yes | No |
| Authorized access | Valid access token | 0.1–1 s | Yes | Yes | No |
| Unauthorized access | Invalid access token | 0.01–0.05 s | Yes | Yes | No |
Mockito unit testing performance.
| Scenario | Parameters | Value |
|---|---|---|
| Input Parameters for HTTP POST | Endpoint | /eCoachUX/createParticipant |
| Port | 8443 | |
| HTTP Verb | POST | |
| Information | Email, mobile, role | |
| Data collection—1 | Response Header: X-XSS-Protection | 1 |
| Response Header: mode | block | |
| Data collection—2 | Response Header: X-Content-Type-Options | nosniff |
| Data collection—3 | Response Header: X-Frame-Options | DENY |
Brute force attack’s unit testing with Postman.
| Scenario | Comment |
|---|---|
| Normal successful login | No brute force detected |
| Normal login failure | No brute force detected |
| Normal login failure | Exceeded maximum attempts allowed. Brute force attack detected and account locked. |
Figure 8Break-up of a response time in our proposed solution for a single authorized HTTP request.
Scalability testing results with Y = 1, Z = 5, and variable loads (X).
| Y = 1, Z = 5 | Mean Throughput | Error % | Received KB/s | Delivered KB/s | Mean Latency (s) |
|---|---|---|---|---|---|
| Load (X) | |||||
| 1 | 6.4 | 0 | 265.5 | 6.8 | 165 |
| 10 | 34.7 | 0 | 1496 | 5.1 | 112 |
| 25 | 55.7 | 0 | 2410 | 8.04 | 260 |
| 50 | 78.5 | 0 | 3398.5 | 11.35 | 440 |
| 75 | 95.3 | 0 | 4130.5 | 13.77 | 550 |
| 100 | 112.8 | 0 | 4891 | 16.27 | 674 |
| 200 | 104.5 | 0 | 4529 | 15.1 | 1597 |
| 300 | 169.3 | 0 | 7347.3 | 24.46 | 1365 |
| 500 | 139.5 | 0 | 6048 | 20.4 | 2900 |
Scalability testing results with Y = 5, Z = 5, and variable loads (X).
| Y = 5, Z = 5 | Mean Throughput | Error % | Received KB/s | Delivered KB/s | Mean Latency (s) |
|---|---|---|---|---|---|
| Load (X) | |||||
| 1 | 18.7 | 0 | 799.39 | 2.9 | 55 |
| 10 | 10 | 0 | 423.5 | 1.45 | 39 |
| 25 | 24.6 | 0 | 1062.33 | 3.8 | 24 |
| 50 | 49.2 | 0 | 2135.3 | 7.4 | 23 |
| 75 | 73.6 | 0 | 3194.8 | 10.65 | 24 |
| 100 | 98.2 | 0 | 4263 | 14.5 | 23 |
| 200 | 195 | 0 | 8479 | 28.5 | 26 |
| 300 | 258 | 0 | 11200 | 37.5 | 126 |
| 500 | 224 | 0 | 9729 | 32.6 | 796 |
Scalability testing results with Y = 10, Z = 5, and variable loads (X).
| Y = 10, Z = 5 | Mean Throughput | Error % | Received KB/s | Delivered KB/s | Mean Latency (s) |
|---|---|---|---|---|---|
| Load (X) | |||||
| 1 | 31.3 | 0 | 1358.5 | 4.8 | 34 |
| 10 | 6.5 | 0 | 279.5 | 1 | 24 |
| 25 | 12.5 | 0 | 537.5 | 2 | 25 |
| 50 | 25 | 0 | 1075 | 4 | 23 |
| 75 | 37.4 | 0 | 1611 | 5.8 | 23 |
| 100 | 49.6 | 0 | 2153.8 | 7.4 | 23 |
| 200 | 99.3 | 0 | 4307 | 14.6 | 23 |
| 300 | 148.6 | 0 | 6457 | 22 | 22 |
| 500 | 143.6 | 0 | 10586.5 | 35.5 | 47 |
GDPR compliance checklist for SSK.
| GDPR Checklist [ | Addressed |
|---|---|
| Lawful basis and transparency | Yes |
| Data security | Yes |
| Accountability and governance | Yes |
| Privacy rights | Yes |
Summary of the adopted functional and non-functional testing.
| Test Case Scenario | Test Case | Passed (Yes/No) |
|---|---|---|
| Basic authentication | Access with a valid credential | Yes |
| Access with an invalid credential | Yes | |
| Two-factor authentication | Access with a valid credential + OTP | Yes |
| Access with an invalid credential/an incorrect OTP | Yes | |
| New user creation and role assignment | Creation request with a valid role assignment | Yes |
| Role-based API access | Access with a valid access key | Yes |
| Access with an invalid access key | Yes | |
| CSRF disabled | Access with a valid credential | Yes |
| CSRF Enabled | Access with an invalid credential | Yes |
| Access with a valid credential and valid “_csrf” token | Yes | |
| Access with a valid credential and invalid “_csrf” token | Yes | |
| CSRF Disabled but Access Token enabled | KeyCloak-based authentication and authorization | Yes |
| XSS Attack | Validate with response header if XSS attack protection is enabled | Yes |
| Brute Force Attack | General login failure | Yes |
| Multiple (=6) login failure | Yes | |
| Content sniffing | Validate with response header if attack protection is enabled | Yes |
| DoS Attack | Analysis of network statistics and packet information | Yes |
| DDoS Attack | Analysis of network statistics and packet information | Yes |
| MITM Attack (sniffing) | Enabling HTTPS (SSL) and the analysis of network statistics | Yes |
| IP Spoofing | Analysis of network IP statistics and packet information | Yes |
| Port Scanning | Analysis of network port statistics and packet information | Yes |
| Clickjacking Attack | Validate with response header if attack protection is enabled | Yes |
| Total Test Pass Rate | - | 100% |
Qualitative analysis on the effectiveness of SSK with three flags—No (0), Limited (1), and Yes (2).
| Features | Spring Security | KeyCloak | SSK |
|---|---|---|---|
| OAuth2 | Yes | Yes | Yes |
| SAML2.0 | No | Yes | Yes |
| OpenID | No | Yes | Yes |
| WebFlux | Yes | Yes | Yes |
| Access control | Yes | Yes | Yes |
| Identity and Access Management—Single-Sign-On (SSO), Identity Brokering and Login, User Federation, Client Adapters | No | Yes | Yes |
| Entire process of seamless calling the Keycloak Authorization Server from Spring-boot | Yes | No | Yes |
| Robustness | Limited | Limited | Yes |
| Powerful and customizable | Limited | Limited | Yes |
| Handling of Java EE security constraints | Limited | Limited | Yes |
| Multi-factor authentication | No | Yes | Yes |
| Easy to use | Yes | No | Yes |
| JSON web token | No | Yes | Yes |
Comparative analysis of our security solution with existing MSSA with respect to the key attributes of a secure web application architecture.
| Research | Inter-Tier Authentication | Server-Side Validation | Secure Communication | Data Encryption | Logging |
|---|---|---|---|---|---|
| Chatterjee et al. (our work) | Yes | Yes | Yes | Yes | Yes |
| Salibindla et al. | No | No | No | No | No |
| Xie et al. | Yes | No | No | No | No |
| Nguyen et al. | Yes | Yes | No | No | No |
| Dikanski et al. | Yes | No | No | No | No |
| Aloufi et al. | No | No | No | No | No |
| Beer et al. | No | Yes | No | Yes | No |
| Serme et al. | No | No | No | Yes | No |
| Backere et al. | No | No | Yes | No | No |
Comparative analysis of our security solution with existing MSSA with respect to the implemented security features.
| Research | Multi-Factor Authentication | OAuth2 (Token and Identity Brokering) | SSL/TLS | Bcrypt Hash | API Key | Spring Security | Third-party IAM (e.g., KeyCloak) | Protection against CSRF, XSS, Clickjacking, Content Sniffing, BF, DoS, DDoS, IP Spoofing, and MITM | CORS | Multi-Factor Authentication |
|---|---|---|---|---|---|---|---|---|---|---|
| Chatterjee et al. (our work) | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Salibindla et al. | No | No | No | No | No | No | No | No | No | No |
| Xie et al. | No | Yes | No | No | No | Yes | No | No | No | No |
| Nguyen et al. | No | Yes | No | No | No | Yes | No | CSRF, BF, XSS | No | No |
| Dikanski et al. | No | Yes | No | No | No | Yes | No | No | No | No |
| Aloufi et al. | No | No | No | No | No | No | No | No | No | No |
| Beer et al. | No | No | No | No | No | No | No | DoS, DDoS, BF | No | No |
| Serme et al. | No | No | No | No | No | No | No | No | No | No |
| Backere et al. | No | No | TLS | No | No | No | No | No | No | No |