Enable / disable functionalities for users on Ms Teams custom App - microsoft-teams

I'm planning to build a custom application for Ms Teams and I wanted the app to have an 'Administration' context, reserved for some users, with charts and records management that the rest of the users wouldn't be able to see. Is there a way to accomplish this?
Is it possible to hide tabs depending on a user profile? Is there another way to accomplish this on teams?
Tks

Inside your tab you can do whatever you want - it's just a custom web app/page. The only "restriction" aside from a normal web app, is that it must implement the Teams javascript library - see here for more. However, once you've implemented that library, you can get the Teams context, which includes the user's Azure AD Id and also UPN, and you could use one or both of those to do a lookup against your database, determine the user's role, and show/hide UI elements accordingly.
However, I think you might be asking about whether the entire Tab -itself- (i.e. even the tab item inside the Teams client) can be hidden from other users. To do this, an option is to use a "private channel", just for the relevant users, and pin the tab inside there only.

Related

Microsoft teams user detection

I am showing a wordpress website in iframe inside Microsoft teams Tabs. is there any way to detect the loggedIn user in my website?
If you are able to wrap your website inside a Teams app (which you can do for example very easily using App Studio, then you could surface your website as a "Tab" app. Doing this means you can reference the Teams JS library in your code, which will enable you to get a context object. You can get a lot of user information from that.
Be aware though that this context is not really 'trusted' data (it's just inserted via Javascript), so it could be spoofed into your page by a malicious actor. If that's a problem, you should look to implement Tab SSO in your app, which will give you a proper JWT token that you can validate.

MS Teams custom tab app changes Session.SessionID between requests

I'm making a custom tab app of MS Teams with ASP.NET, however, the tab doesn't seem to pass a same cookie between requests on MS Teams. So the ASP.NET app behind the tab generates a new Session.SessionID on every request.
I've checked the following question, and tried some settings according to that page, but nothing helped me. Actually my web site works nicely if I navigate it via Chrome or Edge.
ASP.NET: Session.SessionID changes between requests
How do I get a same cookie between requests on MS Teams?
I've not tested this specifically so haven't seen it, but basically the broad idea of session is to have to uniquely "remember" a user, and then restore State for them from a location (e.g. database). From your question, it seems like the out of box "Session" object is giving trouble, but at any rate you should probably avoid using it because it won't "remember" the user even across devices.
However, Teams provides you a way to achieve the same thing yourself quite easily. Remember that the Teams 'Context' object provides a userObjectId property that is unique and valid for the same user on all sessions on all devices (it's actually their Azure Active Directory id). You can simply store whatever you want in your own database, key'ed by this id, and request it on page load. It's also possible to get this from the querystring for a static (personal) tab if you want to handle the behaviour server-side (e.g. C#).

Add cart functionality to API or to Client?

I am creating an e-commerce API using the Django Rest Framework. The API will handle the following areas:
Databases
User Registration
Permissions
Orders/Payments
There's still one area in which I'm not quite sure how to implement in my project. It's the cart functionality. Would it be better to implement it on the client-side (ex: React/Ember) or on the server-side (i.e. API)?
One scenario that confused me is if the user is logged in in different platforms (ex: Website and mobile app). I want the user to have the same cart on mulitple platforms.
In that particular use case, if you want cart persistence then it must be backend. The reason for this is one being able to have a single source of truth. The phone app and the web app cannot talk to each other unless they have some sort of "common ground" between them.
That's where the API comes in. It will allow both ends to speak to each other by having the API as the single source of truth. See my terrible diagram for a visual.

Deeplink from bot to tab in Microsoft Teams

I am currently working on a bot specifically targeting Teams. Search feature in this bot returns around 200-500 results. Even though i have integrated refines to narrow down search results, i still have to show around 50-100 records under a refined label. I am trying to avoid showing 100+ records as Carousel or list view in bot. so, I thought of integrating tab with bot and share a deeplink to tab where user can see complete search result in a data table (jquery).
I am unable to figure out two things on this approach and need help.
Tab content might be hosted in a different domain and needs authorization. How do I pass authorization info to Content url without asking user to login?
How do i pass custom parameters while creating a deep link to tab and read custom data in a tab? For example, userID, accessToken.
Note: I am using AzureADV1 token with Adal.Net for Bot authentication, and storing token cache in a persistent storage.
I appreciate any help on this.
You can include a "context" parameter in your static tab deeplink, similar to the configurable tab deeplink. If you include a "subEntityId" property in this context, you can get the value inside your static tab by calling getContext(). Then you can render a filtered results based on this sub-entity id.

Use Application Insights to view all REST API requests per user

We are developing a WebApi2 application. Users can use the REST API using their specific API key. I am investigating how to setup Application Insights to be able to see the usage of the REST API endpoints per user.
I have been experimenting with using telemetryclient.TrackPageview(endpoint-ID) and telemetryclient.TrackEvent(endpoint-ID), but I am not sure if this is the right way to go. And how should I pass the user-ID (API-key) in the tracking call? As telemetryclient.Context.User.Id? Or using properties or some other way? I would like to be able to use the user-ID to aggregate/segment the pageviews/events that were registered for that particular user. Any ideas are welcome!
I'd suggest using the built in properties, like context.user.id whenever possible, and then custom properties after that.
Currently in the portal, from the search view you can then find an item for any user, then use the "related items" to view "all telemetry for this user" to see all of the items.
Then can use the App Analytics portal to do queries (click the "analytics" button toolbar in the overview blade for your resource azure portal to go to the AA site for that resource), and that service lets you write much richer queries.
in those queries, it's easiest to group/filter on the "built in" properties, for custom properties you have to write a little bit more complicated queries to parse the values out of custom code.

Resources