-
-
Notifications
You must be signed in to change notification settings - Fork 19
Add end-to-end tests for SaaS email triggers and user account bridges #1868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
17 changes: 15 additions & 2 deletions
17
...mpany-info/application/data-structures/invited-user-in-company-and-connection-group.ds.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,29 @@ | ||
| import { ApiProperty } from '@nestjs/swagger'; | ||
| import { OutgoingEmailPayloadDs } from '../../../email/application/data-structures/outgoing-email-payload.ds.js'; | ||
| import { UserRoleEnum } from '../../../user/enums/user-role.enum.js'; | ||
|
|
||
| export class InvitedUserInCompanyAndConnectionGroupDs { | ||
| @ApiProperty() | ||
| companyId: string; | ||
|
|
||
| @ApiProperty() | ||
| groupId: string; | ||
| @ApiProperty({ nullable: true, type: String }) | ||
| groupId: string | null; | ||
|
|
||
| @ApiProperty() | ||
| email: string; | ||
|
|
||
| @ApiProperty({ enum: UserRoleEnum }) | ||
| role: UserRoleEnum; | ||
|
|
||
| // Present only when the /saas/* bridge caller set `suppressEmail: true` (plan 15 Phase 2). | ||
| @ApiProperty({ required: false, type: OutgoingEmailPayloadDs }) | ||
| emailPayload?: OutgoingEmailPayloadDs; | ||
|
|
||
| // suppressEmail-only: the invited address belongs to an existing-but-inactive user, so no | ||
| // invitation was created — the payload above is a re-confirmation letter instead. Returned as | ||
| // a marked success (not thrown) because the global exception filter serializes a fixed shape | ||
| // and would strip the payload from an error body; the SaaS caller translates this back into | ||
| // the user-facing 400 after sending the letter. | ||
| @ApiProperty({ required: false }) | ||
| userAlreadyAddedInactive?: boolean; | ||
| } |
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
34 changes: 34 additions & 0 deletions
34
backend/src/entities/email/application/data-structures/outgoing-email-payload.ds.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { ApiProperty } from '@nestjs/swagger'; | ||
|
|
||
| export type OutgoingEmailPayloadType = | ||
| | 'email_confirmation' | ||
| | 'password_reset_request' | ||
| | 'email_change_request' | ||
| | 'email_changed' | ||
| | 'company_invite'; | ||
|
|
||
| /** | ||
| * Email context a `/saas/*` bridge returns INSTEAD of sending the letter itself when the caller | ||
| * sets `suppressEmail: true` (plan 15 Phase 2 — trigger inversion). The SaaS control plane builds | ||
| * the final link from `rawToken` and sends the email in-process. The raw token transits exactly | ||
| * one internal HTTPS hop and must never be logged on either side. | ||
| */ | ||
| export class OutgoingEmailPayloadDs { | ||
| @ApiProperty({ | ||
| enum: ['email_confirmation', 'password_reset_request', 'email_change_request', 'email_changed', 'company_invite'], | ||
| description: 'Email type discriminator (matches the SaaS EmailType catalog).', | ||
| }) | ||
| type: OutgoingEmailPayloadType; | ||
|
|
||
| @ApiProperty({ description: 'Recipient address.' }) | ||
| to: string; | ||
|
|
||
| @ApiProperty({ required: false, description: 'Raw verification token (absent for notice-only letters).' }) | ||
| rawToken?: string; | ||
|
|
||
| @ApiProperty({ required: false }) | ||
| companyId?: string; | ||
|
|
||
| @ApiProperty({ required: false, nullable: true, type: String }) | ||
| companyName?: string | null; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift
Raw single-use tokens are written to the application logs in self-hosted mode.
Both
printTechStringcalls embed the raw verification token in a complete link. The token grants email confirmation or company-invitation acceptance. Log files are usually retained, rotated, and shipped to external transports, so the exposure is wider than the local administrator console.The comments state this is the intended self-hosted delivery mechanism. If that decision stands, restrict the log level for these two lines and document the retention requirement. Consider gating the output behind an explicit configuration flag so operators who ship logs off-host can disable it.
Also applies to: 164-170
🤖 Prompt for AI Agents