Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maintenance: Use Net::SMTP authenticator API for XOauth2 support.
- Loading branch information
Showing
5 changed files
with
25 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ | ||
|
||
require 'net/smtp' | ||
|
||
class Net::SMTP | ||
class AuthXoauth2 < Net::SMTP::Authenticator | ||
auth_type :xoauth2 | ||
|
||
def auth(user, secret) | ||
token = xoauth2_string(user, secret) | ||
|
||
finish("AUTH XOAUTH2 #{base64_encode(token)}") | ||
end | ||
|
||
private | ||
|
||
def xoauth2_string(user, secret) | ||
"user=#{user}\1auth=Bearer #{secret}\1\1" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters