Skip to content

feat(WebAuthenticationProvider): Allow providing IWebAuthenticationBrokerProvider via DI parameters - #2890

Open
DevTKSS wants to merge 2 commits into
unoplatform:mainfrom
DevTKSS:feat-WebAuthProvider
Open

DevTKSS wants to merge 2 commits into
unoplatform:mainfrom
DevTKSS:feat-WebAuthProvider

Conversation

@DevTKSS

@DevTKSS DevTKSS commented Aug 10, 2025 •

Copy link
Copy Markdown
Contributor

GitHub Issue (If applicable): closes #

PR Type

What kind of change does this PR introduce?

What is the current behavior?

  • We could register that Interface in DI conditionally, as the WebAuthenticationProvider is no public type or any of the Web Auth parts, its not using an Interface then a class itself.
  • While Uno does have this Broker and Interface definition it would be good to have a chance to use this feature 👍
  • Missing oAuth Code Challenge callback function

What is the new behavior?

  • If we would register an Implementation (e.g. via ApiExtension) of this Interface, the DI constructor would resolve IWebAuthenticationBroker as not null

  • Optional Argument so existing Code will not break, while Users of Web Auth could provide ApiExtensions of this to be used.

  • Applyed Conditional #if !WINDOWS because of otherwhise this Interface gets linted with CS0246. see issue on the unoplatform/uno repo for more information about this:

  • Should enable also to use any future Implementations of this Interface to be used like I am trying to acomplish right now just with HttpListener or maybe Refit for enabling https instead of just http (tpc Listener seems to not be able to use https?):

  • added a comment where the oAuth code challenge function should be made availeble as minimalistic approach/or hopefully solution (?) for adding custom action for this without having to copy and re-write the whole WebAuthentication classes and so on, which uno has already!

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
    • Not possible for me to build it locally, as its having that unknown numeric targetframework error
  • Docs have been added/updated which fit documentation template. (for bug fixes / features)
  • Unit Tests and/or UI Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Wasm UI Tests are not showing unexpected any differences. Validate PR Screenshots Compare Test Run results.
  • Contains NO breaking changes
  • Associated with an issue (GitHub or internal)

Other information

if this callback could be added, this could be a usable workaround until a full oauth feature would be added for:

Internal Issue (If applicable):

Copilot AI review requested due to automatic review settings August 10, 2025 22:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the WebAuthenticationProvider to support dependency injection of custom IWebAuthenticationBrokerProvider implementations. This allows developers to provide their own authentication broker implementations instead of being limited to the default WebAuthenticationBroker.

  • Adds optional IWebAuthenticationBrokerProvider parameter to constructor via dependency injection
  • Implements conditional logic to use custom broker when provided, falling back to default behavior
  • Adds documentation comment about OAuth Authorization Code Flow with PKCE challenge support

@DevTKSS

DevTKSS commented Aug 20, 2025 •

Copy link
Copy Markdown
Contributor Author

removed Todo for callback would be able to work with if this PR and the

would get merged, so we could provide the WebAuthBrokerProvider Implementation and the OtherTokenKeys Dictionary from appsettings.json would get even considered. at this time, thats not used at all and the accessor Level is not allowing also that we would get the WebConfiguration via IOptions, as mentioned on the other PR.

@kazo0 would you see the option that this could get reviewed? then I could just put an Implementation in the DI container on non Windows targets like Desktop and could go on with my Projects. e.g. my approach would be HttpListener with OpenBrowser like we seen on

but without the tcpListener using approach because my API I need does require other then what this Server setup can do because its not allowing to tell that I would like to have localhost and not 127.0.0.0 for example or to use https and so on. to match the interfaces it does introduce is absolutly horror and no quick doing, so I would rather just match the interface of this here... together with IOptions I would expect it to work... otherwise I can only drop webauth extension until Uno has a implementation working for desktop and creat a IAuthenticationService which would be not very clean against this easy doing here...

@DevTKSS

DevTKSS commented Sep 7, 2025 •

Copy link
Copy Markdown
Contributor Author

looking up the ApiExtensibilityAttribute and its usage in the WebAuthenticationBrokerProvider, I think the error

could eventually be caused by the Assembly lookup of that attribute but not the solution or usings?

e.g. if we consider the extension of the Provider is defined in a seperate project the Assembly might not be equal to the one where its meant to be used, but I think that should be optional, so maybe this needs to add a nullable and default to null IWebAuthenticationBrokerProvider in the ctor of the definition of the uno.ui implementation of it too ?
Maybe someone of the team could validate this and give some feedback?

@DevTKSS

DevTKSS commented Dec 3, 2025

Copy link
Copy Markdown
Contributor Author

Hey @kazo0 ,
if you find time, could you tell if this might be an option to enable? The Attribute Provided one does because of the ApiExtensionAttribute not allow us to have ctor arguments which is horrible for keeping clean code and SoC modern best practices in mind and enabling this, we could even surround this current limitation you know of with the WebAuthProvider and potentially also the current OIDC Implementation because it's using this, failing for our Desktop target.

For example, if this here would be possible and our Service would "just" be required to meet the interface expectations, so the Uno provider here could do its task as-is, this would simplify soo much 😅 and by using the if (IWebAuthenticationBrokerProvider is null) we should not even need to change something in the other parts in my opinion 🤔

Given case, we would allow this, the Consumer of this enhancement would simply need to:

  1. register its Implementation before this is called in the DI Container (Singleton/Transient/Scoped should all be possible)
  2. The ServiceProvider should then get this implementation automatically, to build our WebAuthenticationProvider here
  3. If now our Provider is called by .AddWeb( Delegates, this ctor parameter should be delivered, not beeing null and et voila, we have WebAuthentication available again! 🚀

How does that sound to you? 😃

…okerProvider via DI parameters

Optional so existing Code will not break
Conditional "if" added for Windows, where compiler gives CS0246 otherwhise. see issue 21237 on the unoplatform/uno repo for more information about this
@DevTKSS
DevTKSS force-pushed the feat-WebAuthProvider branch from 88b95ca to f2c69fa Compare December 3, 2025 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants