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

Allow Downstream API calls to be used outside of ASP.NET Core Hosting environment [Feature Request] #2371

Closed
MZOLN opened this issue Aug 8, 2023 · 0 comments · Fixed by #2374
Labels
enhancement New feature or request feature request

Comments

@MZOLN
Copy link

MZOLN commented Aug 8, 2023

Is your feature request related to a problem? Please describe.
When calling downstream api from a console application allowed schemes are not fetched properly. This is because IAuthenticationSchemeProvider is not registered and aspnet core ITokenAcquisitionHost is used by default.

Describe the solution you'd like
Ability to inject ITokenAcquisitionHost but I would ideally like idweb to not be dependent on asp.net core dlls, but anything to make it work would suffice.

Describe alternatives you've considered
Taking dependency on asp.net core myself and registering the type.

Additional context

@MZOLN MZOLN added enhancement New feature or request feature request labels Aug 8, 2023
jmprieur added a commit that referenced this issue Aug 10, 2023
In .NET 5+, we now use the DefaultTokenAcquisitionHost (the host for SDK apps) instead of the
Asp.NET core one, when the service collection was not initialized by ASP.NET Core (that is
the `IWebHostEnvironment` is not present in the collection.

If developers want the ASP.NET Core host, they would need to use the WebApplication.CreateBuilder().Services instead
of instanciating a simple service collection.
jmprieur added a commit that referenced this issue Aug 13, 2023
* Fix for #2371

# Features:
- In AspNET Core 3.1 and Net 5+, we now use the DefaultTokenAcquisitionHost (the host for SDK apps) instead of the
Asp.NET Core one, when the service collection was not initialized by ASP.NET Core (that is the `IWebHostEnvironment` is not present in the collection. If you want the ASP.NET Core host, you would need to use the WebApplication.CreateBuilder().Services instead
of instantiating a simple service collection.
- In Web APIs, GetAuthenticationResultForUserAsync tries to find the inbound token from user.Identity.BootstrapContext first (if not null), and then from the token acquisition host. This will help for non-asp.NET Core Azure functions for instance
- New PrincipalExtensionsForSecurityTokens.GetBootstrapToken method that extracts a Security token from the bootstrap context (+unit tests)

Co-authored-by: jennyf19 <jeferrie@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant