Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Remove callerId in Auth flow as callerId shouldn't be transferred ove…
Browse files Browse the repository at this point in the history
…r the wire (#2291)

* remove callerId setting and verification

* update comment
  • Loading branch information
lzc850612 committed Sep 5, 2019
1 parent b85077d commit 9122102
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ public override async Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext
{
var requestPath = $"/activities/{activity.Id}";
var request = StreamingRequest.CreatePost(requestPath);

// set callerId to empty so it's not sent over the wire
activity.CallerId = null;

request.SetBody(activity);

_botTelemetryClient.TrackTrace($"Sending activity. ReplyToId: {activity.ReplyToId}", Severity.Information, null);
Expand Down Expand Up @@ -173,6 +177,10 @@ public override async Task<ResourceResponse> UpdateActivityAsync(ITurnContext tu
{
var requestPath = $"/activities/{activity.Id}";
var request = StreamingRequest.CreatePut(requestPath);

// set callerId to empty so it's not sent over the wire
activity.CallerId = null;

request.SetBody(activity);

var response = default(ResourceResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,8 @@ internal SkillWebSocketRequestHandler(ClaimsIdentity claimsIdentity, IBotTelemet

var appIdClaimName = AuthHelpers.GetAppIdClaimName(_claimsIdentity);

// verify if caller id is the same as the appid in the claims
var appIdClaim = _claimsIdentity.Claims.FirstOrDefault(c => c.Type == appIdClaimName)?.Value;
if (!activity.CallerId.Equals(appIdClaim))
{
response.StatusCode = (int)HttpStatusCode.Forbidden;
return response;
}
// retrieve the appid and use it to populate callerId on the activity
activity.CallerId = _claimsIdentity.Claims.FirstOrDefault(c => c.Type == appIdClaimName)?.Value;

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ public async Task<Activity> ForwardToSkillAsync(SkillManifest skillManifest, ISe

await _streamingTransportClient.ConnectAsync(headers);

// populate call id for auth purpose
activity.CallerId = serviceClientCredentials.MicrosoftAppId;

// set recipient to the skill
var recipientId = activity.Recipient.Id;
activity.Recipient.Id = skillManifest.MSAappId;
Expand Down

0 comments on commit 9122102

Please sign in to comment.