-
February 25th, 2021, 04:16 AM
#1
Access Token Info from Metadata Adapter in DataAdapter?
Hello,
I am currently working on a Metadata and DataAdapter for my project, but am running into a slight problem.
When a user authenticates with LS, it is hitting NotifyUser in my Metadata Adapter, where I am validating their token. All good so far.
However, in our DataAdapter, the way that our event subscription works is that I need to pass in a UserId in order to create a subscription. This UserId is available in the token itself.
Is there a way for the Metadata Adapter to pass information to the DataAdapter for use? Or is there a better way to do this?
Thanks,
Tanner
-
February 25th, 2021, 09:52 AM
#2
Hi Tanner,
The original design of the Metadata and Data Adapter interfaces provides that any matters regarding authentication, authorization and QoS are addressed to the Metadata Adapter while the Data Adapter deals exclusively with application data.
And that is why information about the client session (ie. the user) is provided to the Metadata methods but not to the Data methods.
In particular case of subscription request if you need the user's information to authorize the request or not or to tune its characteristics depending the user, the right methods to do this are: notifyNewTables, getAllowedMaxItemFrequency, isModeAllowed,getAllowedBufferSize.
And not the subscribe method of Data Adapter.
That said, if you actually need user information also in the subscribe method a possible solution is to leverage the getItems method of the Metadata interface.
That means that all the clients subscribe to the same Item name but in the getItems method your custom implementation will return a decorated name with user information; something like 'itemName_userId' or 'itemName_userToken'.
So the subscribe Method of the Data Adapter will receive the Item name decorated and can retrieve the user information.
Please let me know if that makes sense for you.
Regards,
Giuseppe
-
March 4th, 2021, 08:59 PM
#3
Thank you for the clarifications on this. As such, we have decided to refactor, and remove our dependency on the UserId in this case.
Thanks,
Tanner
-
March 15th, 2021, 09:47 PM
#4
Hi Giuseppe,
Is it true that if I modify the itemName in getItems that it will effect the subscription itself?
For example, it turns out we do need some user information for our scenario. As such, I have an http client that is subscribing to 'itemName'. I am catching this subscription with getItems, and updating it to be 'itemName_userId'. However, now when I post updates to 'itemName' the client no longer receives the data. Is this because LS thinks the client is actually subscribed to 'itemName_userId' instead of just 'itemName'?
Thanks,
Tanner
-
March 16th, 2021, 09:15 AM
#5
Hi Tanner,
I can confirm that in a similar case, the Data Adapter should use the 'itemName_userId' name to push updates.
However, regardless of what happens in the Metadata, the Data Adapter must always refer to the name of the Item received in the subscribe call.
Regards,
Giuseppe
Similar Threads
-
By Alessandro in forum Adapter SDKs
Replies: 4
Last Post: October 24th, 2011, 09:33 AM
-
By h2c357 in forum Client SDKs
Replies: 1
Last Post: September 8th, 2011, 08:55 AM
-
By msgiribabu in forum Adapter SDKs
Replies: 4
Last Post: February 3rd, 2011, 10:33 AM
-
By oxid in forum Adapter SDKs
Replies: 4
Last Post: February 5th, 2010, 03:12 PM
-
By stephenlam in forum Adapter SDKs
Replies: 4
Last Post: December 12th, 2008, 10:52 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
All times are GMT +1. The time now is 07:17 PM.
Bookmarks