Skip to content

Add config so we can enable Rails Mailer previews in deployed envs#5521

Merged
zachmargolis merged 5 commits intomainfrom
margolis-mailer-previews-lower-env
Oct 20, 2021
Merged

Add config so we can enable Rails Mailer previews in deployed envs#5521
zachmargolis merged 5 commits intomainfrom
margolis-mailer-previews-lower-env

Conversation

@zachmargolis
Copy link
Copy Markdown
Contributor


if IdentityConfig.store.rails_mailer_previews_enabled
config.action_mailer.show_previews = true
config.action_mailer.preview_path ||= Rails.root.join('spec/mailers/previews')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this shouldn't be = instead? Just wondering based on the default being a folder which doesn't exist in our project (test/mailers/previews). Unsure if that default is applied directly, or evaluated based on preview_path being nil.

Also wonder if we could just set preview_path regardless of environment / configuration, and rely on show_previews setting to actually enact it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why do we only need to set this in production, and not in other environments?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re: = ... yes that was a copy-paste error from a blog on enabling in prod 🤦

Re: why only in prod, I think because the configs default to these values in lower environments


if IdentityConfig.store.rails_mailer_previews_enabled
# CSP 2.0 only; overriden by x_frame_options in some browsers
default_csp_config[:frame_ancestors] = %w('self')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to sort out how to expect this to behave where we set x-frame-options as deny but frame-ancestors to self, since I see the former as implying a frame-ancestors of none (per docs). I wonder instead if we could just set x-frame-options to SAMEORIGIN?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I read correctly, SAMEORIGIN is even more poorly supported?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I went with this because I trusted the old comment here that frame-ancestors takes precedence over x-frame-options

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coupled with the fact that this worked locally (the reason I had to add the frame options in the last PR was that the previews didn't work without that change)

Co-authored-by: Andrew Duthie <andrew.duthie@gsa.gov>
@zachmargolis zachmargolis merged commit a62bfb4 into main Oct 20, 2021
@zachmargolis zachmargolis deleted the margolis-mailer-previews-lower-env branch October 20, 2021 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants