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

[WPB-9859] Support OAUTH SMTP authentication #4277

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

stefanwire
Copy link
Contributor

https://wearezeta.atlassian.net/browse/WPB-9859

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Sep 30, 2024
@fisx fisx changed the title Support OAUTH SMTP authentication [WPB-9859] Support OAUTH SMTP authentication Sep 30, 2024
Copy link
Contributor

@fisx fisx left a comment

Choose a reason for hiding this comment

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

looks good so far i think (assuming you're adding what we just discussed later today).

i agree that we should also write a test in /integration. as an easy way to commit the test to the PR without breaking things when the credentials evaporate, we can deactivate the test by default, printing an info "if you want this test to run, you need to provide credentials in the source code and remove the pending").

deriving (Show, Generic)

instance FromJSON EmailSMTPCredentials
instance FromJSON EmailSMTPCredentials where
parseJSON = withObject "smtpCredentials" $ \v ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
parseJSON = withObject "smtpCredentials" $ \v ->
parseJSON = withObject "EmailSMTPCredentials" $ \v ->

i like the habit of using the haskell type as description verbatim.

Comment on lines 128 to 136
v .:? "smtpAuth" .!= ("basic" :: String) >>= \case
"xauth2" ->
EmailSMTPXAUTH2
<$> v .: "smtpUsername"
<*> v .: "smtpXAUTH2Token"
_ ->
EmailSMTPBasicAuth
<$> v .: "smtpUsername"
<*> v .: "smtpPassword"
Copy link
Contributor

Choose a reason for hiding this comment

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

this is fine, but you could also:

Suggested change
v .:? "smtpAuth" .!= ("basic" :: String) >>= \case
"xauth2" ->
EmailSMTPXAUTH2
<$> v .: "smtpUsername"
<*> v .: "smtpXAUTH2Token"
_ ->
EmailSMTPBasicAuth
<$> v .: "smtpUsername"
<*> v .: "smtpPassword"
v .:? "smtpAuth" >>= \case
Just "xauth2" ->
EmailSMTPXAUTH2
<$> v .: "smtpUsername"
<*> v .: "smtpXAUTH2Token"
_ -> -- this covers the `Just "basicAuth"` case and the fallback for everything else.
EmailSMTPBasicAuth
<$> v .: "smtpUsername"
<*> v .: "smtpPassword"

(not tested)

(or should there be a type error for everything but Nothing in the fallback rule?)

@echoes-hq echoes-hq bot added the echoes: product-roadmap/feature Work contributing to adding a new feature as part of the product roadmap. label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes: product-roadmap/feature Work contributing to adding a new feature as part of the product roadmap. ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants