-
Notifications
You must be signed in to change notification settings - Fork 324
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
base: develop
Are you sure you want to change the base?
Conversation
7c60a5d
to
d1c075c
Compare
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.
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 -> |
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.
parseJSON = withObject "smtpCredentials" $ \v -> | |
parseJSON = withObject "EmailSMTPCredentials" $ \v -> |
i like the habit of using the haskell type as description verbatim.
services/brig/src/Brig/Options.hs
Outdated
v .:? "smtpAuth" .!= ("basic" :: String) >>= \case | ||
"xauth2" -> | ||
EmailSMTPXAUTH2 | ||
<$> v .: "smtpUsername" | ||
<*> v .: "smtpXAUTH2Token" | ||
_ -> | ||
EmailSMTPBasicAuth | ||
<$> v .: "smtpUsername" | ||
<*> v .: "smtpPassword" |
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.
this is fine, but you could also:
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?)
https://wearezeta.atlassian.net/browse/WPB-9859
Checklist
changelog.d