semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

OpenAPI auth provider implementations

Open gitri-ms opened this issue 2 years ago • 1 comments

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:

gitri-ms avatar Apr 19 '23 22:04 gitri-ms

Please run dotnet format to fix formatting in: dotnet/src/SemanticKernel.Skills/Skills.OpenAPI/Authentication/BasicAuthenticationProvider.cs'.

shawncal avatar Apr 19 '23 22:04 shawncal