semantic-kernel
semantic-kernel copied to clipboard
OpenAPI auth provider implementations
Motivation and Context
This PR introduces a set of "authentication providers" that can be used with the OpenAPI skill to authenticate HTTP requests. Each of these providers implements the AuthenticateRequestAsyncCallback delegate, which is a parameter to the RestApiOperationRunner. The OpenAPI skill example is updated to demonstrate usage.
Description
Implements the following:
- BasicAuthenticationProvider - encodes the providedcredential string and applies it to the HTTP auth header using the "basic" scheme
- BearerAuthenticationProvider - applies the provided token to the HTTP auth header using the "bearer" scheme
- InteractiveMsalAuthenticationProvider - extends BearerAuthenticationProvider, uses MSAL to authenticate user and acquire bearer token
Contribution Checklist
- [x] The code builds clean without any errors or warnings
- [x] The PR follows SK Contribution Guidelines (https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
- [x] The code follows the .NET coding conventions (https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions) verified with
dotnet format - [ ] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
Please run dotnet format to fix formatting in: dotnet/src/SemanticKernel.Skills/Skills.OpenAPI/Authentication/BasicAuthenticationProvider.cs'.