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

Commit d72fc0d

Browse files
authored
Make whitelist optional (#2363)
1 parent b84d415 commit d72fc0d

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/Auth/Authenticator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public async Task<ClaimsIdentity> Authenticate(HttpRequest httpRequest, HttpResp
4646

4747
var appIdClaimName = AuthHelpers.GetAppIdClaimName(claimsIdentity);
4848
var appId = claimsIdentity.Claims.FirstOrDefault(c => c.Type == appIdClaimName)?.Value;
49-
if (_whitelistAuthenticationProvider.AppsWhitelist == null
50-
|| _whitelistAuthenticationProvider.AppsWhitelist.Count == 0
51-
|| !_whitelistAuthenticationProvider.AppsWhitelist.Contains(appId))
49+
if (_whitelistAuthenticationProvider.AppsWhitelist != null
50+
&& _whitelistAuthenticationProvider.AppsWhitelist.Count > 0
51+
&& !_whitelistAuthenticationProvider.AppsWhitelist.Contains(appId))
5252
{
5353
httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized;
5454
await httpResponse.WriteAsync("Skill could not allow access from calling bot.").ConfigureAwait(false);

templates/Skill-Template/csharp/Sample/SkillSample/WhiteListAuthProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public WhiteListAuthProvider(IConfiguration configuration)
2020
// the parent bot's microsoft app id to the list
2121
var section = configuration.GetSection($"skillAuthenticationWhitelist");
2222
var appsList = section.Get<string[]>();
23-
AppsWhitelist = new HashSet<string>(appsList);
23+
AppsWhitelist = appsList != null ? new HashSet<string>(appsList) : null;
2424
}
2525

2626
public HashSet<string> AppsWhitelist { get; }

templates/Skill-Template/csharp/Template/Skill/WhiteListAuthProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public WhiteListAuthProvider(IConfiguration configuration)
2020
// the parent bot's microsoft app id to the list
2121
var section = configuration.GetSection($"skillAuthenticationWhitelist");
2222
var appsList = section.Get<string[]>();
23-
AppsWhitelist = new HashSet<string>(appsList);
23+
AppsWhitelist = appsList != null ? new HashSet<string>(appsList) : null;
2424
}
2525

2626
public HashSet<string> AppsWhitelist { get; }

0 commit comments

Comments
 (0)