Skip to content

Commit

Permalink
Add Autodiscover.xml support
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Martin committed Sep 14, 2015
1 parent 844b2eb commit 00ac83c
Show file tree
Hide file tree
Showing 10 changed files with 284 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .editorconfig
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = tab
indent_size = 4
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
* text=auto
4 changes: 4 additions & 0 deletions .gitignore
@@ -1,3 +1,7 @@
# Dot files
._*
.DS_Store

# Logs
logs
*.log
Expand Down
93 changes: 93 additions & 0 deletions .jscsrc
@@ -0,0 +1,93 @@
{
"esnext": true,
"excludeFiles": ["bower_components/**", "node_modules/**"],
"disallowAnonymousFunctions": true,
"disallowDanglingUnderscores": {
"allExcept": ["_this"]
},
"disallowEmptyBlocks": true,
"disallowKeywordsOnNewLine": ["else"],
"disallowKeywords": ["with"],
"disallowMixedSpacesAndTabs": true,
"disallowMultipleLineBreaks": true,
"disallowMultipleLineStrings": true,
"disallowNewlineBeforeBlockStatements": true,
"disallowOperatorBeforeLineBreak": ["+", "-", "/", "*", "."],
"disallowPaddingNewlinesInBlocks": true,
"disallowQuotedKeysInObjects": true,
"disallowSpaceAfterObjectKeys": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowSpaceBeforePostfixUnaryOperators": true,
"disallowSpacesInCallExpression": true,
"disallowTrailingComma": true,
"disallowYodaConditions": true,
"maximumLineLength": {
"value": 80,
"tabSize": 4,
"allowComments": false,
"allowUrlComments": true,
"allowRegex": true
},
"requireBlocksOnNewline": true,
"requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties",
"requireCapitalizedConstructors": true,
"requireCommaBeforeLineBreak": true,
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"],
"requireDotNotation": true,
"requireFunctionDeclarations": true,
"requireLineBreakAfterVariableAssignment": true,
"requireLineFeedAtFileEnd": true,
"requirePaddingNewlinesBeforeKeywords": [
"do",
"for",
"if",
"switch",
"case",
"try",
"void",
"while",
"with",
"return",
"typeof",
"function"
],
"requirePaddingNewLinesBeforeLineComments": {
"allExcept": "firstAfterCurly"
},
"requirePaddingNewLinesInObjects": true,
"requireParenthesesAroundIIFE": true,
"requireSemicolons": true,
"requireSpaceAfterBinaryOperators": true,
"requireSpaceAfterKeywords": true,
"requireSpaceBeforeBinaryOperators": true,
"requireSpaceBeforeBlockStatements": true,
"requireSpaceBeforeKeywords": [
"else",
"case",
"catch",
"finally",
"void",
"while",
"with",
"return"
],
"requireSpaceBeforeObjectValues": true,
"requireSpaceBetweenArguments": true,
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInConditionalExpression": true,
"requireSpacesInForStatement": true,
"requireSpacesInFunctionDeclaration": {
"beforeOpeningCurlyBrace": true
},
"safeContextKeyword": ["_this"],
"validateIndentation": "\t",
"validateLineBreaks": "LF",
"validateParameterSeparator": ", ",
"validateQuoteMarks": {
"mark": "'",
"escape": true
}
}
26 changes: 26 additions & 0 deletions .jshintrc
@@ -0,0 +1,26 @@
{
"curly": true,
"eqeqeq": true,
"freeze": true,
"futurehostile": true,
"globalstrict": true,
"latedef": true,
"maxcomplexity": 8,
"maxdepth": 4,
"maxparams": 4,
"noarg": true,
"nonbsp": true,
"shadow": "outer",
"singleGroups": true,
"undef": true,
"unused": true,
"boss": false,
"evil": false,
"lastsemic": false,
"loopfunc": false,
"validthis": true,
"strict": true,
"devel": true,
"node": true,
"esnext": true
}
4 changes: 3 additions & 1 deletion README.md
@@ -1,2 +1,4 @@
# autodiscover.xml
Providers Autodiscover capabilities for IMAP/SMTP services on Microsoft Outlook/Apple Mail and Autoconf capabilities for Thunderbird
Provides Autodiscover capabilities for IMAP/SMTP services on Microsoft Outlook/Apple Mail and Autoconf capabilities for Thunderbird

