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

Feature/generic oauth provider updates #25

Merged
merged 35 commits into from Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ccac6a5
Update all dependencies
mwoodffdc Mar 11, 2019
b0bce08
Add system tests to typescript configuration
mwoodffdc Mar 11, 2019
f8fb986
Add system test tslint configuration
mwoodffdc Mar 11, 2019
60cbd84
Update tslint configuration to complete all documentation
mwoodffdc Mar 11, 2019
7b0f9dc
Update test configuration
mwoodffdc Mar 11, 2019
0b1c204
Remove openid directory
mwoodffdc Mar 11, 2019
7176e4e
Add the client cache and tests
mwoodffdc Mar 11, 2019
dcce1b9
Add the environment validator and tests
mwoodffdc Mar 11, 2019
0f47ad0
Add the base OAuth2 client and tests
mwoodffdc Mar 11, 2019
e528d92
Add the JWT creation and tests
mwoodffdc Mar 11, 2019
4f1bffb
Add the OAuth2 JWT client and tests
mwoodffdc Mar 11, 2019
bd79ef1
Add the OpenId Identity checks and tests
mwoodffdc Mar 11, 2019
a0b5d50
Add the OpenID client and tests
mwoodffdc Mar 11, 2019
a29235b
Add the salesforce identity checks and tests
mwoodffdc Mar 11, 2019
195753c
Add the Salesforce client and tests
mwoodffdc Mar 11, 2019
7b2f9e9
Update all flows and tests
mwoodffdc Mar 11, 2019
02dfb78
Update the grant and tests
mwoodffdc Mar 11, 2019
0ee762d
Update the middleware and tests
mwoodffdc Mar 11, 2019
3ce61be
Update the revocation functions and tests
mwoodffdc Mar 11, 2019
d60d201
Update the userinfo functions and tests
mwoodffdc Mar 11, 2019
74cc719
Add identity middleware and tests
mwoodffdc Mar 11, 2019
73cdd63
Update the index
mwoodffdc Mar 11, 2019
f0925b6
Remove the server certificate and script
mwoodffdc Mar 11, 2019
2fe2d61
Add the default configuration
mwoodffdc Mar 11, 2019
359d073
Update the Salesforce system tests
mwoodffdc Mar 11, 2019
cbc9115
Add the Google system tests
mwoodffdc Mar 11, 2019
b6217a7
Make sure all local config files are ignored
mwoodffdc Mar 11, 2019
8aa6858
Add example files
mwoodffdc Mar 11, 2019
c238dc4
Update the readme
mwoodffdc Mar 11, 2019
464d55f
Update example default with missing type
mwoodffdc Mar 11, 2019
cdae5b4
Update the salesforce system test so that all imports aree from the s…
mwoodffdc Mar 11, 2019
f83ca64
Makes sure that the JWT iat is an integer
mwoodffdc Mar 11, 2019
c78e6a7
Fix a couple of typos
mwoodffdc Mar 12, 2019
cd82f2e
Update the copyright notices starting comments
mwoodffdc Mar 12, 2019
169c05a
Update the documentation
mwoodffdc Mar 12, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -3,7 +3,7 @@ coverage
dist
node_modules

config/local*
**/config/local*

*.cert
*.key
Expand Down
16 changes: 0 additions & 16 deletions certificates/serverCertificateGenerator.txt

This file was deleted.

