Skip to content

Feat/keycloak sso 2#1174

Merged
dadiorchen merged 3 commits intoGreenstand:keycloakfrom
Mohmn:feat/keycloak-sso-2
Mar 19, 2026
Merged

Feat/keycloak sso 2#1174
dadiorchen merged 3 commits intoGreenstand:keycloakfrom
Mohmn:feat/keycloak-sso-2

Conversation

@Mohmn
Copy link
Member

@Mohmn Mohmn commented Mar 8, 2026

Description

Added Keycloak SSO integration (keycloak-js) with check-sso bootstrap and PKCE.
Moved auth initialization to app startup (src/index.js) before rendering routes.
Added clean auth routing flow:
LoginRoute starts SSO login
AuthCallback handles Keycloak callback and redirects back to original page
PrivateRoute simplified to guard-only behavior
Added axios auth client setup (authAxios / publicAxios) with:
token refresh via ensureFreshToken(30)
auth header attachment for protected requests
fallback to legacy token when Keycloak is disabled
redirect to /login on refresh failure
Refactored existing API/network calls from fetch to axios in API modules and related components/contexts (without introducing new backend endpoints).

Issue(s) addressed

What kind of change(s) does this PR introduce?

  • Enhancement
  • Bug fix
  • Refactor

Please check if the PR fulfils these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Issue

What is the current behavior?

What is the new behavior?

Breaking change

Does this PR introduce a breaking change?

Other useful information

@Mohmn Mohmn requested a review from a team as a code owner March 8, 2026 00:56
@Mohmn Mohmn force-pushed the feat/keycloak-sso-2 branch 2 times, most recently from a0567c8 to a1ecbd3 Compare March 9, 2026 20:24
Copy link
Collaborator

@dadiorchen dadiorchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mohmn please check the comment

@keycloak-auth
Feature: Keycloak Login

@keycloak-invalid
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don’t naming tag arbitrarily, every tag should be defined if we want to add new, @Skip is the one for skip invalided test

@@ -1,3 +1,4 @@
@local-auth
Feature: Login
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don’t need these two feature, just keep this one, and move the keycloak-login here.

@@ -0,0 +1,90 @@
import {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this written by yourself or generated by AI? The more test put it here, the more maintainace burden ahead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes ai, i use ai for tests

@@ -0,0 +1,59 @@
import React from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI work again?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@dadiorchen
Copy link
Collaborator

Also, the CI/CD failed for some reason, can you take a look?

The recent one passed with no error, https://github.com/Greenstand/treetracker-admin-client/actions/runs/22834081601/job/66431365450?pr=1171

@Mohmn
Copy link
Member Author

Mohmn commented Mar 11, 2026

Also, the CI/CD failed for some reason, can you take a look?

The recent one passed with no error, https://github.com/Greenstand/treetracker-admin-client/actions/runs/22834081601/job/66431365450?pr=1171

#1176
The CI errors are likely coming from the base branch since it’s failing there as well. I think the BDD-related packages might be the cause.

@Mohmn Mohmn marked this pull request as draft March 12, 2026 01:33
@Mohmn Mohmn force-pushed the feat/keycloak-sso-2 branch from fb0d605 to f119c8c Compare March 12, 2026 01:54
@dadiorchen dadiorchen marked this pull request as ready for review March 13, 2026 09:10
@dadiorchen
Copy link
Collaborator

dadiorchen commented Mar 13, 2026

@Mohmn looks good, the admin user is not good putting here, please: create a normal user, and use that user to login to replace the admin user.

And regenerate the report + video again.

@Mohmn
Copy link
Member Author

Mohmn commented Mar 14, 2026

Also, the CI/CD failed for some reason, can you take a look?

The recent one passed with no error, https://github.com/Greenstand/treetracker-admin-client/actions/runs/22834081601/job/66431365450?pr=1171

I have cleaned up the npm-related issues. However, package.json still needs some cleanup, i noticed that some packags are using * instead of version no's

@dadiorchen
Copy link
Collaborator

Great, please change the user and password, I will merge the code

@Mohmn Mohmn force-pushed the feat/keycloak-sso-2 branch from b252418 to dd2e622 Compare March 15, 2026 19:41
@Mohmn
Copy link
Member Author

Mohmn commented Mar 15, 2026

Great, please change the user and password, I will merge the code
done,
but i still get the api failure errors

Screenshot from 2026-03-16 01-14-45

@dadiorchen
Copy link
Collaborator

If the error don’t break the test, that’s fine

But I see the user name is still the admin? Did I miss something?

@Mohmn
Copy link
Member Author

Mohmn commented Mar 16, 2026

If the error don’t break the test, that’s fine

But I see the user name is still the admin? Did I miss something?

strange , i guess something went wrong with my rebase
but i made another commit

@dadiorchen dadiorchen merged commit 6f70ca7 into Greenstand:keycloak Mar 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants