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

Auth: CRAM-MD5 #52

Closed
Jonny007-MKD opened this issue Mar 4, 2016 · 5 comments
Closed

Auth: CRAM-MD5 #52

Jonny007-MKD opened this issue Mar 4, 2016 · 5 comments

Comments

@Jonny007-MKD
Copy link

Hi,

as far as I understood your code you implement the smtp.Auth interface which is then used by the smtp package when calling c.Auth().

In auth.go you implement LOGIN and PLAIN mechanisms. Have you ever thought about implementing CRAM-MD5?

You would have to return CRAM-MD5 in Auth.Send, listen for the base64 encoded challenge in Auth.Next, decode it and return (base64 encoded) the username and a MD5 response à la

digest = MD5(('password' XOR opad), MD5(('password' XOR ipad), challenge)).

Details can be found in this Tutorial and RFC 2195.

@alexcesaro
Copy link
Member

CRAM-MD5 is already implemented in the standard library.

I added an example to make it clear how to use it with Gomail.

@Jonny007-MKD
Copy link
Author

Thank you, that's quite easy :)
What about auto detection of Auth? Like using CRAM-MD5 if supported by the server and falling back to LOGIN/PLAIN if not? Can I do this without connecting to the SMTP server on my own?

alexcesaro added a commit that referenced this issue Mar 6, 2016
Also deprecated NewPlainDialer() in favor of NewDialer().

Fixes #52
@alexcesaro
Copy link
Member

I just added the automatic support of CRAM-MD5.

You should now be able to remove the Send method in Gogs. The only setting that is not supported in Gomail is the DisableHelo setting of Gogs. But it seems useless since the functions of the smtp package automatically call Client.hello().

@Jonny007-MKD
Copy link
Author

Great, thanks! :)

I found some code (in smtp.go?) that says something like

if hostname != "" {
    c.Hello(hostname)
}

Is this redundant in gomail if the smtp package calls it?

@alexcesaro
Copy link
Member

The smtp package calls the Hello with localhost as a parameter. If you want to call Hello with an other parameter you have to call it manually. That is why it is called in Gomail when LocalName is not empty.

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

No branches or pull requests

2 participants