-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
System publisher + SendEvent overloads (#19290)
* System publisher * PR FB * fix * SendEvent overloads
- Loading branch information
1 parent
0f7ee4f
commit a35fc04
Showing
13 changed files
with
445 additions
and
45 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
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
36 changes: 36 additions & 0 deletions
36
sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridKeyCredentialPolicy.cs
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,36 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using Azure.Core; | ||
using Azure.Core.Pipeline; | ||
|
||
namespace Azure.Messaging.EventGrid | ||
{ | ||
internal class EventGridKeyCredentialPolicy : HttpPipelineSynchronousPolicy | ||
{ | ||
private readonly string _name; | ||
private readonly AzureKeyCredential _credential; | ||
public const string SystemPublisherKey = "AzureSystemPublisher"; | ||
|
||
public EventGridKeyCredentialPolicy(AzureKeyCredential credential, string name) | ||
{ | ||
Argument.AssertNotNull(credential, nameof(credential)); | ||
Argument.AssertNotNullOrEmpty(name, nameof(name)); | ||
_credential = credential; | ||
_name = name; | ||
} | ||
|
||
public override void OnSendingRequest(HttpMessage message) | ||
{ | ||
base.OnSendingRequest(message); | ||
|
||
// AzureSystemPublisher is the key that internal partners will use | ||
// when authenticating with a certificate. So we don't need to include the key | ||
// in the request in this case. | ||
if (_credential.Key != SystemPublisherKey) | ||
{ | ||
message.Request.Headers.SetValue(_name, _credential.Key); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.