Skip to content

feat: add configuration, custom Auth and event handlers for Diamond Light Source#1497

Open
GrantDLS wants to merge 22 commits into
UserOfficeProject:developfrom
GrantDLS:dls-config
Open

feat: add configuration, custom Auth and event handlers for Diamond Light Source#1497
GrantDLS wants to merge 22 commits into
UserOfficeProject:developfrom
GrantDLS:dls-config

Conversation

@GrantDLS
Copy link
Copy Markdown
Contributor

@GrantDLS GrantDLS commented Apr 29, 2026

Description

This PR is to add the necessary configuration files, custom authorization class and email event handler for Diamond Light Source to be able to use User Office Project.

Motivation and Context

  • apps/backend/src/auth/DlsUserAuthorization.ts
    • Our own custom authorization class that works the same as the OAuthAuthorization class that it extends, except for it excludes some user attributes being pulled from the OAuth provider.
  • apps/backend/src/config/dls/configureDLSEnvironment.ts
    • This is all standard but also adds a utility method getUASInstance() which reads the value of a .env variable and falls back to a sensible default.
  • apps/backend/src/config/dependencyConfigDLS.ts
    • This is standard and just sets the dependency mappings
  • apps/backend/src/eventHandlers/email/DLS/DLSEmailHandler.ts
    • This is our email handler in which we're currently handling the following 2 events: PROPOSAL_SUBMITTED and PROPOSAL_CO_PROPOSER_INVITES_UPDATED. The logic for building and sending each email type is separated into different files for readability.
  • apps/frontend/public/images/diamond-white.svg
    • This is our logo for use in the header.

How Has This Been Tested

A test has been written for the email handler to ensure the correct email template is used for each event that we're handling.

Changes

There are only 2 changes to the core files of the code base:

  • apps/backend/src/auth/OAuthAuthorization.ts
    • This class mostly meets our needs, but a small change is needed in externalTokenLogin(). I've extended the class, but needed access to the private method getUserRole(), so I've made it's access modifier protected rather than private.
  • apps/backend/src/config/index.ts
    • A case has been added to the switch statement to load the DLS config file when it is set in the .env file.

Tests included/Docs Updated?

N/A

@GrantDLS GrantDLS marked this pull request as ready for review April 29, 2026 10:49
@GrantDLS GrantDLS requested a review from a team as a code owner April 29, 2026 10:49
@GrantDLS GrantDLS requested review from William-Edwards-STFC and removed request for a team April 29, 2026 10:49
@GrantDLS GrantDLS marked this pull request as draft April 29, 2026 12:48
@GrantDLS GrantDLS marked this pull request as ready for review April 29, 2026 12:48
@GrantDLS GrantDLS changed the title feat: Configuration, custom Auth and event handlers for Diamond Light Source feat: Add configuration, custom Auth and event handlers for Diamond Light Source Apr 29, 2026
Comment thread apps/backend/src/auth/DLSUserAuthorization.ts Outdated
Comment thread apps/backend/src/auth/DLSUserAuthorization.ts
Comment thread apps/backend/src/config/dls/configureDLSEnvironment.ts Outdated
Comment thread apps/backend/src/config/dls/configureDLSEnvironment.ts Outdated
Comment thread apps/backend/src/eventHandlers/email/dlsEmailHandler.ts Outdated
Comment thread apps/backend/src/eventHandlers/email/dlsEmailHandler.ts Outdated
Comment thread apps/backend/src/eventHandlers/email/dlsEmailHandler.ts Outdated
Comment thread apps/backend/src/eventHandlers/email/dlsEmailHandler.ts Outdated
Comment thread apps/backend/src/eventHandlers/email/dlsEmailHandler.ts Outdated
Comment thread apps/backend/src/eventHandlers/email/dlsEmailHandler.ts Outdated
Comment thread apps/backend/src/eventHandlers/email/dlsEmailHandler.ts Outdated
@GrantDLS GrantDLS changed the title feat: Add configuration, custom Auth and event handlers for Diamond Light Source feat: add configuration, custom Auth and event handlers for Diamond Light Source Apr 30, 2026
@yoganandaness
Copy link
Copy Markdown
Contributor

@GrantDLS Is this PR ready to be reviewed? If so, could you add the label "review:please"

@GrantDLS
Copy link
Copy Markdown
Contributor Author

@GrantDLS Is this PR ready to be reviewed? If so, could you add the label "review:please"

I've done quite a bit of refactoring since I created the PR. Just adding a couple of tests for the email handler and I'll add the label. Thank you, @yoganandaness .

Comment thread apps/backend/src/eventHandlers/email/DLS/DLSEmailHandler.spec.ts Outdated
Comment thread apps/backend/src/eventHandlers/email/DLS/DLSEmailHandler.spec.ts Outdated
Comment thread apps/backend/src/eventHandlers/email/DLS/proposalSubmittedHandler.ts Outdated
@zacharyjhankin
Copy link
Copy Markdown
Collaborator

Can you add an image of the email PROPOSAL_CO_PROPOSER_INVITES_UPDATED?

Comment thread apps/backend/src/auth/DLSUserAuthorization.ts Outdated
Comment thread apps/backend/src/auth/DLSUserAuthorization.ts
Comment thread apps/backend/src/auth/DLSUserAuthorization.ts Outdated
Comment thread apps/backend/src/auth/DLSUserAuthorization.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants