Skip to content

Add warning to mailer documentation about authentication #11563

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

Merged
merged 5 commits into from
May 24, 2020

Conversation

zeripath
Copy link
Contributor

References #7966

Signed-off-by: Andrew Thornton [email protected]

@zeripath zeripath added the type/docs This PR mainly updates/creates documentation label May 22, 2020
@mrsdizzie
Copy link
Member

Hmm weird, I use SMTP fine with user/password without setting IS_TLS_ENABLED=true or localhost set.

Looking at the way Gitea works is that if you set IS_TLS_ENABLED=true or have port 465 then it tries to starts a TLS connection directly:

isSecureConn := opts.IsTLSEnabled || (strings.HasSuffix(port, "465"))
// Start TLS directly if the port ends with 465 (SMTPS protocol)
if isSecureConn {
conn = tls.Client(conn, tlsconfig)
}

but if not it still tries StartTLS if supported:

// If not using SMTPS, always use STARTTLS if available
hasStartTLS, _ := client.Extension("STARTTLS")
if !isSecureConn && hasStartTLS {
if err = client.StartTLS(tlsconfig); err != nil {
return fmt.Errorf("StartTLS: %v", err)
}
}

Which will upgrade the connection to a TLS connection in most cases. So IS_TLS_ENABLED=true is somewhat confusing as you will often end up with a TLS connection anyway since StartTLS will work in many cases -- and since it just works you'll never think to change the default IS_TLS_ENABLED setting because you won't have a TLS problem. In the case of the linked issue it doesn't work because that server happens to not support TLS at all.

So I think it should say you can only use username/password if the SMTP server supports TLS.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 22, 2020
@zeripath
Copy link
Contributor Author

zeripath commented May 23, 2020

@mrsdizzie - I forgot about that little feature - hopefully I've improved @guillep2k's suggestion.

@guillep2k presumably nota bene has died out in the Americas, I thought it was well-known e.g. i.e. etc.

@silverwind
Copy link
Member

Can you also add this to app.ini.sample?

@mrsdizzie
Copy link
Member

@zeripath looks good. Maybe while in here we can update the comment forIS_TLS_ENABLED=true that it actually means to just try Implicit TLS first. I can't make a code suggestion since it isn't part of the diff but maybe:

Try an Implicit TLS connection first. WIll fall back to STARTTLS if not supported. Implicit TLS is also implied when using port 465 in the `HOST` value.

Since the name is confusing and the current comment isn't really descriptive of what it does (most people read it as required for any TLS and it is probably wrongly suggested for servers or ports that don't support Implicit TLS).

@zeripath
Copy link
Contributor Author

@mrsdizzie do you mean explicit rather than implicit here? My understanding is that STARTTLS is opportunistic TLS or implicit - in that the server and the client will upgrade to TLS implicitly without us explicitly telling them to, similarly connecting to a TLS port and detecting it was a TLS connection would be implicit, but saying connect with TLS is being explicit.

@zeripath
Copy link
Contributor Author

Oh this is a weirdness of the RFC - the implicit here means that at the protocol layer the TLS is implicit. (even though the user has made it very explicit that they want TLS.)

@mrsdizzie
Copy link
Member

@zeripath yes agree its all very confusing : (

Most simply, STARTTLS is considered the explicit one because the connection is explicitly upgraded if not secure. Other option is implicit because its implied the connection is already secure.

Signed-off-by: Andrew Thornton <[email protected]>
@zeripath
Copy link
Contributor Author

OK I've tried to make that a bit clearer.

Fundamentally IS_TLS_ENABLED needs to be changed - it's confusing and should be FORCE_SMTPS_CONNECTION.

Copy link
Member

@mrsdizzie mrsdizzie left a comment

Choose a reason for hiding this comment

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

lgtm -- hopefully this will be just as helpful to us in the future as a reminder of how it works : )

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 24, 2020
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 24, 2020
@zeripath zeripath merged commit 02a52d6 into go-gitea:master May 24, 2020
@zeripath zeripath deleted the improve-mailer-docs branch May 24, 2020 22:56
ydelafollye pushed a commit to ydelafollye/gitea that referenced this pull request Jul 31, 2020
)

* Add warning to mailer documentation about authentication

References go-gitea#7966

Signed-off-by: Andrew Thornton <[email protected]>

* As per @guillep2k and @mrsdizzie

* as per @mrsdizzie

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: guillep2k <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/docs This PR mainly updates/creates documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants