-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Make it possible to turn off OpenID Connect configuration retrieval, or enable removal of an added authentication handler #61168
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
Comments
The solution that was suggested to me at some point was to use |
@ChrisKlug, what's wrong with building the service provider first, then modifying the schemes after? Have you taken a look at |
Is the call to the OIDC configuration endpoint not done during creation? Or is that called at a later point? I thought it was done during creation, in which case it is too late to remove it after creation... |
Also, it would feel better to do it before creation to me. As I really don't want it in there. But that is a subjective thing I guess |
It happens on the first request. @ChrisKlug, is there a reason you could add something to your app's configuration (e.g., create some kind of testing configuration), and then set up the app's auth differently depending on the current configuration? |
If it's on first request, I should be able to remove the handler in my test after the creation of the app using the I currently have a conditional that only adds the OIDC handler if the environment isn't my integration testing. But I'd rather not have code that is test specific deployed to test... |
To progress further on this issue, I think we'll need example code that does not work that you would like to have work. |
I created a little sample of what I am talking about. It's available here: https://github.com/ChrisKlug/asp-net-core-auth-example It is quite easily fixed using I get that it might not be a high priority issue, but I still think it would make it easier to discover if it was available in |
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
During integration testing with the WebApplicationFactory, I tend replace the existing authentication method (OIDC) with basic auth to simplify testing. However, in the current model, it seems more or less impossible to remove an authentication handler once it has been added. This is a problem with the OIDC handler, as it makes a request to retrieve the OIDC configuration on startup, which causes problems during testing.
Describe the solution you'd like
It would be great to be able to remove an authentication handler after it has been added, e.g. in the ConfigureTestServices method. Alternatively, it could be solved by being able to configure the OIDC handler to not get the configuration automatically.
Additional context
Right now, my solution is to set a specific environment name in the tests, and have code that checks the environment name before adding the OIDC handler. However, this feels less than optimal, as I don't want to have test specific code in my production application.
The text was updated successfully, but these errors were encountered: