Microsoft.Agents.Authentication.Msal
0.1.26
Prefix Reserved
dotnet add package Microsoft.Agents.Authentication.Msal --version 0.1.26
NuGet\Install-Package Microsoft.Agents.Authentication.Msal -Version 0.1.26
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.Agents.Authentication.Msal" Version="0.1.26" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.Agents.Authentication.Msal --version 0.1.26
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Microsoft.Agents.Authentication.Msal, 0.1.26"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Microsoft.Agents.Authentication.Msal as a Cake Addin #addin nuget:?package=Microsoft.Agents.Authentication.Msal&version=0.1.26 // Install Microsoft.Agents.Authentication.Msal as a Cake Tool #tool nuget:?package=Microsoft.Agents.Authentication.Msal&version=0.1.26
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Microsoft.Agents.Authentication.Msal
Provides the MSAL implementation to implement authentication for Agents
How to use it
public static void AddBotAspNetAuthentication(this IServiceCollection services, IConfiguration configuration, string botConnectionConfig = "Connections:BotServiceConnection:Settings")
{
var tokenValidationSection = configuration.GetSection("TokenValidation");
var validTokenIssuers = tokenValidationSection.GetSection("ValidIssuers").Get<List<string>>();
// If ValidIssuers is empty, default for ABS Public Cloud
if (validTokenIssuers == null || validTokenIssuers.Count == 0)
{
validTokenIssuers =
[
"https://api.botframework.com",
"https://sts.windows.net/d6d49420-f39b-4df7-a1dc-d59a935871db/",
"https://login.microsoftonline.com/d6d49420-f39b-4df7-a1dc-d59a935871db/v2.0",
"https://sts.windows.net/f8cdef31-a31e-4b4a-93e4-5f571e91255a/",
"https://login.microsoftonline.com/f8cdef31-a31e-4b4a-93e4-5f571e91255a/v2.0",
];
var tenantId = configuration[$"{botConnectionConfig}:TenantId"];
if (!string.IsNullOrEmpty(tenantId))
{
validTokenIssuers.Add(string.Format(CultureInfo.InvariantCulture, AuthenticationConstants.ValidTokenIssuerUrlTemplateV1, tenantId));
validTokenIssuers.Add(string.Format(CultureInfo.InvariantCulture, AuthenticationConstants.ValidTokenIssuerUrlTemplateV2, tenantId));
}
}
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.SaveToken = true;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidateAudience = true,
ValidateLifetime = true,
ClockSkew = TimeSpan.FromMinutes(5),
ValidIssuers = validTokenIssuers,
ValidAudience = configuration[$"{botConnectionConfig}:ClientId"],
RequireSignedTokens = true,
SignatureValidator = (token, parameters) => new JwtSecurityToken(token),
};
});
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Agents.Authentication (>= 0.1.26)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
- Microsoft.Identity.Client (>= 4.64.1)
- Microsoft.IdentityModel.Abstractions (>= 8.1.2)
- Microsoft.IdentityModel.LoggingExtensions (>= 8.1.2)
- System.Configuration.ConfigurationManager (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.1.26 | 63 | 11/18/2024 |