在活动邮件程序 smtp 设置中使用 `:plain` 和 `:login` 有什么区别?
What is the difference between using `:plain` vs `:login` in active mailer smtp settings?
在活动邮件程序 smtp 设置中使用 :plain
与 :login
作为身份验证有什么区别?
平原
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com',
:enable_starttls_auto => true
}
登录
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :login,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com',
:enable_starttls_auto => true
}
在有关配置 smpt 设置的不同教程中,特别是对于发送网格,我已经看到这些被使用了。
他们两个似乎都在工作,那么这两者之间有什么区别?
推荐哪一个,为什么?
我领导 :plain
使用 base64
编码来混淆凭据,那么这是最安全的吗?
长话短说,因为您正在使用 TLS 您的凭据是安全的,因为它们是在加密连接上交换的。
根据 ActionMailer 文档here,无论身份验证如何 :plain
或 :login
,密码总是 Base64
编码。 Base64
编码的问题是任何窃听 SMTP 通信的人都可以轻松解码它。所以这两种认证机制在安全性上其实是一样的。
然而,当您使用 TLS
时,连接是加密的,并且 Base64 凭据通过此加密连接发送,使其安全。如果您不使用 TLS,那么最好使用 :cram_md5
而不是 :login
或 :plain
来保护凭据。
在活动邮件程序 smtp 设置中使用 :plain
与 :login
作为身份验证有什么区别?
平原
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com',
:enable_starttls_auto => true
}
登录
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :login,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com',
:enable_starttls_auto => true
}
在有关配置 smpt 设置的不同教程中,特别是对于发送网格,我已经看到这些被使用了。
他们两个似乎都在工作,那么这两者之间有什么区别? 推荐哪一个,为什么?
我领导 :plain
使用 base64
编码来混淆凭据,那么这是最安全的吗?
长话短说,因为您正在使用 TLS 您的凭据是安全的,因为它们是在加密连接上交换的。
根据 ActionMailer 文档here,无论身份验证如何 :plain
或 :login
,密码总是 Base64
编码。 Base64
编码的问题是任何窃听 SMTP 通信的人都可以轻松解码它。所以这两种认证机制在安全性上其实是一样的。
然而,当您使用 TLS
时,连接是加密的,并且 Base64 凭据通过此加密连接发送,使其安全。如果您不使用 TLS,那么最好使用 :cram_md5
而不是 :login
或 :plain
来保护凭据。