Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #284 from luca-waldmann-cimt/master
Browse files Browse the repository at this point in the history
Fixes #${283}
  • Loading branch information
jwulf committed Jan 25, 2023
2 parents bc94f6a + 7e9e989 commit 9938457
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 8 deletions.
Empty file modified .husky/pre-commit
100755 → 100644
Empty file.
Empty file modified .husky/prepare-commit-msg
100755 → 100644
Empty file.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ const zbc = new ZBClient("my-secure-broker.io:443", {
audience: "my-secure-broker.io",
clientId: "myClientId",
clientSecret: "randomClientSecret",
customRootCert: fs.readFileSync('./my_CA.pem'),
cacheOnDisk: true
}
}
Expand All @@ -441,6 +442,8 @@ The `cacheOnDisk` option will cache the token on disk in `$HOME/.camunda`, which
If the cache directory is not writable, the ZBClient constructor will throw an exception. This is considered fatal, as it can lead to denial of service or hefty bills if you think caching is on when it is not.
The `customRootCert` argument is optional. It can be used to provide a custom TLS certificate as a Buffer, which will be used while obtaining the OAuth token from the specified URL. If not provided, the CAs provided by [Mozilla](https://ccadb-public.secure.force.com/mozilla/IncludedCACertificateReport) will be used.
<a name = "basic-auth"></a>
## Basic Auth
Expand Down
Empty file modified bin/zeebe-node
100755 → 100644
Empty file.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"@types/debug": "0.0.31",
"@types/got": "^9.6.9",
"@types/jest": "^27.5.2",
"@types/node": "^10.17.17",
"@types/node": "^10.17.60",
"@types/promise-retry": "^1.1.3",
"@types/stack-trace": "0.0.29",
"@types/uuid": "^3.4.4",
Expand Down
10 changes: 10 additions & 0 deletions src/lib/OAuthProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export interface OAuthProviderConfig {
audience: string
clientId: string
clientSecret: string
/** Custom TLS certificate for OAuth */
customRootCert?: Buffer
/** Cache token in memory and on filesystem? */
cacheOnDisk?: boolean
/** Override default token cache directory */
Expand All @@ -36,6 +38,7 @@ export class OAuthProvider {
public url: string
public clientId: string
public clientSecret: string
public customRootCert?: Buffer
public useFileCache: boolean
public tokenCache = {}
private failed = false
Expand All @@ -49,6 +52,8 @@ export class OAuthProvider {
cacheDir,
clientId,
clientSecret,
/** Custom TLS certificate for OAuth */
customRootCert,
/** Cache token in memory and on filesystem? */
cacheOnDisk,
}: {
Expand All @@ -57,12 +62,14 @@ export class OAuthProvider {
cacheDir?: string
clientId: string
clientSecret: string
customRootCert?: Buffer
cacheOnDisk: boolean
}) {
this.url = url
this.audience = audience
this.clientId = clientId
this.clientSecret = clientSecret
this.customRootCert = customRootCert
this.useFileCache = cacheOnDisk
this.cacheDir = cacheDir || OAuthProvider.getTokenCacheDirFromEnv()

Expand Down Expand Up @@ -130,6 +137,9 @@ export class OAuthProvider {
'content-type': 'application/x-www-form-urlencoded',
'user-agent': this.userAgentString,
},
https: {
certificateAuthority: this.customRootCert
}
})
.then(res => {
return this.safeJSONParse(res.body).then(token => {
Expand Down
1 change: 1 addition & 0 deletions src/zb/ZBClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export class ZBClient extends TypedEmitter<typeof ConnectionStatusEvent> {
this.oAuth = this.options.oAuth
? new OAuthProvider(
this.options.oAuth as OAuthProviderConfig & {
customRootCert: Buffer
cacheDir: string
cacheOnDisk: boolean
}
Expand Down

0 comments on commit 9938457

Please sign in to comment.