feat: implement OAuth2 authentication for EAM API access - #1646
Open
yoganandaness wants to merge 2 commits into
Open
feat: implement OAuth2 authentication for EAM API access#1646yoganandaness wants to merge 2 commits into
yoganandaness wants to merge 2 commits into
Conversation
yoganandaness
requested review from
Bhaswati1148,
TCMeldrum,
jekabs-karklins and
zacharyjhankin
and removed request for
a team and
Bhaswati1148
July 15, 2026 12:37
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the backend EAM asset registration integration to call the Camel API and authenticate via an OAuth2 client_credentials token exchange, replacing the previous Basic-auth approach. This aligns the service with the new IT-mandated integration path and auth mechanism.
Changes:
- Added
getAccessTokenutility for OAuth2 token retrieval (client credentials + Basic client auth + form-encoded body). - Updated
performApiRequestto sendAuthorization: Bearer <token>to Camel endpoints and removed the old Basic-auth headers. - Updated environment variable documentation, example
.env, and CI workflow configuration for the new OAuth2/Camel settings.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| documentation/docs/developer-guide/configuration.md | Documents the updated EAM/Camel OAuth2 environment variables. |
| apps/backend/src/services/assetRegistrar/eam/utils/performApiRequest.ts | Switches API calls to Bearer token auth via getAccessToken. |
| apps/backend/src/services/assetRegistrar/eam/utils/getEnvOrThrow.ts | Updates the allowed EAM env var keys to include OAuth2 settings. |
| apps/backend/src/services/assetRegistrar/eam/utils/getAccessToken.ts | Implements OAuth2 client-credentials token exchange for EAM/Camel access. |
| apps/backend/src/services/assetRegistrar/eam/utils/getAccessToken.spec.ts | Adds unit tests validating token request shape and error handling. |
| apps/backend/example.development.env | Updates the example backend env file to the new OAuth2 variable set. |
| .github/workflows/test-build.yml | Updates CI env vars for the EAM integration to the new OAuth2 variable set. |
Comment on lines
10
to
12
| try { | ||
| const base64Credentials = Buffer.from( | ||
| `${getEnvOrThrow('EAM_AUTH_USER')}:${getEnvOrThrow('EAM_AUTH_PASSWORD')}` | ||
| ).toString('base64'); | ||
| const accessToken = await getAccessToken(); | ||
|
|
Comment on lines
+23
to
+27
| describe('getAccessToken', () => { | ||
| afterEach(() => { | ||
| jest.restoreAllMocks(); | ||
| }); | ||
|
|
Comment on lines
+533
to
536
| EAM_OAUTH_SCOPE: uos.api.read | ||
| EAM_OAUTH_AUDIENCE: https://ios.esss.lu.se/ | ||
| EAM_AUTH_ORGANIZATION: dummyOrg | ||
| EAM_EQUIPMENT_PART_CODE: 12413 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Migrates the EAM asset registration integration from calling EAM directly to
calling it through the Camel API, and switches authentication from Basic Auth
to an OAuth2 client_credentials flow.
getAccessTokenutil that requests an OAuth2 access token from theconfigured token endpoint (
client_credentialsgrant,Basic base64(clientId:clientSecret)auth, url-encoded
grant_type/scope/audbody).performApiRequestnow obtains an access token and sends it as aBearertoken to the Camel endpoints; the old Basic auth and
tenant/organizationheaders were removed.
EAM_AUTH_USER,EAM_AUTH_PASSWORD,EAM_AUTH_TENANT; addedEAM_OAUTH_TOKEN_URL,EAM_AUTH_CLIENT_ID,EAM_AUTH_CLIENT_SECRET,EAM_OAUTH_SCOPE,EAM_OAUTH_AUDIENCE.EAM_API_URLnow points at the Camel base URL (the/assetsand/casemanagementpaths are appended as before).example.development.env, CI workflow env, and configuration docs.Motivation and Context
The IT team has decided that UO should no longer call EAM directly but go
through the Camel API, and the underlying OAuth has changed accordingly. This
change adapts our integration to the new auth flow (OAuth2 token exchange +
Bearer token) and the new Camel endpoints.
How Has This Been Tested
getAccessTokenutil (token request shape, errorhandling) pass.
client secret is available, to confirm the Camel response body matches the
currently-parsed shape.
Fixes
Changes
(new/removed environment variables must be set in each environment).
apps/backend/src/services/assetRegistrar/eam/), CI workflow,and documentation.
Depends on
Tests included/Docs Updated?