Skip to content
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

[To Main] DESENG-618: Removed token from the Email verification response object #2523

Merged
merged 4 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## May 23, 2024

- **Bugfix** Security issue with email verification [🎟️ DESENG-618](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-618)
- Removed verification token from the response object
- Updated the test to reflect the change

- **Bugfix** Add try catch block around snowplow call [🎟️ DESENG-621](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-621)
- Added a try catch block to all snowplow calls

Expand Down
7 changes: 4 additions & 3 deletions met-api/src/met_api/services/email_verification_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ def create(cls, email_verification: EmailVerificationSchema,

email_verification['created_by'] = email_verification.get(
'participant_id')
email_verification['verification_token'] = uuid.uuid4()
EmailVerification.create(email_verification, session)
verification_token = uuid.uuid4()
EmailVerification.create({**email_verification, 'verification_token': verification_token}, session)

# TODO: remove this once email logic is brought over from submission service to here
if email_verification.get('type', None) != EmailVerificationType.RejectedComment:
cls._send_verification_email(email_verification, subscription_type)
cls._send_verification_email(
{**email_verification, 'verification_token': verification_token}, subscription_type)

return email_verification

Expand Down
7 changes: 0 additions & 7 deletions met-api/tests/unit/api/test_email_verification_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,6 @@ def test_post_subscription_email_verification(client, jwt, session, notify_mock,
headers=headers, content_type=ContentType.JSON.value)

assert rv.status_code == 200
verification_token = rv.json.get('verification_token')

rv = client.get(f'/api/email_verification/{verification_token}',
headers=headers, content_type=ContentType.JSON.value)

assert rv.status_code == 200
assert rv.json.get('type') == EmailVerificationType.Subscribe

with patch.object(EmailVerificationService, 'create', side_effect=side_effect):
rv = client.post(f'/api/email_verification/{SubscriptionTypes.PROJECT.value}/subscribe',
Expand Down
Loading