19 changes: 19 additions & 0 deletions config/default.json
@@ -0,0 +1,19 @@
{
"authProvider": {
"google": {
"httpTimeout": 4000,
"issuerURI": "https://accounts.google.com",
"type": "OpenID"
},
"salesforceConnection": {
"httpTimeout": 4000,
"issuerURI": "https://test.salesforce.com",
"type": "Salesforce"
},
"salesforceIdentity": {
"httpTimeout": 4000,
"issuerURI": "https://test.salesforce.com",
"type": "Salesforce"
}
}
}
2 changes: 2 additions & 0 deletions examples/.gitignore
@@ -0,0 +1,2 @@
node_modules
dist
1 change: 1 addition & 0 deletions examples/.npmrc
@@ -0,0 +1 @@
package-lock=false
18 changes: 18 additions & 0 deletions examples/.vscode/launch.json
@@ -0,0 +1,18 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug App",
"runtimeArgs": [
"-r",
"ts-node/register"
],
"args": [
"src/index.ts"
],
"console": "integratedTerminal"
}
]
}
10 changes: 10 additions & 0 deletions examples/.vscode/settings.json
@@ -0,0 +1,10 @@
{
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
},
"editor.detectIndentation": false,
"editor.formatOnSave": true,
"editor.insertSpaces": false,
"files.insertFinalNewline": true
}
23 changes: 23 additions & 0 deletions examples/config/default.json
@@ -0,0 +1,23 @@
{
"app": {
"authProvider": {
"salesforce": {
"httpTimeout": 4000,
"issuerURI": "https://test.salesforce.com",
"type": "Salesforce"
}
},
"openid": {
"salesforce": {
"immediate": false,
"prompt": "consent",
"redirectUri": "https://localhost:8080/api/auth/v1.0/callback",
"scope": "openid",
"verifySignature": false
},
"salesforceConnection": {
"scope": "api"
}
}
}
}
38 changes: 38 additions & 0 deletions examples/package.json
@@ -0,0 +1,38 @@
{
"name": "orizuru-auth-examples",
"version": "1.0.0",
"description": "Orizuru Auth Examples",
"main": "dist/index.js",
"files": [
"src"
],
"repository": {
"type": "git",
"url": "https://github.com/financialforcedev/orizuru-auth"
},
"scripts": {
"build": "rm -rf dist && tsc",
"build-clean": "rm -rf dist",
"build-compile": "tsc",
"install-dependencies": "npm i",
"start": "npm run install-dependencies && npm run build && node dist/index.js"
},
"author": "FinancialForce",
"license": "BSD-3-Clause",
"dependencies": {
"@financialforcedev/orizuru": "^9.3.0",
"@financialforcedev/orizuru-auth": "^7.0.0",
"@financialforcedev/orizuru-transport-rabbitmq": "^5.0.1",
"@types/config": "0.0.34",
"@types/jsforce": "^1.9.5",
"@types/pem": "^1.9.5",
"config": "^3.0.1",
"jsforce": "^1.9.1",
"pem": "^1.14.2"
},
"devDependencies": {
"ts-node": "^8.0.3",
"tslint": "^5.13.1",
"typescript": "^3.3.3333"
}
}
72 changes: 72 additions & 0 deletions examples/src/index.ts
@@ -0,0 +1,72 @@
// Imports
import { json, Request, Response, Server } from '@financialforcedev/orizuru';
import { flow } from '@financialforcedev/orizuru-auth';
import { Transport } from '@financialforcedev/orizuru-transport-rabbitmq';
import config from 'config';
import https from 'https';
import pem, { CertificateCreationResult } from 'pem';

// Define a function that creates a self-signed certificate
function createCertificate(): Promise<CertificateCreationResult> {
return new Promise((resolve, reject) => {
pem.createCertificate({ days: 1, selfSigned: true }, (err, result) => {
if (err) {
return reject(err);
}

process.stdout.write('Created certificate\n');
return resolve(result);
});
});
}

// Create the server
const server = new Server({
authProvider: {
salesforce: config.get('app.authProvider.salesforce')
},
openid: {
salesforce: config.get('app.openid.salesforce'),
salesforceConnection: config.get('app.openid.salesforceConnection')
},
port: 8080,
transport: new Transport({
prefetch: 1,
url: 'amqp://localhost'
})
});

// Add the route to generate the authorization URL (in this case we use 'test' as the state parameter)
server.addRoute({
method: 'get',
middleware: [
json()
],
responseWriter: () => async (err: Error | undefined, req: Request, res: Response) => {
const url = await flow.webServer.authorizationUrlGenerator(server.options.authProvider.salesforce)(server.options.openid.salesforce, server.options.openid.salesforce);
res.redirect(url);
},
schema: {
fields: [],
name: 'auth',
namespace: 'api.v1_0',
type: 'record'
},
synchronous: true
});

// **All code specified in the rest of the readme should be added here**

// Create a self-signed certificate and then start the server listening to connections using HTTPS
createCertificate().then((certificate) => {

const serverOptions: https.ServerOptions = {
cert: certificate.certificate,
key: certificate.clientKey
};

const httpsServer = https.createServer(serverOptions, server.serverImpl);
httpsServer.listen(server.options.port);
process.stdout.write('Started server\n');

});
22 changes: 22 additions & 0 deletions examples/tsconfig.json
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"declaration": true,
"declarationDir": "dist/types",
"esModuleInterop": true,
"inlineSourceMap": true,
"inlineSources": true,
"module": "commonjs",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "./dist",
"strict": true,
"strictNullChecks": true,
"target": "es2017"
},
"include": [
"src"
]
}
25 changes: 25 additions & 0 deletions examples/tslint.json
@@ -0,0 +1,25 @@
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"rules": {
"indent": [
true,
"tabs",
4
],
"max-line-length": false,
"quotemark": [
true,
"single"
],
"trailing-comma": [
true,
{
"multiline": "never",
"singleline": "never"
}
]
}
}