Looking at this example/test to dynamically add authentication schemes at runtime:
If the endpoint is invoked twice, it will result in an InvalidOperationException:
https://github.com/aspnet/HttpAbstractions/blob/dev/src/Microsoft.AspNetCore.Authentication.Core/AuthenticationSchemeProvider.cs#L121
Instead perhaps this method should be bool TryAddScheme(AuthenticationScheme scheme) so users don't have to wrap it in a try-catch.
Also it appears that the underlying _map should be a ConcurrentDictionary?
While we're looking at this API why is AddScheme and RemoveScheme synchronous but GetSchemeAsync asynchronous?
This is a good suggestion but the best way to fix it would be a breaking change, so we will consider this in the 3.0 milestone. For now we recommend using a workaround, such as trying to catch the exception.
Closing because it seems that implementors of the current interface could add their own interface with this new method, down-cast, and call it where needed.
Re-opening based on offline discussion:
Extra small. It would be one new overload of this method that doesn鈥檛 throw:
https://github.com/aspnet/HttpAbstractions/blob/bc7092a32b1943c7f17439e419d3f66cd94ce9bd/src/Microsoft.AspNetCore.Authentication.Core/AuthenticationSchemeProvider.cs#L136-L156
https://github.com/aspnet/HttpAbstractions/blob/bc7092a32b1943c7f17439e419d3f66cd94ce9bd/src/Microsoft.AspNetCore.Authentication.Abstractions/IAuthenticationSchemeProvider.cs#L72
We might want to wait for C# 8 default interface implementations though (later in 3.0).
We have default interface members so we believe this is non-breaking now.
Issues with dim still, moving to preview 8
Glad to see this happening :)
Contingency plan if we can't get DIM working (having some issues) is to punt to 3.1.
We're going to punt on DIM changes due to the limitations (VB support, crossgen issues). Let's move TryAddScheme out to 3.1.
crossgen dim works now in master, still doesn't work in release/3.1, so the fix looks good for 5.0 at least