[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)
10 changes: 10 additions & 0 deletions app.json
@@ -0,0 +1,10 @@
{
"name": "Autodiscover.xml",
"description": "Providers Autodiscover capabilities for IMAP/SMTP services on Microsoft Outlook/Apple Mail and Autoconf capabilities for Thunderbird",
"website": "https://tiliq.com",
"repository": "https://github.com/Tiliq/autodiscover.xml",
"keywords": ["tiliq", "autoconfigure", "autoconf", "autodiscover", "outlook", "thunderbird", "apple mail", "imap", "smtp"],
"addons": [
"papertrail"
]
}
50 changes: 50 additions & 0 deletions index.js
@@ -0,0 +1,50 @@
'use strict';

const path = require('path');
const app = require('koa')();
const swig = require('koa-swig');
const body = require('koa-buddy');
const router = require('koa-router')();
const log = console.log.bind(console);

function findChild(name, children) {
for (let child of children) {
if (child.name === name) {
return child;
}
}
}

router.post('/Autodiscover/Autodiscover.xml', function *autodiscover(next) {
log(this.request.headers, this.request.body);

this.set('Content-Type', 'application/xml');

const request = findChild('Request');
const schema = findChild('AcceptableResponseSchema', request.children);
const email = findChild('EMailAddress', request.children).content;
const username = email.split('@')[0];
const domain = email.split('@')[1];

this.render('autodiscover', {
schema: schema.content,
email,
username,
domain
});

yield next;
});

app.context.render = swig({
root: path.join(__dirname, 'views'),
autoescape: true,
cache: 'memory',
ext: 'xml'
});

app.use(body());
app.use(router.routes());
app.use(router.allowedMethods());

app.listen(process.env.PORT || 8000);
36 changes: 36 additions & 0 deletions package.json
@@ -0,0 +1,36 @@
{
"name": "autodiscover.xml",
"version": "1.0.0",
"description": "Providers Autodiscover capabilities for IMAP/SMTP services on Microsoft Outlook/Apple Mail and Autoconf capabilities for Thunderbird",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Tiliq/autodiscover.xml.git"
},
"author": "Kevin J. Martin",
"license": "MIT",
"bugs": {
"url": "https://github.com/Tiliq/autodiscover.xml/issues"
},
"homepage": "https://github.com/Tiliq/autodiscover.xml#readme",
"keywords": [
"tiliq",
"autoconfigure",
"autoconf",
"autodiscover",
"outlook",
"thunderbird",
"apple mail",
"imap",
"smtp"
],
"dependencies": {
"koa": "^1.0.0",
"koa-buddy": "^0.1.0",
"koa-router": "^5.1.2",
"koa-swig": "^2.0.0"
}
}
52 changes: 52 additions & 0 deletions views/autodiscover.xml
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8" ?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
<Response xmlns="{{schema}}">
<User>
<DisplayName>{{email}}</DisplayName>
</User>

<Account>
<AccountType>email</AccountType>
<Action>settings</Action>

<Protocol>
<Type>IMAP</Type>
<TTL>1</TTL>

<Server>imap.{{domain}}</Server>
<Port>993</Port>

<LoginName>{{email}}</LoginName>

<DomainRequired>on</DomainRequired>
<DomainName>{{domain}}</DomainName>

<SPA>off</SPA>
<SSL>on</SSL>
<AuthRequired>on</AuthRequired>
</Protocol>
</Account>

<Account>
<AccountType>email</AccountType>
<Action>settings</Action>

<Protocol>
<Type>SMTP</Type>
<TTL>1</TTL>

<Server>imap.{{domain}}</Server>
<Port>587</Port>

<LoginName>{{email}}</LoginName>

<DomainRequired>on</DomainRequired>
<DomainName>{{domain}}</DomainName>

<SPA>off</SPA>
<SSL>on</SSL>
<AuthRequired>on</AuthRequired>
</Protocol>
</Account>
</Response>
</Autodiscover>

0 comments on commit 00ac83c

Please sign in to comment.