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

Add support for proxy_protocol and proxy_smtp_auth parameters #1526

Merged
merged 2 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ class { 'nginx':
}

nginx::resource::mailhost { 'domain1.example':
auth_http => 'server2.example/cgi-bin/auth',
protocol => 'smtp',
listen_port => 587,
ssl_port => 465,
starttls => 'only',
xclient => 'off',
ssl => true,
ssl_cert => '/tmp/server.crt',
ssl_key => '/tmp/server.pem',
auth_http => 'server2.example/cgi-bin/auth',
protocol => 'smtp',
listen_port => 587,
ssl_port => 465,
starttls => 'only',
xclient => 'off',
proxy_protocol => 'off',
proxy_smtp_auth => 'off',
ssl => true,
ssl_cert => '/tmp/server.crt',
ssl_key => '/tmp/server.pem',
}
```

Expand Down
28 changes: 18 additions & 10 deletions manifests/resource/mailhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
# for authorization.
# @param xclient
# Whether to use xclient for smtp
# @param proxy_protocol
# Wheter to use proxy_protocol
# @param proxy_smtp_auth
# Wheter to use proxy_smtp_auth
# @param imap_auth
# Sets permitted methods of authentication for IMAP clients.
# @param imap_capabilities
Expand Down Expand Up @@ -111,16 +115,18 @@
#
# @example SMTP server definition
# nginx::resource::mailhost { 'domain1.example':
# ensure => present,
# auth_http => 'server2.example/cgi-bin/auth',
# protocol => 'smtp',
# listen_port => 587,
# ssl_port => 465,
# starttls => 'only',
# xclient => 'off',
# ssl => true,
# ssl_cert => '/tmp/server.crt',
# ssl_key => '/tmp/server.pem',
# ensure => present,
# auth_http => 'server2.example/cgi-bin/auth',
# protocol => 'smtp',
# listen_port => 587,
# ssl_port => 465,
# starttls => 'only',
# xclient => 'off',
# proxy_protocol => 'off',
# proxy_smtp_auth => 'off',
# ssl => true,
# ssl_cert => '/tmp/server.crt',
# ssl_key => '/tmp/server.pem',
# }
#
define nginx::resource::mailhost (
Expand Down Expand Up @@ -155,6 +161,8 @@
Optional[String] $auth_http = undef,
Optional[String] $auth_http_header = undef,
Enum['on', 'off'] $xclient = 'on',
Enum['on', 'off'] $proxy_protocol = 'off',
Enum['on', 'off'] $proxy_smtp_auth = 'off',
Optional[String] $imap_auth = undef,
Optional[Array] $imap_capabilities = undef,
Optional[String] $imap_client_buffer = undef,
Expand Down
2 changes: 2 additions & 0 deletions spec/acceptance/nginx_mail_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class { 'nginx':
ssl_cert => '/etc/pki/tls/certs/blah.cert',
ssl_key => '/etc/pki/tls/private/blah.key',
xclient => 'off',
proxy_protocol => 'off',
proxy_smtp_auth => 'off',
}
"

Expand Down
24 changes: 24 additions & 0 deletions spec/defines/resource_mailhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@
value: 'off',
match: ' xclient off;'
},
{
title: 'should set proxy_protocol',
attr: 'proxy_protocol',
value: 'off',
match: ' proxy_protocol off;'
},
{
title: 'should set proxy_smtp_auth',
attr: 'proxy_smtp_auth',
value: 'off',
match: ' proxy_smtp_auth off;'
},
{
title: 'should set auth_http',
attr: 'auth_http',
Expand Down Expand Up @@ -551,6 +563,18 @@
value: 'off',
match: ' xclient off;'
},
{
title: 'should set proxy_protocol',
attr: 'proxy_protocol',
value: 'off',
match: ' proxy_protocol off;'
},
{
title: 'should set proxy_smtp_auth',
attr: 'proxy_smtp_auth',
value: 'off',
match: ' proxy_smtp_auth off;'
},
{
title: 'should set auth_http',
attr: 'auth_http',
Expand Down
2 changes: 2 additions & 0 deletions templates/mailhost/mailhost_common.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
protocol <%= @protocol %>;
<% end -%>
xclient <%= @xclient %>;
proxy_protocol <%= @proxy_protocol %>;
proxy_smtp_auth <%= @proxy_smtp_auth %>;
<% if defined? @auth_http -%>
auth_http <%= @auth_http %>;
<% end -%>
Expand Down