-
Notifications
You must be signed in to change notification settings - Fork 127
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
Use AAD Token for Authentication #362
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,33 @@ | |||
<!-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this for?
@@ -0,0 +1,9 @@ | |||
# Microsoft Open Source Code of Conduct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this for?
@@ -0,0 +1,45 @@ | |||
## Purpose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this for?
samples/acquire-token/.gitignore
Outdated
@@ -0,0 +1,349 @@ | |||
## Ignore Visual Studio temporary files, build results, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this for?
|
||
### Pre-requisites | ||
|
||
1. Open PowerShell (On Windows, press `Windows-R` and type `PowerShell` in the search window) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this only worked on Windows? What about other platforms?
@@ -0,0 +1,76 @@ | |||
# Contributing to [project-title] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this for?
src/directLine.ts
Outdated
@@ -558,9 +564,12 @@ export class DirectLine implements IBotConnection { | |||
} else { | |||
return this.startConversation().do(conversation => { | |||
this.conversationId = conversation.conversationId; | |||
this.token = this.secret || conversation.token; | |||
// Don't invoke acquireToken(), coulf fetch anew AAD token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/coulf/could
src/directLine.ts
Outdated
@@ -664,7 +675,7 @@ export class DirectLine implements IBotConnection { | |||
} | |||
|
|||
private refreshTokenLoop() { | |||
this.tokenRefreshSubscription = Observable.interval(intervalRefreshToken, this.services.scheduler) | |||
this.tokenRefreshSubscription = Observable.interval(3000, this.services.scheduler) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the change here?
@@ -558,9 +564,12 @@ export class DirectLine implements IBotConnection { | |||
} else { | |||
return this.startConversation().do(conversation => { | |||
this.conversationId = conversation.conversationId; | |||
this.token = this.secret || conversation.token; | |||
// Don't invoke acquireToken(), coulf fetch anew AAD token | |||
this.token = (this.acquireToken ? this.token : this.secret) || conversation.token; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we setting the secret as the token ever? This isn't a practice we should follow, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that doesn't look good. However, ABS API expects either a token or secret in the Authentication header. Maybe we should use a variable name that suits both.
this.secret = options.secret; | ||
this.token = options.secret || options.token; | ||
this.token = this.acquireToken ? this.acquireToken() : options.secret || options.token; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned about the async nature of this function. What if the caller needs to do some HTTP call or database operation? I'm not sure this will work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The client calls webchat after fetching the token atleast once. The WebSite code logic keeps refreshing the token. Yes, that code is async. Sample is in this doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code doesn't look to be async, is what I mean. Can you write a test that exercises this to demonstrate the behavior you mention?
A new policy, DisableLocalAuth, was added to Azure Bot Service to enable bot resource owners to enforce bots in particular subscriptions to explicitly use AAD token instead of secret.
This PR is to update DirectLine client to be able to support using AAD token.
Follow this doc if you would like to test the feature.