sincerely 1.1.4 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8145214d026bf9a3055f7192b694b84dceb0bfa89a4a78e526a5832dfb016675
4
- data.tar.gz: 393c5f2ba30f47710726e86190f054a43502331444c3ca61e326304bb6ebb223
3
+ metadata.gz: 6f9d8077a60c896468257937b8386a6b02675d5540576207dfdfe6fde2d30327
4
+ data.tar.gz: bd84c37199b404102e2acfbf51a7835c10a53d41b83f8af2527d5e31b4c05f49
5
5
  SHA512:
6
- metadata.gz: c50b3fd1d13596262f3aba63044c3348faa5c0fe87159cba4895ba25da90572f5c0e5e6ff8fbfca398774ad84c3c6edbbe163201091094afa135ac68fe207fa1
7
- data.tar.gz: 6ae7839a324a550b09f3866609b5f6ba733da0e4a935267e8eefd7df122d712fe9e1738072b03570167b279928c00906bdc14153b22f9cdd7b0e101ee544c3b5
6
+ metadata.gz: 9ce92f5c1f802392aa081fa332baee7a0076b8708e309f3fc765f28c0dc62cce3759d40623cdf75838d2d8d3d0c007b1fb64b05970e5c8fb6d216cb5164283f3
7
+ data.tar.gz: a47d13e92e9acc43c98146ffc3b7ecbd10b53fdee81e6330046fd050b7759be39707dc7f9d611d21948208712660d07dd83136097d2707cd675c79ae1e110ce8
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.2.0] - 2026-09-22
6
+
7
+ ### Security
8
+ - The AWS SES webhook now rejects SNS messages whose `TopicArn` is not the configured one, with `403 Forbidden`. Signature verification alone only proves that a message was signed by SNS, not that it came from our topic: any AWS account could subscribe the public endpoint, have the subscription auto-confirmed, and publish SES-shaped events for message ids it knows.
9
+
10
+ ### Added
11
+ - `topic_arn` option for the email delivery method, holding the ARN of the SNS topic the SES configuration set publishes to
12
+
13
+ ### Changed
14
+ - **Breaking**: the webhook rejects every message when `topic_arn` is not configured. Existing installations must add it to `config/sincerely.yml` before upgrading, or delivery events stop being processed.
15
+
5
16
  ## [1.1.4] - 2026-09-21
6
17
 
7
18
  ### Fixed
data/README.md CHANGED
@@ -64,6 +64,7 @@ defaults: &defaults
64
64
  access_key_id: your_access_key_id
65
65
  secret_access_key: your_secret_access_key
66
66
  configuration_set_name: config_set
67
+ topic_arn: arn:aws:sns:region:account-id:your-topic
67
68
  sms:
68
69
  ```
69
70
 
@@ -71,6 +72,7 @@ defaults: &defaults
71
72
  * `access_key_id`: AWS access key id
72
73
  * `secret_access_key`: AWS secret access key
73
74
  * `configuration_set_name`: the name of the configuration set to use when sending the email, you don't need to specify the configuration set option if you don't want to handle SES email sending events
75
+ * `topic_arn`: the ARN of the SNS topic the configuration set publishes events to. Required by the webhook described in the `Callbacks` section, which rejects messages coming from any other topic
74
76
 
75
77
  Sincerely uses the `aws-sdk-sesv2` gem to send emails. See [sesv2](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/SESV2.html) for details.
76
78
 
@@ -150,7 +152,7 @@ Please note that the notification state is updated only if the event callback is
150
152
 
151
153
  `EmailAwsSes` delivery system handles SES email sending events. To enable it make sure:
152
154
  * you have run the `events` task described in the `Getting Started` section
153
- * you have set the `configuration_set_name` option described in the `Configuration` section
155
+ * you have set the `configuration_set_name` and `topic_arn` options described in the `Configuration` section
154
156
  * you have run the following task that generates the webhook controller for you
155
157
  ```bash
156
158
  rails g sincerely:aws_ses_webhook_controller SES_WEBHOOK
@@ -18,6 +18,8 @@ module Sincerely
18
18
  def create
19
19
  verifier.authenticate!(request.raw_post)
20
20
 
21
+ return head :forbidden unless trusted_topic?
22
+
21
23
  case sns_message_type
22
24
  when 'SubscriptionConfirmation'
23
25
  confirm_subscription
@@ -52,6 +54,20 @@ module Sincerely
52
54
  posted_message_body['Token']
53
55
  end
54
56
 
57
+ def trusted_topic?
58
+ expected_topic_arn = delivery_options[:topic_arn]
59
+
60
+ if expected_topic_arn.blank?
61
+ logger&.error('[Sincerely] SNS webhook rejected: no topic_arn configured for the email delivery method')
62
+ return false
63
+ end
64
+
65
+ return true if topic_arn == expected_topic_arn
66
+
67
+ logger&.error("[Sincerely] SNS webhook rejected: unexpected TopicArn #{topic_arn.inspect}")
68
+ false
69
+ end
70
+
55
71
  def event_payload
56
72
  message = posted_message_body['Message']
57
73
  JSON.parse(message) if message.present?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sincerely
4
- VERSION = '1.1.4'
4
+ VERSION = '1.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sincerely
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 100 Starlings
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-09-21 00:00:00.000000000 Z
11
+ date: 2026-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aasm