-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
add Oauth2 support #130
add Oauth2 support #130
Conversation
Thanks again for the work you're putting into this @drakkan. I do have a private O365 account for Office, so I have access to outlook.com. Not sure if this also supports MS Exchange Online or if that's only for business customers. I'm happy to test with my credentials if this works. |
Worst case I have access to both providers enterprise offerings and I have access to the Microsoft Sponsored Azure Program. |
uhmm, the protocol implementation looks correct, maybe I have to fix something with my app registration
also note the 5 seconds delay after the |
This reads to me like the server (S) sends |
This is probably more relevant (pretty sure on closer inspection it is indeed the same):
|
It works! I missed a permission while registering my app
|
Does it happen to work with the default implementation too? I suspect it may |
yes it works
|
and here is the output for an auth error
|
Nice work! Probably want to delete those credentials. Looks like you can probably just remove variants all together for now probably? |
Great work @drakkan and thanks as always for the helpful input as well @james-d-elliott! If you give me a hint on how get the tokens created, I can set up a github secret for the GH test environment, so that they don't fail. |
yes, no need for variants, I'll update the PR later.
Bad token
|
To create the tokens you need first to register your app on Google/Microsoft and then you can use the oauth2 library. To complete the oauth exchange and get a refresh token. I don't think this can be done in go-mail, you need an http server to get the auth callback. This is a one time operation, the refresh tokens never expire or expire after a long time |
@wneessen for Microsoft for example, I registered an app in the Azure portal like this You need to set credentials, redirect uri, permissions etc. Not sure if you can automate this in GitHub. Using the refresh token you can create access tokens to use for sending emails |
Ok, that sounds more complex than expected. Not sure if the GH workflow will let us accomplish this easily. |
@wneessen we need to better investigate this:
I don't thing my PR sends the |
@drakkan I'm pretty sure that comes from the smtp auth method: Line 238 in 13c8d0a
Reason behind this is the SMTP AUTH RFC where it states:
I assume that the OAUTH implementations of MS and Google did not implement this behaviour. Not sure if it's better to extend |
yes it is not so easy to automate, additional the first time the user must be redirected to its account and grant the required permission. Take a look here for an overview |
Thanks, I'll take a look later today and/or in the next few days |
Microsoft also accept the same protocol used for Google servers
XOAUTH2 does not follow the SMTP AUTH RFC
@drakkan Is the PR ready to review/merge or are you still working on it? |
It should be ready. Both success and auth error cases seem to work as expected |
Perfect. I'll review and get a new release ready in the next days. |
Thank you. |
That's good to know. Might actually be a good idea to get some "real life" data first. |
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.
Everything looks good. Ready to merge
@james-d-elliott this feature has been included in the development version of SFTPGo since last week but unfortunately I still haven't received any feedback from the user who requested it. |
@drakkan Were you able to get in some more real-life testing from your project? Do you think we are ready for an official release? |
not yet, sorry. I'll tag SFTPGo v2.5.2 with this feature included the next weekend anyway. |
I did email you on the 9th, figured you were busy because I didn't see a response. |
I have sent the email, you can remove them from this post. I mistyped "gmail" incidentally it looks like. |
sent some instructions via email, check your spam folder if you dont't see any reply 😄 Thank you!!! |
I see them, will take a look this weekend. |
no hurry, thank you! |
fixes #129
The Microsoft variant is untested. Do no merge.
If in the meantime you have suggestions to improve the code, they are welcome.
If anyone can share a Microsoft Exchange Online account for testing and is interested in this feature, please contact me privately