Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from financialforcedev/feature/generic-oauth-p…
…rovider-updates Feature/generic oauth provider updates
- Loading branch information
Showing
73 changed files
with
8,049 additions
and
3,123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ coverage | |
dist | ||
node_modules | ||
|
||
config/local* | ||
**/config/local* | ||
|
||
*.cert | ||
*.key | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": true, | ||
"source.organizeImports": true | ||
}, | ||
"editor.detectIndentation": false, | ||
"editor.formatOnSave": true, | ||
"editor.insertSpaces": false, | ||
"files.insertFinalNewline": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.