You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Host with multiple transports having different auth types #328
I need to create a Host that has multiple transports having different types of authentication.
My case:
Transport at port 50000 using secure websocket with OAuth authentication (for public clients) - security
Transport at port 50001 using RawSocket transport using ticket authentication (for local clients) - speed
I tried using code from WampAuthenticationHost but I ended up with endless internal dependency chain (I gave up after copying more than dozen classes).
I just need to have 2 different RegisterTransport methods, one which uses CreateAuthenticationBinding (this one uses WampAuthenticationBinaryBinding, WampAuthenticationBinaryBinding and WampAuthenticationBinding which are all internal and have other internal dependencies) and one which does not.
I also tried to use implementation of WampHost and edit that but that's even worse, almost everything is internal.
Is there a simple way to do this? Or is it at least possible to make most of those things public?
It seems to me like the problem is that you have a single IWampSessionAuthenticatorFactory so apparently you can't use two authentication methods?
But IWampSessionAuthenticatorFactory actually receives as an argument of the type WampPendingClientDetails so in theory we can just add the details about the underlying transport there and then you can choose your authenticator factory based on that?
Oh I didn't know it's sent in the arguments like that. That's very convenient. I actually have two separatate IWampSessionAuthenticatorFactorys so I created one Master factory which has a dictionary to switch the factory based on transport.
Is there some list where all the transport strings are listed?
Yeah, I'll fix that. Maybe the WampPendingClientDetails class should also
include the transport itself for the case where you have two instances of a
transport of the same type with different authorization methods.
Elad
I was thinking about it and in my opinion it's a hacky solution.
Ideally we should be able to just attach IWampSessionAuthenticatorFactory to a binding just like it's done in WampAuthenticationHost and that would solve all the issues.
In that case I would be able to not only have different authentication methods for multiple instances of the same transport, but even specify different authenticators for each binding on the same transport.
// Allows to map different bindings to different authentication methodspublicvoidRegisterTransport(IWampTransporttransport,IDictonary<IWampBinding,IWampSessionAuthenticatorFactory>bindingToAuthenticationFactory);
this will break api and also won't allow WampAuthenticationHost to implement IWampHost. Another option is just to add a new class instead of WampAuthenticationHost that has this functionality. I'll have to do some refactoring tricks but this is doable.
I also checked and authentication for crossbario is also defined per transport so we should probably support this.
I just pushed a commit with this feature. Can you try it out? The version is 21.0.0-develop-33 from GitHub and the new class is called WampMultiAuthenticationHost.
Hi Elad,
sorry for answering so late. I tried this (using 21.0.0-develop-34) and it seems to work without any issues (I will do more testing in the following weeks).
Great! I plan to release a new version of WampSharp at some point containing these changes and also the changes of #330, but it will take me some time unfortunately.
Activity
[-]Host with multiple transports[/-][+]Host with multiple transports having different auth types[/+]darkl commentedon Dec 9, 2020
It seems to me like the problem is that you have a single
IWampSessionAuthenticatorFactoryso apparently you can't use two authentication methods?But
IWampSessionAuthenticatorFactoryactually receives as an argument of the typeWampPendingClientDetailsso in theory we can just add the details about the underlying transport there and then you can choose your authenticator factory based on that?Elad
esso23 commentedon Dec 10, 2020
Oh I didn't know it's sent in the arguments like that. That's very convenient. I actually have two separatate
IWampSessionAuthenticatorFactorys so I created one Master factory which has a dictionary to switch the factory based on transport.Is there some list where all the transport strings are listed?
darkl commentedon Dec 10, 2020
Can you attach here your master factory code please?
For future reference and for understanding what you exactly did.
Thanks
Elad
esso23 commentedon Dec 10, 2020
Well it does not work since the
TransportDetailsobject is null.darkl commentedon Dec 10, 2020
esso23 commentedon Dec 10, 2020
I was thinking about it and in my opinion it's a hacky solution.
Ideally we should be able to just attach
IWampSessionAuthenticatorFactoryto a binding just like it's done inWampAuthenticationHostand that would solve all the issues.In that case I would be able to not only have different authentication methods for multiple instances of the same transport, but even specify different authenticators for each binding on the same transport.
darkl commentedon Dec 11, 2020
We'll have to change some api.
If we remove the original overload:
this will break api and also won't allow
WampAuthenticationHostto implementIWampHost. Another option is just to add a new class instead ofWampAuthenticationHostthat has this functionality. I'll have to do some refactoring tricks but this is doable.I also checked and authentication for
crossbariois also defined per transport so we should probably support this.darkl commentedon Jun 6, 2021
Hi Esso,
I just pushed a commit with this feature. Can you try it out? The version is
21.0.0-develop-33from GitHub and the new class is calledWampMultiAuthenticationHost.Usage:
Thanks
Elad
esso23 commentedon Sep 29, 2021
Hi Elad,
sorry for answering so late. I tried this (using
21.0.0-develop-34) and it seems to work without any issues (I will do more testing in the following weeks).I propose adding another overload:
Since it's likely going to be the most common use-case to add the same auth factory to all the bindings on the given transport.
esso23 commentedon Oct 25, 2021
I did some tests in production environment with this and found no issues.
darkl commentedon Oct 25, 2021
Great! I plan to release a new version of WampSharp at some point containing these changes and also the changes of #330, but it will take me some time unfortunately.
esso23 commentedon Feb 7, 2022
Hi @darkl,
any ETA on when we can expect this to be merged to master?
Thanks,
Esso
darkl commentedon Feb 7, 2022
Hi Esso,
I'm currently very busy. I'll have more time after March 15th.
Elad
esso23 commentedon Feb 8, 2022
Alright, we'll be patiently waiting then :)
darkl commentedon May 3, 2022
Version 22.5.1 is now available on NuGet!