From 8cf160e095906de94ca228af36ed05a98208d389 Mon Sep 17 00:00:00 2001 From: Ifaz-Ikram Date: Tue, 5 May 2026 22:25:27 +0530 Subject: [PATCH 1/4] feat: add admin role to Keycloak realm configuration --- development/keycloak/realm-config.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/development/keycloak/realm-config.json b/development/keycloak/realm-config.json index 0b5f49a..01cdf04 100644 --- a/development/keycloak/realm-config.json +++ b/development/keycloak/realm-config.json @@ -64,7 +64,12 @@ { "name": "patient", "description": "Role for patients in the healthcare system" + }, + { + "name": "admin", + "description": "Role for administrators in the healthcare system" } + ] }, "clients": [ From 66e42b99797fc756104780835d7c0694fe573848 Mon Sep 17 00:00:00 2001 From: Ifaz-Ikram Date: Tue, 5 May 2026 23:00:29 +0530 Subject: [PATCH 2/4] feat: implement custom Keycloak login theme and update realm configuration for MediCare integration --- development/docker-compose.yaml | 9 +- development/keycloak/realm-config.json | 30 ++- .../keycloak/themes/medicare/login/error.ftl | 27 +++ .../keycloak/themes/medicare/login/info.ftl | 38 ++++ .../medicare/login/login-reset-password.ftl | 39 ++++ .../keycloak/themes/medicare/login/login.ftl | 63 +++++ .../themes/medicare/login/register.ftl | 69 ++++++ .../medicare/login/resources/css/login.css | 215 ++++++++++++++++++ .../themes/medicare/login/theme.properties | 2 + 9 files changed, 480 insertions(+), 12 deletions(-) create mode 100644 development/keycloak/themes/medicare/login/error.ftl create mode 100644 development/keycloak/themes/medicare/login/info.ftl create mode 100644 development/keycloak/themes/medicare/login/login-reset-password.ftl create mode 100644 development/keycloak/themes/medicare/login/login.ftl create mode 100644 development/keycloak/themes/medicare/login/register.ftl create mode 100644 development/keycloak/themes/medicare/login/resources/css/login.css create mode 100644 development/keycloak/themes/medicare/login/theme.properties diff --git a/development/docker-compose.yaml b/development/docker-compose.yaml index 82b9693..0833a9a 100644 --- a/development/docker-compose.yaml +++ b/development/docker-compose.yaml @@ -16,8 +16,8 @@ services: # Keycloak Server keycloak: - image: quay.io/keycloak/keycloak:latest - command: start-dev + image: quay.io/keycloak/keycloak:26.6.1 + command: start-dev --import-realm environment: KC_DB: postgres KC_DB_URL: jdbc:postgresql://postgres:5432/keycloak @@ -27,6 +27,9 @@ services: KC_BOOTSTRAP_ADMIN_PASSWORD: admin ports: - "8080:8080" + volumes: + - ./keycloak/themes:/opt/keycloak/themes:ro + - ./keycloak/realm-config.json:/opt/keycloak/data/import/realm-config.json:ro depends_on: postgres: condition: service_healthy @@ -50,4 +53,4 @@ services: - backend volumes: - postgres_data: \ No newline at end of file + postgres_data: diff --git a/development/keycloak/realm-config.json b/development/keycloak/realm-config.json index 01cdf04..6152de8 100644 --- a/development/keycloak/realm-config.json +++ b/development/keycloak/realm-config.json @@ -5,6 +5,7 @@ "registrationAllowed": true, "registrationEmailAsUsername": false, "rememberMe": true, + "loginTheme": "medicare", "verifyEmail": false, "resetPasswordAllowed": true, "editUsernameAllowed": false, @@ -57,6 +58,10 @@ ], "roles": { "realm": [ + { + "name": "admin", + "description": "Role for administrators in the healthcare system" + }, { "name": "doctor", "description": "Role for doctors in the healthcare system" @@ -64,27 +69,34 @@ { "name": "patient", "description": "Role for patients in the healthcare system" - }, - { - "name": "admin", - "description": "Role for administrators in the healthcare system" } - ] }, "clients": [ { "clientId": "medicare", + "name": "MediCare Frontend", + "secret": "medicare-dev-secret", + "baseUrl": "http://127.0.0.1:3000", "publicClient": false, "standardFlowEnabled": true, "directAccessGrantsEnabled": false, "redirectUris": [ - "http://localhost:3000/*" + "http://localhost:3000/*", + "http://127.0.0.1:3000/*", + "http://127.0.0.1:8000/api/auth/callback", + "http://localhost:8000/api/auth/callback", + "http://localhost:3002/*" ], + "attributes": { + "post.logout.redirect.uris": "http://localhost:3000/login##http://127.0.0.1:3000/login##http://localhost:3002/login" + }, "webOrigins": [ - "http://localhost:3000/*", - "http://localhost:8000/*" + "http://localhost:3000", + "http://127.0.0.1:3000", + "http://localhost:3002", + "http://localhost:8000" ] } ] -} \ No newline at end of file +} diff --git a/development/keycloak/themes/medicare/login/error.ftl b/development/keycloak/themes/medicare/login/error.ftl new file mode 100644 index 0000000..38b3dcf --- /dev/null +++ b/development/keycloak/themes/medicare/login/error.ftl @@ -0,0 +1,27 @@ + + + + + + MediCare Sign-In Error + + + +
+
+
+ +

MediCare

+

Sign-In Error

+

${kcSanitize((message.summary)!'Unable to complete sign-in.')?no_esc}

+
+ + Back to MediCare Sign-In +
+
+ + diff --git a/development/keycloak/themes/medicare/login/info.ftl b/development/keycloak/themes/medicare/login/info.ftl new file mode 100644 index 0000000..0fedfa1 --- /dev/null +++ b/development/keycloak/themes/medicare/login/info.ftl @@ -0,0 +1,38 @@ + + + + + + MediCare + + + +
+
+
+ +

MediCare

+

Account Notice

+
+ + <#if messageHeader??> +
${kcSanitize(messageHeader)?no_esc}
+ + <#if message?has_content> +
${kcSanitize(message.summary)?no_esc}
+ + + <#if actionUri??> + ${msg("proceedWithAction")} + <#else> + Back to sign in + +
+
+ + diff --git a/development/keycloak/themes/medicare/login/login-reset-password.ftl b/development/keycloak/themes/medicare/login/login-reset-password.ftl new file mode 100644 index 0000000..44ac461 --- /dev/null +++ b/development/keycloak/themes/medicare/login/login-reset-password.ftl @@ -0,0 +1,39 @@ + + + + + + Reset MediCare Password + + + +
+
+
+ +

MediCare

+

Reset Password

+

Enter your username or email and we will send recovery instructions if the account exists.

+
+ + <#if message?has_content> + + + +
+
+ + +
+ +
+ + +
+
+ + diff --git a/development/keycloak/themes/medicare/login/login.ftl b/development/keycloak/themes/medicare/login/login.ftl new file mode 100644 index 0000000..3d27d82 --- /dev/null +++ b/development/keycloak/themes/medicare/login/login.ftl @@ -0,0 +1,63 @@ + + + + + + ${(realm.displayName)!'MediCare'} Sign In + + + +
+
+
+ +

MediCare

+

Secure Sign In

+

Use your MediCare account to access patient monitoring, reports, and administrative tools.

+
+ + <#if message?has_content> + + + +
+ <#if !usernameHidden??> +
+ + +
+ + +
+ + +
+ +
+ <#if realm.rememberMe && !usernameHidden??> + + + <#if realm.resetPasswordAllowed> + Forgot password? + +
+ + value="${auth.selectedCredential}"> + +
+ + <#if realm.registrationAllowed && !registrationDisabled??> + + +
+
+ + diff --git a/development/keycloak/themes/medicare/login/register.ftl b/development/keycloak/themes/medicare/login/register.ftl new file mode 100644 index 0000000..45ada1b --- /dev/null +++ b/development/keycloak/themes/medicare/login/register.ftl @@ -0,0 +1,69 @@ + + + + + + Create MediCare Account + + + +
+
+
+ +

MediCare

+

Create Account

+

Register with the MediCare identity service to continue securely.

+
+ + <#if message?has_content> + + + +
+
+ + +
+ +
+ + +
+ +
+ + +
+ + <#if !realm.registrationEmailAsUsername> +
+ + +
+ + + <#if passwordRequired??> +
+ + +
+ +
+ + +
+ + + +
+ + +
+
+ + diff --git a/development/keycloak/themes/medicare/login/resources/css/login.css b/development/keycloak/themes/medicare/login/resources/css/login.css new file mode 100644 index 0000000..feb7601 --- /dev/null +++ b/development/keycloak/themes/medicare/login/resources/css/login.css @@ -0,0 +1,215 @@ +:root { + --mc-sky: #00a6f4; + --mc-sky-dark: #0089c9; + --mc-sky-pale: #eef6fc; + --mc-text: #16324f; + --mc-text-secondary: #405b78; + --mc-muted: #566d86; + --mc-border: rgba(24, 59, 99, 0.1); + --mc-surface: rgba(255, 255, 255, 0.9); + --mc-danger: #dc4b4b; + --mc-success: #2f9e61; + --mc-focus: rgba(95, 152, 208, 0.35); + --mc-shadow: 0 20px 40px rgba(22, 50, 79, 0.14); +} + +* { + box-sizing: border-box; +} + +body { + min-height: 100vh; + margin: 0; + color: var(--mc-text); + font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; + background: + radial-gradient(circle at 8% 8%, rgba(0, 166, 244, 0.18), transparent 32rem), + radial-gradient(circle at 88% 15%, rgba(47, 158, 97, 0.14), transparent 28rem), + linear-gradient(151deg, #b9d4ee 0%, #d8eaf7 35%, #fdf6ed 65%, #ffffff 100%); +} + +.mc-page { + display: flex; + min-height: 100vh; + align-items: center; + justify-content: center; + padding: 2rem 1rem; +} + +.mc-card { + width: min(100%, 34rem); + border: 1px solid var(--mc-border); + border-radius: 1.5rem; + background: var(--mc-surface); + box-shadow: var(--mc-shadow); + backdrop-filter: blur(18px); + padding: clamp(1.5rem, 4vw, 2.5rem); +} + +.mc-header { + display: flex; + flex-direction: column; + align-items: center; + gap: 0.75rem; + text-align: center; +} + +.mc-badge { + display: inline-flex; + width: 3.25rem; + height: 3.25rem; + align-items: center; + justify-content: center; + border-radius: 1.25rem; + background: linear-gradient(180deg, var(--mc-sky) 0%, var(--mc-sky-dark) 100%); + color: #fff; + box-shadow: 0 10px 24px rgba(22, 50, 79, 0.12); +} + +.mc-brand { + margin: 0; + color: var(--mc-sky); + font-size: 1.25rem; + font-weight: 700; + letter-spacing: 0; +} + +.mc-title { + margin: 0.25rem 0 0; + color: var(--mc-text); + font-size: clamp(2rem, 7vw, 2.5rem); + line-height: 1.1; + font-weight: 800; + letter-spacing: 0; +} + +.mc-copy { + margin: 0.5rem auto 0; + max-width: 26rem; + color: var(--mc-text-secondary); + font-size: 1rem; + line-height: 1.6; +} + +.mc-form { + margin-top: 2rem; +} + +.mc-field { + margin-top: 1rem; +} + +.mc-label { + display: block; + margin-bottom: 0.4rem; + color: var(--mc-text-secondary); + font-size: 0.875rem; + font-weight: 700; +} + +.mc-input { + width: 100%; + min-height: 2.85rem; + border: 1px solid var(--mc-border); + border-radius: 0.9rem; + background: #fff; + color: var(--mc-text); + font: inherit; + padding: 0 0.9rem; + outline: none; + transition: border-color 160ms ease, box-shadow 160ms ease; +} + +.mc-input:focus { + border-color: var(--mc-sky); + box-shadow: 0 0 0 4px var(--mc-focus); +} + +.mc-row { + display: flex; + align-items: center; + justify-content: space-between; + gap: 1rem; + margin-top: 1rem; + color: var(--mc-text-secondary); + font-size: 0.875rem; +} + +.mc-check { + display: inline-flex; + align-items: center; + gap: 0.5rem; +} + +.mc-check input { + width: 1.1rem; + height: 1.1rem; + accent-color: var(--mc-sky); +} + +.mc-link { + color: var(--mc-sky-dark); + font-weight: 700; + text-decoration: none; +} + +.mc-link:hover { + color: var(--mc-text); +} + +.mc-button { + display: inline-flex; + width: 100%; + min-height: 3rem; + align-items: center; + justify-content: center; + margin-top: 1.25rem; + border: 0; + border-radius: 1rem; + background: var(--mc-sky); + color: #fff; + cursor: pointer; + font: inherit; + font-weight: 800; + transition: background-color 160ms ease, transform 160ms ease; +} + +.mc-button:hover { + background: var(--mc-sky-dark); + transform: translateY(-1px); +} + +.mc-message { + margin-top: 1.25rem; + border-radius: 1rem; + padding: 0.85rem 1rem; + font-size: 0.9rem; + line-height: 1.5; +} + +.mc-message-error { + border: 1px solid rgba(220, 75, 75, 0.24); + background: #fdf1f1; + color: var(--mc-danger); +} + +.mc-message-success { + border: 1px solid rgba(47, 158, 97, 0.24); + background: #eef9f2; + color: var(--mc-success); +} + +.mc-footer { + margin-top: 1.5rem; + text-align: center; + color: var(--mc-muted); + font-size: 0.9rem; + line-height: 1.5; +} + +@media (max-width: 420px) { + .mc-row { + flex-direction: column; + align-items: flex-start; + } +} diff --git a/development/keycloak/themes/medicare/login/theme.properties b/development/keycloak/themes/medicare/login/theme.properties new file mode 100644 index 0000000..bac7d8b --- /dev/null +++ b/development/keycloak/themes/medicare/login/theme.properties @@ -0,0 +1,2 @@ +parent=base +styles=css/login.css From 487e0f531d325b2af2f0500a633762c0b96178fc Mon Sep 17 00:00:00 2001 From: "IFAZ M.I.M." Date: Wed, 6 May 2026 19:56:57 +0530 Subject: [PATCH 3/4] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- development/keycloak/themes/medicare/login/error.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/development/keycloak/themes/medicare/login/error.ftl b/development/keycloak/themes/medicare/login/error.ftl index 38b3dcf..2faf5a2 100644 --- a/development/keycloak/themes/medicare/login/error.ftl +++ b/development/keycloak/themes/medicare/login/error.ftl @@ -20,7 +20,7 @@

${kcSanitize((message.summary)!'Unable to complete sign-in.')?no_esc}

- Back to MediCare Sign-In + Back to MediCare Sign-In From 716cc147a370e6f9808767a53daadc14949bc46b Mon Sep 17 00:00:00 2001 From: "IFAZ M.I.M." Date: Wed, 6 May 2026 19:57:06 +0530 Subject: [PATCH 4/4] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- development/keycloak/realm-config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/development/keycloak/realm-config.json b/development/keycloak/realm-config.json index 6152de8..3cc70d6 100644 --- a/development/keycloak/realm-config.json +++ b/development/keycloak/realm-config.json @@ -76,7 +76,7 @@ { "clientId": "medicare", "name": "MediCare Frontend", - "secret": "medicare-dev-secret", + "secret": "OVERRIDE-THIS-CLIENT-SECRET", "baseUrl": "http://127.0.0.1:3000", "publicClient": false, "standardFlowEnabled": true,