Skip to content

Commit

Permalink
✨ Add LDAP mobile config and support
Browse files Browse the repository at this point in the history
Signed-off-by: mathieu.brunot <mathieu.brunot@monogramm.io>
  • Loading branch information
madmath03 committed Sep 19, 2019
1 parent f51a28b commit b615744
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 36 deletions.
30 changes: 25 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

This service is created to autodiscover your provider email settings.

It provides IMAP/SMTP Autodiscover capabilities on Microsoft Outlook/Apple Mail, Autoconfig capabilities for Thunderbird, and Configuration Profiles for iOS/Apple Mail.
It provides IMAP/SMTP/LDAP Autodiscover capabilities on Microsoft Outlook/Apple Mail, Autoconfig capabilities for Thunderbird, and Configuration Profiles for iOS/Apple Mail.

**A simple support page is also available at the root of the autodiscover domain.**

Expand All @@ -22,6 +22,7 @@ smtp IN CNAME {{$MX_DOMAIN}}.
_imaps._tcp IN SRV 0 0 {{IMAP_PORT}} {{MX_DOMAIN}}.
_submission._tcp IN SRV 0 0 {{SMTP_PORT}} {{MX_DOMAIN}}.
_autodiscover._tcp IN SRV 0 0 443 autodiscover.{{$DOMAIN}}.
_ldap._tcp IN SRV 0 0 {{LDAP_PORT}} {{LDAP_HOST}}.
```

Replace above variables with data according to this table
Expand All @@ -31,8 +32,10 @@ Replace above variables with data according to this table
| MX_DOMAIN | The hostname name of your MX server |
| DOMAIN | Your apex/bare/naked Domain |
| AUTODISCOVER_IP | IP of the Autoconfig HTTP |
| IMAP_PORT | Port for the IMAP server |
| SMTP_PORT | Port for the SMTP server |
| IMAP_PORT | Port for your IMAP server |
| SMTP_PORT | Port for your SMTP server |
| LDAP_HOST | The hostname of your LDAP server |
| LDAP_PORT | Port for your LDAP server |

---

Expand All @@ -59,9 +62,17 @@ services:
- SMTP_HOST=smtp.domain.com
- SMTP_PORT=587
- SMTP_SOCKET=STARTTLS
- LDAP_HOST=ldap.domain.com
- LDAP_PORT=636
- LDAP_SOCKET=SSL
- LDAP_BASE=dc=ldap,dc=example,dc=com
- LDAP_USER_FIELD=uid
- LDAP_USER_BASE=ou=People,dc=ldap,dc=example,dc=com
- LDAP_SEARCH=(|(objectClass=PostfixBookMailAccount))
- PROFILE_IDENTIFIER=com.domain.autodiscover
- PROFILE_UUID=48C88203-4DB9-49E8-B593-4831903605A0
- PROFILE_UUID=92943D26-CAB3-4086-897D-DC6C0D8B1E86
- MAIL_UUID=7A981A9E-D5D0-4EF8-87FE-39FD6A506FAC
- LDAP_UUID=6ECB6BA9-2208-4ABF-9E60-4E9F4CD7309E
labels:
- "traefik.port=8000"
- "traefik.frontend.rule=Host:autoconfig.domain.com,autodiscover.domain.com"
Expand All @@ -85,9 +96,17 @@ services:
- SMTP_HOST=smtp.domain.com
- SMTP_PORT=587
- SMTP_SOCKET=STARTTLS
- LDAP_HOST=ldap.domain.com
- LDAP_PORT=636
- LDAP_SOCKET=SSL
- LDAP_BASE=dc=ldap,dc=example,dc=com
- LDAP_USER_FIELD=uid
- LDAP_USER_BASE=ou=People,dc=ldap,dc=example,dc=com
- LDAP_SEARCH=(|(objectClass=PostfixBookMailAccount))
- PROFILE_IDENTIFIER=com.domain.autodiscover
- PROFILE_UUID=48C88203-4DB9-49E8-B593-4831903605A0
- PROFILE_UUID=92943D26-CAB3-4086-897D-DC6C0D8B1E86
- MAIL_UUID=7A981A9E-D5D0-4EF8-87FE-39FD6A506FAC
- LDAP_UUID=6ECB6BA9-2208-4ABF-9E60-4E9F4CD7309E
deploy:
replicas: 1
labels:
Expand All @@ -112,6 +131,7 @@ The above autoconfiguration methods assume the following:
* Mozilla [Autoconfig configuration](https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Autoconfiguration/FileFormat/HowTo)
* Microsoft [Exchange Command Reference](https://docs.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-ascmd/1a3490f1-afe1-418a-aa92-6f630036d65a)
* Apple [ConfigurationProfile reference](https://developer.apple.com/library/archive/featuredarticles/iPhoneConfigurationProfileRef/index.html)
* [DNS SRV Records for LDAP](https://github.com/doctorjbeam/LDAPAutoDiscover)

* [Bootstrap](https://getbootstrap.com/), [jQuery](https://jquery.com/) and [Popper.js](https://popper.js.org/) used for default support page

Expand Down
34 changes: 31 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "autodiscover-email-settings",
"description": "Provides IMAP/SMTP Autoconfiguration capabilities for Microsoft Outlook, Apple Mail, and Thunderbird",
"description": "Provides IMAP/SMTP/LDAP Autoconfiguration capabilities for Microsoft Outlook, Apple Mail, and Thunderbird",
"website": "https://monogramm.io",
"repository": "https://github.com/monogramm/autodiscover-email-settings",
"keywords": ["monogramm", "autoconfigure", "autoconf", "autodiscover", "outlook", "thunderbird", "apple mail", "imap", "smtp"],
"keywords": ["monogramm", "autoconfigure", "autoconf", "autodiscover", "outlook", "thunderbird", "apple mail", "imap", "smtp", "ldap"],
"addons": [
"papertrail"
],
Expand Down Expand Up @@ -44,17 +44,45 @@
"description": "Your SMTP Socket",
"value": "STARTTLS"
},
"LDAP_HOST": {
"description": "Your LDAP Host",
"value": "ldap.example.com"
},
"LDAP_PORT": {
"description": "Your LDAP Port",
"value": "389"
},
"LDAP_SOCKET": {
"description": "Your LDAP Socket",
"value": "STARTTLS"
},
"LDAP_BASE": {
"description": "Your LDAP Base DN",
"value": "dc=ldap,dc=example,dc=com"
},
"LDAP_USER_FIELD": {
"description": "Your LDAP Username name",
"value": "uid"
},
"LDAP_USER_BASE": {
"description": "Your LDAP User Base DN",
"value": "ou=People,dc=ldap,dc=example,dc=com"
},
"PROFILE_IDENTIFIER": {
"description": "Your mobile profile identifier",
"value": "com.example.autodiscover"
},
"PROFILE_UUID": {
"description": "Your mobile profile globally unique ID",
"value": "48C88203-4DB9-49E8-B593-4831903605A0"
"value": "92943D26-CAB3-4086-897D-DC6C0D8B1E86"
},
"MAIL_UUID": {
"description": "Your mail profile globally unique ID",
"value": "7A981A9E-D5D0-4EF8-87FE-39FD6A506FAC"
},
"LDAP_UUID": {
"description": "Your ldap profile globally unique ID",
"value": "6ECB6BA9-2208-4ABF-9E60-4E9F4CD7309E"
}
}
}
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ router.post('/autodiscover/autodiscover.xml', autodiscover);
router.get('/Autodiscover/Autodiscover.xml', autodiscover);
router.post('/Autodiscover/Autodiscover.xml', autodiscover);


// Thunderbird
router.get('/mail/config-v1.1.xml', function *autoconfig() {
this.set('Content-Type', 'application/xml');
yield this.render('autoconfig');
});


// iOS / Apple Mail (/email.mobileconfig?email=username@domain.com or /email.mobileconfig?email=username)
router.get('/email.mobileconfig', function *autoconfig() {
let email = this.request.query.email;
Expand All @@ -99,6 +101,7 @@ router.get('/email.mobileconfig', function *autoconfig() {

const inssl = settings.imap.socket == 'SSL' || settings.imap.socket == 'STARTTLS' ? 'true' : 'false';
const outssl = settings.smtp.socket == 'SSL' || settings.smtp.socket == 'STARTTLS' ? 'true' : 'false';
const ldapssl = settings.ldap.socket == 'SSL' || settings.ldap.port == '636' ? 'true' : 'false';

this.set('Content-Type', 'application/x-apple-aspen-config; chatset=utf-8');
this.set('Content-Disposition', `attachment; filename="${filename}"`);
Expand All @@ -108,10 +111,12 @@ router.get('/email.mobileconfig', function *autoconfig() {
username,
domain,
inssl,
outssl
outssl,
ldapssl
});
});


// Generic support page
router.get('/', function *index() {
yield this.render('index.html');
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "autodiscover-email-settings",
"version": "1.0.0",
"description": "Provides IMAP/SMTP Autodiscover capabilities on Microsoft Outlook/Apple Mail, Autoconfig capabilities for Thunderbird, and Configuration Profiles for iOS/Apple Mail.",
"version": "1.2.0",
"description": "Provides IMAP/SMTP/LDAP Autodiscover capabilities on Microsoft Outlook/Apple Mail, Autoconfig capabilities for Thunderbird, and Configuration Profiles for iOS/Apple Mail.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"engines": {
"node": ">=4.0.0"
"node": ">=4.0.0"
},
"repository": {
"type": "git",
Expand All @@ -29,7 +29,8 @@
"thunderbird",
"apple mail",
"imap",
"smtp"
"smtp",
"ldap"
],
"dependencies": {
"koa": "^1.0.0",
Expand Down
12 changes: 12 additions & 0 deletions settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,23 @@ module.exports = {
port: process.env.SMTP_PORT,
socket: process.env.SMTP_SOCKET
},
ldap: {
host: process.env.LDAP_HOST,
port: process.env.LDAP_PORT,
socket: process.env.LDAP_SOCKET,
base: process.env.LDAP_BASE,
userfield: process.env.LDAP_USER_FIELD,
usersbase: process.env.LDAP_USER_BASE,
searchfilter: process.env.LDAP_SEARCH
},
mobile: {
identifier: process.env.PROFILE_IDENTIFIER,
uuid: process.env.PROFILE_UUID,
mail: {
uuid: process.env.MAIL_UUID,
},
ldap: {
uuid: process.env.LDAP_UUID,
}
}
};
34 changes: 18 additions & 16 deletions views/autoconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@
<displayShortName>%EMAILLOCALPART%</displayShortName>

<incomingServer type="imap">
<hostname>{{imap.host}}</hostname>
<port>{{imap.port}}</port>
<socketType>{{imap.socket}}</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILADDRESS%</username>
</incomingServer>
<hostname>{{imap.host}}</hostname>
<port>{{imap.port}}</port>
<socketType>{{imap.socket}}</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILADDRESS%</username>
</incomingServer>

<outgoingServer type="smtp">
<hostname>{{smtp.host}}</hostname>
<port>{{smtp.port}}</port>
<socketType>{{smtp.socket}}</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILADDRESS%</username>
<hostname>{{smtp.host}}</hostname>
<port>{{smtp.port}}</port>
<socketType>{{smtp.socket}}</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILADDRESS%</username>
</outgoingServer>

<documentation url="{{info.url}}">
<descr lang="fr">Description des paramètres</descr>
<descr lang="de">Allgemeine Beschreibung der Einstellungen</descr>
<descr lang="en">Generic settings page</descr>
</documentation>
<documentation url="{{info.url}}">
<descr lang="en">Generic settings page</descr>
<descr lang="fr">Paramètres généraux</descr>
<descr lang="es">Configuraciones genéricas</descr>
<descr lang="de">Allgemeine Beschreibung der Einstellungen</descr>
<descr lang="ru">Страница общих настроек</descr>
</documentation>
</emailProvider>
</clientConfig>
37 changes: 32 additions & 5 deletions views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,13 @@
<main role="main">
<div class="jumbotron">
<div class="container">
<h1 class="display-4">{{info.name}} Email settings</h1>
<h1 class="display-4">{{info.name}} generic settings</h1>
<p class="lead">Generic settings support page</p>
<p>This is a simple support page for email automatic configuration service.
It provides IMAP/SMTP Autodiscover capabilities on Microsoft Outlook/Apple Mail, Autoconfig
It provides IMAP/SMTP/LDAP Autodiscover capabilities on Microsoft Outlook/Apple Mail, Autoconfig
capabilities for Thunderbird, and Configuration Profiles for iOS/Apple Mail.
</p>
<p><a class="btn btn-primary btn-lg" href="https://github.com/Monogramm/autodiscover.xml"
<p><a class="btn btn-primary btn-lg" href="https://github.com/Monogramm/autodiscover-email-settings"
target="_blank" role="button">Learn more &raquo</a></p>
</div>
</div>
Expand Down Expand Up @@ -305,7 +305,7 @@ <h3 id="automatic" class="h3 font-weight-normal">Automatic settings</h3>
<div class="container">
<h3 id="mobileconfig" class="h3 font-weight-normal">Apple Configuration Profile</h3>

<div id="mobileconfig" class="mb-5">
<div class="mb-5">
<p>Enter your username or full email address and click the download button to setup your Apple mobile
device.</p>

Expand All @@ -328,7 +328,7 @@ <h3 id="mobileconfig" class="h3 font-weight-normal">Apple Configuration Profile<
<div class="container">
<h3 id="manualconfig" class="h3 font-weight-normal">Manual configuration</h3>

<div id="manualconfig" class="mb-5">
<div class="mb-5">
<p>Copy the following settings to your email application.</p>

<div class="row">
Expand Down Expand Up @@ -360,6 +360,33 @@ <h5 id="manualconfig-smtp">Outgoing server (SMTP)</h5>
</dl>
</div>
</div>

<p>If your email application supports LDAP contacts, copy the following settings.</p>

<div class="row">
<div class="col-md-6">
<h5 id="manualconfig-ldap">Contacts (LDAP)</h5>
<dl>
<dt>Hostname</dt>
<dd id="manualconfig-ldap-hostname">{{ldap.host}}</dd>

<dt>Port</dt>
<dd id="manualconfig-ldap-port">{{ldap.port}}</dd>

<dt>Encryption</dt>
<dd id="manualconfig-ldap-socket">{{ldap.socket}}</dd>

<dt>Base</dt>
<dd id="manualconfig-ldap-base">{{ldap.base}}</dd>

<dt>Username (replace <code>your.username</code> with your actual username)</dt>
<dd id="manualconfig-ldap-username">{{ldap.userfield}}=<code>your.username</code>,{{ldap.usersbase}}</dd>

<dt>Search Filter</dt>
<dd id="manualconfig-ldap-searchfilter">{{ldap.searchfilter}}</dd>
</dl>
</div>
</div>
</div>

<hr>
Expand Down
37 changes: 35 additions & 2 deletions views/mobileconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,44 @@
<key>PayloadVersion</key>
<real>1</real>
</dict>
<dict>
<key>LDAPAccountDescription</key>
<string>{{info.name}} LDAP</string>
<key>LDAPAccountHostName</key>
<string>{{ldap.host}}</string>
<key>LDAPAccountUseSSL</key>
<{{ldapssl}}/>
<key>LDAPAccountUserName</key>
<string>{{ldap.userfield}}={{username}},{{ldap.usersbase}}</string>
<key>LDAPSearchSettings</key>
<array>
<dict>
<key>LDAPSearchSettingDescription</key>
<string>{{info.name}} Contacts</string>
<key>LDAPSearchSettingSearchBase</key>
<string>{{ldap.base}}</string>
<key>LDAPSearchSettingScope</key>
<string>LDAPSearchSettingScopeSubtree</string>
</dict>
</array>
<key>PayloadDescription</key>
<string>{{info.name}} LDAP</string>
<key>PayloadDisplayName</key>
<string>{{info.name}} Contacts</string>
<key>PayloadIdentifier</key>
<string>{{mobile.identifier}}.com.apple.ldap.account.{{mobile.ldap.uuid}}</string>
<key>PayloadType</key>
<string>com.apple.ldap.account</string>
<key>PayloadUUID</key>
<string>{{mobile.ldap.uuid}}</string>
<key>PayloadVersion</key>
<real>1</real>
</dict>
</array>
<key>PayloadDescription</key>
<string>{{info.name}}</string>
<key>PayloadDisplayName</key>
<string>{{email}}</string>
<string>{{info.name}}</string>
<key>PayloadIdentifier</key>
<string>{{mobile.identifier}}</string>
<key>PayloadOrganization</key>
Expand All @@ -74,6 +107,6 @@
<key>PayloadUUID</key>
<string>{{mobile.uuid}}</string>
<key>PayloadVersion</key>
<integer>1</integer>
<integer>2</integer>
</dict>
</plist>

0 comments on commit b615744

Please sign in to comment.