Skip to content

Commit

Permalink
Support connection strings (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwatson484 authored Apr 20, 2023
1 parent 2ff51d8 commit 66057da
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/Yelp/detect-secrets
rev: v0.13.1
rev: v1.4.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
91 changes: 64 additions & 27 deletions .secrets.baseline
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
{
"exclude": {
"files": "package-lock.json|^.secrets.baseline$",
"lines": null
},
"generated_at": "2021-08-12T13:00:16Z",
"version": "1.4.0",
"plugins_used": [
{
"name": "ArtifactoryDetector"
},
{
"name": "AWSKeyDetector"
},
{
"name": "ArtifactoryDetector"
"name": "AzureStorageKeyDetector"
},
{
"base64_limit": 4.5,
"name": "Base64HighEntropyString"
"name": "Base64HighEntropyString",
"limit": 4.5
},
{
"name": "BasicAuthDetector"
Expand All @@ -22,8 +21,14 @@
"name": "CloudantDetector"
},
{
"hex_limit": 3,
"name": "HexHighEntropyString"
"name": "DiscordBotTokenDetector"
},
{
"name": "GitHubTokenDetector"
},
{
"name": "HexHighEntropyString",
"limit": 3.0
},
{
"name": "IbmCloudIamDetector"
Expand All @@ -35,41 +40,73 @@
"name": "JwtTokenDetector"
},
{
"keyword_exclude": null,
"name": "KeywordDetector"
"name": "KeywordDetector",
"keyword_exclude": ""
},
{
"name": "MailchimpDetector"
},
{
"name": "NpmDetector"
},
{
"name": "PrivateKeyDetector"
},
{
"name": "SendGridDetector"
},
{
"name": "SlackDetector"
},
{
"name": "SoftlayerDetector"
},
{
"name": "SquareOAuthDetector"
},
{
"name": "StripeDetector"
},
{
"name": "TwilioKeyDetector"
}
],
"results": {
"README.md": [
{
"hashed_secret": "29fcd7da9dc4cf68637e6efc7b29da7493ff1524",
"is_verified": false,
"line_number": 50,
"type": "Secret Keyword"
}
]
},
"version": "0.13.1",
"word_list": {
"file": null,
"hash": null
}
"filters_used": [
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
},
{
"path": "detect_secrets.filters.heuristic.is_indirect_reference"
},
{
"path": "detect_secrets.filters.heuristic.is_likely_id_string"
},
{
"path": "detect_secrets.filters.heuristic.is_lock_file"
},
{
"path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string"
},
{
"path": "detect_secrets.filters.heuristic.is_potential_uuid"
},
{
"path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
},
{
"path": "detect_secrets.filters.heuristic.is_sequential_string"
},
{
"path": "detect_secrets.filters.heuristic.is_swagger_file"
},
{
"path": "detect_secrets.filters.heuristic.is_templated_secret"
}
],
"results": {},
"generated_at": "2023-04-20T08:32:31Z"
}
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ npm install --save ffc-messaging

`host` - Azure Service Bus namespace, for example, `myservicebus.servicebus.windows.net`

`useCredentialChain` - Boolean value for whether to authenticate connection with using Azure's credential chain. For example, set this to true if you wish to use [AAD Pod Identity](https://github.com/Azure/aad-pod-identity). If `false`, then `username` and `password` are required.
`useCredentialChain` - Boolean value for whether to authenticate connection with using Azure's credential chain. For example, set this to true if you wish to use [AAD Pod Identity](https://github.com/Azure/aad-pod-identity). If `false`, then `username` and `password` or `connectionString` are required.

`username` - Azure Service Bus Shared Access Key name for authentication. Not required if `useCredentialChain` is `true`.
`connectionString` - Azure Service Bus connection string. If provided, `username` and `password` are ignored.

`password` - Azure Service Bus Shared Access Key value for authentication. Not required if `useCredentialChain` is `true`.
`username` - Azure Service Bus Shared Access Key name for authentication. Not required if `useCredentialChain` is `true` or `connectionString` is provided.

`password` - Azure Service Bus Shared Access Key value for authentication. Not required if `useCredentialChain` is `true` or `connectionString` is provided.

`type` - Azure Service Bus entity to connect to, allows `queue`, `sessionQueue`, `topic` or `subscription`.

Expand Down
2 changes: 2 additions & 0 deletions app/messaging/admin-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class AdminClient {
if (this.config.useCredentialChain) {
const credentials = this.getCredentials()
this.sbClient = new ServiceBusAdministrationClient(this.config.host, credentials)
} else if (this.config.connectionString) {
this.sbClient = new ServiceBusAdministrationClient(this.config.connectionString)
} else {
this.sbClient = new ServiceBusAdministrationClient(`Endpoint=sb://${this.config.host}/;SharedAccessKeyName=${this.config.username};SharedAccessKey=${this.config.password}`)
}
Expand Down
2 changes: 2 additions & 0 deletions app/messaging/message-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class MessageBase {
if (this.config.useCredentialChain) {
const credentials = this.getCredentials()
this.sbClient = new ServiceBusClient(this.config.host, credentials)
} else if (this.config.connectionString) {
this.sbClient = new ServiceBusClient(this.config.connectionString)
} else {
this.sbClient = new ServiceBusClient(`Endpoint=sb://${this.config.host}/;SharedAccessKeyName=${this.config.username};SharedAccessKey=${this.config.password}`)
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffc-messaging",
"version": "2.6.5",
"version": "2.7.0",
"description": "Messaging npm module for FFC services",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit 66057da

Please sign in to comment.