2. Basic Preliminaries
In a digital health system [
23,
24,
25,
26], personal health data can be collected from heterogeneous sources over the different web and REST APIs. Therefore, maintaining the privacy and security of EHRs has become an open challenge. In combination with open source KeyCloak software [
27], the Spring Security [
14,
15,
16] paradigm may offer an opportunity to enhance security features, functionalities, identity brokering, session handling, CORS support, access management solutions, and security assertion markup language (SAML) [
28] for a health system’s web and REST APIs. The required security background for understanding the SSK security solution is discussed in this section.
Spring Security Framework [
14,
15,
16] is a robust, highly customizable, comprehensive, and extensible open-source Java framework supporting authentication and authorization. Furthermore, it provides a solution to protect common external attacks [
28,
29,
30,
31,
32,
33,
34,
35,
36,
37], such as session fixation, clickjacking, CSRF, etc. For securing Spring-based applications, it is the de-facto standard. The modules linked to spring security are core, remoting, web, config, LDAP, Access Control List (ACL), Central Authentication Service (CAS), and OpenID. The modular SSF consists of loosely coupled components linked to dependency injection. The selected list of core security components (class/interface) of the SSF is described in
Table 2. SSF can be integrated with various authentication technologies and standards, such as single-sign-on or SSO [
28] (Kerberos, LDAP, and JASSO), HTTP-basic, automatic remember-me, and form-based authentication, authentication filter, OpenID [
28], OAuth [
29], and SAML. This study focused mainly on form-based authentication, OAuth 2.0, SAML 2.0, standard spring security programming models, and configuration idioms. Spring Security OAuth supports using spring security with OAuth (v. 1a) and OAuth2. The spring SAML extension (SSE) enables SAML 2.0 service provider features to integrate with spring applications. It supports SAML 2.0 in identity provider (IP) mode with Keycloak, ADFS 2.0, Shibboleth, Open AM/OpenSSO, Ping Federate, and Okta.
Keycloak [
27] is an open-access IAM platform that secures web applications and RESTful web services using standard protocols such as OAuth2, OpenID Link, and SAML 2.0. It offers flexible login, registration, administration, CORS support, and account management user interfaces. We configured Keycloak as a separate sever to secure our eCoach APIs using the standard security assertion markup language 2.0 (SAML 2.0) integration with SSF. SAML 2.0 is a variant of the SAML standard that allows security domains to share authentication and authorization identities. SAML 2.0 is an XML-based protocol that uses security tokens containing assertions between an SAML authority, an Identity Provider, and an SAML client, called a Service Provider, to transfer information about a principal (usually an end-user). SAML 2.0 allows SSO, web-based, cross-domain, and helps minimize the administrative overhead of transmitting multiple authentication tokens to the user. These tokens may have identity details, such as username, address, email, and other information about the profile. They can also keep permission data so that users can make authorization decisions. These tokens can also be used on REST-based services to render stable invocations. The following core concepts and terms are generally used in Keycloak to secure web application and REST APIs [
23]: users, authentication, authorization, credentials, roles, user role mapping, composite roles, groups, realms (to manage a set of users, credentials, their functions, and groups), clients, client adapters, client role, identity token, access token, session, user federation provider, and identity provider mappers.
Table 2 describes the selected list of components of Keycloak for SSF integration to protect our eCoach REST APIs.
Microservice Architecture (MSA) [
29,
30,
31,
32,
33,
34,
35,
36,
37] has arisen to describe a specific way of developing software systems for independently deployable services. The traditional monolithic software development approach suffers from the following drawbacks: bundled deployment as a single stack, intransigent scalability, high cost of resources and refactoring efforts, and DevOps challenges among dispersed teams [
15,
16]. In contrast, MSA handles such concerns with the following measures: task decomposition into services, service communication using APIs with the smallest granularity, agility, independent deployment, and execution of services. REST and SOAP are two HTTP-based communication protocols used for data exchange between microservice APIs in multiple formats, such as XML and JSON [
15]. We used REST for eCoach API implementation in this study due to its lightweight nature. There are numerous methods to secure REST APIs. Still, the following four are the most popular:
HTTP-based authentication scheme (basic and bearer token),
API keys,
OAuth2 (access token and refresh token), and
OpenID (e.g., Keycloak OpenID, BankID).
OAuth2 is intended for authorization only, to grant access from one program to another to data and features. OpenID Connect (OIDC) is a thin layer on top of OAuth2 that adds details about logging into the user profile. We used Keycloak generic OpenID connect relying party and SAML service provider libraries in this study. The reliability and credibility of eHealth scientific research and associated services rely on the health data protection plans and guidelines regarding security, privacy, and confidentiality. For this study, we received ethical approval from The Norwegian Centre for Research Data (NSD) for managing data for our eHealth research in Norway.
3. System Architecture
Personal health and wellness data are generally collected through wearable sensors, interactions, interviews, web-based interactions, mobile apps, questionnaires, and feedback forms [
23,
25]. For ubiquitous tracking, high-end, time-dependent activity data collection with wearable BLE devices has become accessible and feasible. Wearable activity sensors can be connected via Bluetooth short-range communication technology (BLE) to a smartphone. With a machine intelligence module, the computing device can calculate and transfer high-resolution raw acceleration data and multiple operation parameters to safe storage seamlessly to process the data further. Some activity data are questionnaire-dependent, such as non-wear time and intense activity information. Either invasive (e.g., glycemic response, cholesterol level) or non-invasive physiological data (e.g., weight, blood pressure, heart rate, body assessment data) can be collected. Food data based on the questionnaire can be collected either regularly or on an alternating daily or weekly basis. Baseline data (medical background, habit, preference, personal knowledge, initial weight and height, initial blood pressure, and initial body assessment data) are being collected for demographic statistics or population clustering or individual target assessment during the participant’s initial recruitment or every month.
In this context, we developed a digital infrastructure after extending the SSK features with VPN, Bcrypt hash, API key, firewall, and SSL, as depicted in
Figure 1. Moreover, we deployed an electronic health coaching (eCoach) prototype system in the developed infrastructure to execute a formal security testing of the SSK solution scheme, and it is depicted in
Figure 2. We maintained a modular structure for our eCoach prototype system for an obesity case study with the following modules [
25]: activity, contextual, questionnaire, user interface (eCoachUX), and eCoach business (for user management, performance monitoring, database management, scheduling, user support, user communication, decision support, and recommendation generation).
3.1. Data Collection
We used a wearable MOX-2 [
38] activity monitor to collect personal activity data for the following measurement parameters:
Physical activity classification (low intensity, medium intensity, and high intensity),
Posture detection (sedentary, standing, and weight-bearing),
Physical activity intensity (counts per minute),
The activity module is responsible for activity device registration, device allocation, seamless collection of sensor observations, and sending it back to the eCoach business module for storing data in a PostgreSQL database.
MOX-2 is an activity monitor based on an embedded BLE accelerometer with low power consumption. The device can seamlessly measure and transmit high-resolution raw acceleration data and multiple activity parameters per second for seven consecutive days (up to 60 days).
In Stage 1, data collected from the activity sensor are sent back to the MOX mobile app to be stored temporarily in CSV format on the smartphone over BLE protocol. In Stage 2, a schedular running at the backend of our eCoach app collects activity data periodically from the smartphone location and sends it to the activity module using the HTTP-POST service (see
Figure 3). The contextual module periodically contains context updates from OpenWeather REST APIs (e.g., latest and hourly) with API-Key authentication and sends them back to eCoach business logic for stable storage. The questionnaire module consists of six question sets: daily, alternative day, weekly, interview, baseline (monthly), and feedback form. The participant submits the questionnaire, which is stored in the database through the eCoach business logic.
3.2. eCoach System (App. Version vs. Web Version)
The “/eCoachUX/home” API is exposed to the external user (protected with VPN access, a firewall, and SSL). Other APIs are protected with the access-role as configured in the Keycloak authorization server. If participants forget the password for authentication, they need to raise a request through “/eCoachUX/complaint” REST API. The Actuator provides secure endpoints for controlling, handling, and monitoring Spring Boot modules, such as /metrics, /env, /beans, /health, /info, and /trace, which are protected by role-based authorization. The user interface module is responsible for app view, web view, and data visualization based on individual access roles.
Figure 1 depicts how the SSK security solution for the eCoach system has been implemented with the KeyCloak third-party IAM platform. This study concentrated only on the eCoach API security and its implementation with SSK. Other core eCoach concepts, such as sensor specification, decision support principles, AI incorporation for the analysis of EHRs, data visualization, and personalized recommendation generation for a healthy lifestyle, are beyond this study’s scope.
The eCoach system has been hosted in a VPN-protected ubuntu infrastructure provided by The University, and the provided network (“EduNet”) is strictly firewall protected. Its internal IP addresses are not published to external Domain Name Services (DNS). Networks inside EduNet should be accessible; however, they must go through the proxy for external access from the eCoach server. We implemented an extra layer of basic (form-based) authentication on top of KeyCloak’s two-factor (password and One-Time Password (OTP)) authentication to authenticate participants on the eCoach mobile app to transfer activity data from the MOX-activity smartphone app. Basic authentication consists of a system-generated unique user ID (UUID) and a modifiable password. No personal data (such as national id, email, mobile or phone no, or similar personal identifiers) are unveiled in the basic user authentication step. KeyCloak’s two-factor user authentications consist of google authenticator (auto-id generator app) and credentials. Collected data are stored in a PostgreSQL database in JSON format for faster data processing. Furthermore, we created a self-signed SSL certificate with Keytool to secure confidential web information using public key (RSA) encryption. The eCoach system has five user categories: researcher, developer, system admin, health professional (nurse), and participants. They are further grouped into “ADMIN” (researcher, developer, system admin) and “USER” (health professional or nurse, and participants) for role-specific access control. Researchers and developers are responsible for the feasibility study, methodology adoption, system design, development, system configuration, deployment, test, and performance evaluation. They have full access to the system. System admin is accountable for infrastructure support. However, they do not have access to the participant’s health and wellness data. Trained health professionals, such as nurses, are responsible for interviewing (participant screening, recruitment, and the assessment of health condition), thereby collecting initial and baseline data through a pre-defined questionnaire set. Furthermore, they have access to a visualizing dashboard to monitor the participant’s processed health and wellness data. Participants have access to the personal data collection endpoints, feedback forms, and personal health and wellness monitoring dashboard. The system is protected from disclosing any personal data, and questionnaire forms are restricted from submitting any unique identifiers. The Secure Shell (SSH) access to the ubuntu and database servers is protected with authentication and authorization rules. The proposed eCoach system can be accessed through a web portal and/or a smartphone android application.
3.3. Methods for Security Implementation and Performance Evaluation
There is no single protection method to meet all the security requirements and design specifications for our distributed eCoach system. To implement and validate the SSK security solution, we utilized the web engineering security methodology by Aljawarneh et al. [
39]. The software engineering principles inspire the method and build on top of the standard waterfall software development life cycle (SDLC) (see
Table 3). The methodology helped to eliminate substantial threat exposures during all the SDLC phases by integrating security and evaluation components at each SDLC phase. Both software engineers and security professionals verified each stage.
To determine the performance of the hybrid security method, we evaluated the scalability of the API. Throughput (S) and latency (L) are considered to measure API scalability [
39,
40,
41,
42]. Network throughput refers to the average data rate at which data or messages are successfully transmitted on a specific communication link. It is measured in bits per second (bps). The maximum network throughput equals the Transmission Control Protocol (TCP) window size divided by the communication packet’s round-trip time (RTT). This method does not consider communication overhead, such as network receiver window size, machine limitations, or network delay [
39,
40,
41,
42]. Network latency is the time it takes for a packet to be captured, transmitted, processed through multiple devices, and then received and decoded at the destination [
39,
40,
41,
42]. We use Apache open-source software JMeter (V 5.4.1) to generate HTTP request load (l) to check API scalability as a “thread group” and capture the corresponding throughput and latency. The following three attributes for load testing using JMeter [
39] are critical:
The number of threads or users;
The acceleration period in seconds;
The loop count sets the test count.
We set the cycle count value of a single load to 5 repeated experiments and take the average throughput and latency. Low latency and high throughput are good performance indicators for supporting real-time critical applications.
6. Discussion
Using the SSK security solution, personal health data governance has fulfilled the General Data Protection Regulation (GDPR) compliance checklist as specified in
Table 14. It is three-fold research:
First, we implemented a security solution with SSF, basic authentication, two-factor authentication, and authorization (OAuth2) with an open-source KeyCloak server (IDP), VPN, network firewall, and SSL.
Second, we implemented the solution for developing a digital infrastructure where we deployed an eCoach prototype system.
Third, we performed testing of the prototype APIs against the common external vulnerabilities, as described in
Table 15.
We created 22 test cases for 16 test scenarios to replicate external attacks as our SSK security solution. SSK security implementation and configuration in the prototype system successfully secured the eCoach APIs from an attack in all scenarios with 100% test accuracy. Furthermore, we performed a qualitative analysis on the effectiveness of SSK in
Table 16 after comparing SSK with Spring Security and Keycloak against certain security features.
Due to licensing and subscription constraints, we could not create a similar environment and deploy other solutions (e.g., SF + Okta or solutions identified in literature) to test scalability against throughput and latency. Therefore, we only performed scalability testing for our adopted work under defined settings and obtained a promising result, as described in
Table 11,
Table 12 and
Table 13. The result shows that the increased value of the ramp-up period has a positive impact on the mean throughput and mean latency. Moreover, we performed a comparative analysis of our adopted security solution with existing MSSA as described in
Table 17 and
Table 18. The solution is safe from the typical external illegitimate flooding requests as the external or exposed eCoach services are protected by a VPN and a firewall.
This study has consolidated the security implementation with Keycloak third-party IAM combined with SF and its performance evaluation in digital infrastructure. In future research, we will connect other third-party IAM (e.g., Okta, TSD) with SF to implement different security solutions and compare their performance evaluation against SSK. This study strictly focuses on SSK implementation and its performance analysis in an “on-premises” digital setup. In the future, we will extend our study in a cloud setup for SSK solution implementation, performance analysis, and comparing the performance outcome with the “on-premises” SSK performance results.
7. Conclusions
The literature review reveals that existing frameworks and security standards to secure the API endpoints in an MSA architecture have minimal experimental outcomes of confirming the integrated effectiveness of SF, SSF, third-party OAuth2, Bcrypt hash, VPN, firewall, and SSL. A prototype eCoach system has been implemented in this study using MSA as a prototype to assess the integration between the technologies. The research findings show that the SSK solution effectively protected the APIs from the vulnerabilities, such as CSRF, XSS, Clickjacking, content sniffing, brute force, DoS, DDoS, IP spoofing, and MITM. Integration of SSF with Keycloak has made the solution powerful and highly customizable. The overall solution is scalable, with approximately 300 concurrent requests. We can extend the study with other different penetration testing methods in the future.