-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Statsbeat update function resource provider * WIP * Adding AAD handling * Build * Change statbeat tests * Test * Test
- Loading branch information
1 parent
aa1af92
commit 52d3937
Showing
14 changed files
with
882 additions
and
565 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 |
---|---|---|
@@ -1,19 +1,32 @@ | ||
{ | ||
"version": "0.1.0", | ||
"version": "2.0.0", | ||
"command": "npm", | ||
"isShellCommand": true, | ||
"showOutput": "silent", | ||
"suppressTaskName": true, | ||
"tasks": [ | ||
{ | ||
"taskName": "test", | ||
"args": ["run", "test"], | ||
"isTestCommand": true | ||
"label": "test", | ||
"type": "shell", | ||
"args": [ | ||
"run", | ||
"test" | ||
], | ||
"problemMatcher": [], | ||
"group": { | ||
"_id": "test", | ||
"isDefault": false | ||
} | ||
}, | ||
{ | ||
"taskName": "build", | ||
"args": ["run", "build"], | ||
"isTestCommand": false | ||
"label": "build", | ||
"type": "shell", | ||
"args": [ | ||
"run", | ||
"build" | ||
], | ||
"problemMatcher": [], | ||
"group": { | ||
"_id": "build", | ||
"isDefault": 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,35 @@ | ||
import http = require("http"); | ||
import https = require("https"); | ||
import azureCore = require("@azure/core-http"); | ||
|
||
const applicationInsightsResource = "https://monitor.azure.com//.default"; | ||
|
||
|
||
class AuthorizationHandler { | ||
|
||
private _azureTokenPolicy: azureCore.RequestPolicy; | ||
|
||
constructor(credential: azureCore.TokenCredential) { | ||
let scopes: string[] = [applicationInsightsResource]; | ||
let emptyPolicy: azureCore.RequestPolicy = { | ||
sendRequest(httpRequest: azureCore.WebResourceLike): Promise<azureCore.HttpOperationResponse> { | ||
return null; | ||
} | ||
}; | ||
this._azureTokenPolicy = azureCore.bearerTokenAuthenticationPolicy(credential, scopes).create(emptyPolicy, new azureCore.RequestPolicyOptions()); | ||
} | ||
|
||
/** | ||
* Applies the Bearer token to the request through the Authorization header. | ||
*/ | ||
public async addAuthorizationHeader(requestOptions: http.RequestOptions | https.RequestOptions): Promise<void> { | ||
let authHeaderName = azureCore.Constants.HeaderConstants.AUTHORIZATION; | ||
let webResource = new azureCore.WebResource("https://"); | ||
this | ||
await this._azureTokenPolicy.sendRequest(webResource); | ||
requestOptions.headers[authHeaderName] = webResource.headers.get(authHeaderName); | ||
} | ||
|
||
} | ||
|
||
export = AuthorizationHandler; |
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
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
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
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
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
Oops, something went wrong.