Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: Add support for custom authentication provider for OpenAPI #2283

Merged
merged 7 commits into from
Aug 11, 2023

Conversation

mojanas
Copy link
Contributor

@mojanas mojanas commented Aug 2, 2023

Motivation and Context

  1. Why is this change required? This change adds support for other authentication methods defined in OpenAPI specs.
  2. What problem does it solve? Some APIs use other authentication methods that define a value in a custom header. As an example, many PlayFab APIs are authenticated using secret key or user token in a custom header. The current authentication providers are not sufficient for onboarding these APIs as skills.
  3. What scenario does it contribute to? This change will enable APIs using custom header authentication to onboard their OpenAPI specs as skills in Semantic Kernel.
  4. If it fixes an open issue, please link to the issue here.

Description

This change adds a new OpenAPI authentication provider that enables specifying a custom header to supply the authentication key or value.

Contribution Checklist

@shawncal shawncal added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels Aug 2, 2023
@shawncal shawncal changed the title Add support for custom authentication provider for OpenAPI .Net: Add support for custom authentication provider for OpenAPI Aug 2, 2023
@mojanas mojanas marked this pull request as ready for review August 2, 2023 15:45
@mojanas mojanas requested a review from a team as a code owner August 2, 2023 15:45
@glahaye
Copy link
Contributor

glahaye commented Aug 2, 2023

@gitri-ms This is related to work you did in the past. Adding you as a reviewer.

@shawncal
Copy link
Member

shawncal commented Aug 3, 2023

I believe one can already do this by passing in an HttpClient with the DefaultHeaders populated, which is our recommended approach for similar situations across SK. (We're trying to reduce the number of routes we provide to do things that are already doable via common dotnet patterns, or can be added as extensions, to reduce the surface and complexity of the SDK)

@SergeyMenshykh can you please confirm, and take a look at the PR and the needs it addresses?

@SergeyMenshykh
Copy link
Member

I would propose taking this authentication provider in, as it's very simple. At the same time, it's very flexible to cover all authentication needs for OpenAPI functionality, so no more providers will be needed.

@shawncal shawncal added this pull request to the merge queue Aug 11, 2023
Merged via the queue into microsoft:main with commit 334b22a Aug 11, 2023
15 checks passed
@mojanas mojanas deleted the openapi/custom-auth branch August 18, 2023 15:09
SOE-YoungS pushed a commit to SOE-YoungS/semantic-kernel that referenced this pull request Nov 1, 2023
…rosoft#2283)

### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

1. **Why is this change required?** This change adds support for other
authentication methods defined in OpenAPI specs.
2. **What problem does it solve?** Some APIs use other authentication
methods that define a value in a custom header. As an example, [many
PlayFab
APIs](https://learn.microsoft.com/en-us/gaming/playfab/api-references/#security)
are authenticated using secret key or user token in a custom header. The
current authentication providers are not sufficient for onboarding these
APIs as skills.
3. **What scenario does it contribute to?** This change will enable APIs
using custom header authentication to onboard their OpenAPI specs as
skills in Semantic Kernel.
  4. **If it fixes an open issue, please link to the issue here.**

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

This change adds a new OpenAPI authentication provider that enables
specifying a custom header to supply the authentication key or value.

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄

---------

Co-authored-by: Gil LaHaye <gillahaye@microsoft.com>
Co-authored-by: Shawn Callegari <36091529+shawncal@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

5 participants