feat: add more auth providers and cleanup google auth

it's no longer needed to use stunnel ;-)
This commit is contained in:
simon
2020-02-23 20:42:36 +01:00
parent 5e5005cf6b
commit 3f600c664f
22 changed files with 1351 additions and 152 deletions

1
__tests__/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*hokify*

View File

@@ -0,0 +1,21 @@
import 'mocha';
import { expect } from 'chai';
import * as fs from 'fs';
import { GoogleLDAPAuth } from '../../src/auth/GoogleLDAPAuth';
describe('test google ldap auth', function() {
this.timeout(10000);
it('authenticate against ldap server', async () => {
const auth = new GoogleLDAPAuth({
base: 'dc=hokify,dc=com',
tlsOptions: {
key: fs.readFileSync('./ldap.gsuite.hokify.com.40567.key'),
cert: fs.readFileSync('./ldap.gsuite.hokify.com.40567.crt')
}
});
const result = await auth.authenticate('username', 'password');
expect(result).to.equal(true);
});
});

View File

@@ -0,0 +1,18 @@
import 'mocha';
import { expect } from 'chai';
import { IMAPAuth } from '../../src/auth/IMAPAuth';
describe('test imap auth', () => {
it('authenticate against imap server', async () => {
const auth = new IMAPAuth({
host: 'imap.gmail.com',
port: 993,
useSecureTransport: true,
validHosts: ['gmail.com']
});
const result = await auth.authenticate('username', 'password');
expect(result).to.equal(true);
});
});

View File

@@ -0,0 +1,23 @@
import 'mocha';
import { expect } from 'chai';
import * as fs from 'fs';
import { LDAPAuth } from '../../src/auth/LDAPAuth';
describe('test ldap auth', function() {
this.timeout(10000);
it('authenticate against ldap server', async () => {
const auth = new LDAPAuth({
url: 'ldaps://ldap.google.com:636',
base: 'dc=hokify,dc=com',
tlsOptions: {
servername: 'ldap.google.com',
key: fs.readFileSync('./ldap.gsuite.hokify.com.40567.key'),
cert: fs.readFileSync('./ldap.gsuite.hokify.com.40567.crt'),
}
});
const result = await auth.authenticate('username', 'password');
expect(result).to.equal(true);
});
});

View File

@@ -0,0 +1,18 @@
import 'mocha';
import { expect } from 'chai';
import { SMTPAuth } from '../../src/auth/SMTPAuth';
describe('test smtp auth', () => {
it('authenticate against smtp server', async () => {
const auth = new SMTPAuth({
host: 'smtp.gmail.com',
port: 465,
useSecureTransport: true,
validHosts: ['gmail.com']
});
const result = await auth.authenticate('username', 'password');
expect(result).to.equal(true);
});
});

BIN
__tests__/eapol_test Executable file

Binary file not shown.

7
__tests__/tsconfig.json Normal file
View File

@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
},
"include": ["__tests__/*.ts", "*.ts", "../src/**/*.ts"]
}

16
__tests__/ttls-pap.conf Normal file
View File

@@ -0,0 +1,16 @@
#
# eapol_test -c ttls-pap.conf -s testing123
#
network={
ssid="example"
key_mgmt=WPA-EAP
eap=TTLS
identity="user"
anonymous_identity="anonymous"
password="pwd"
phase2="auth=PAP"
#
# Uncomment the following to perform server certificate validation.
ca_cert="./ssl/cert/ca.pem"
}