Raise an event notification to a specific client when a user is registered/created on Identity Server - identityserver4

I am creating an AdminUI for my users where I set all the permission. As part of the requirements, every time that a user logins on my IdentityServer I need to set some default permissions, but those are handle on my Admin application. Which is the best way to raise an event to let that application that a user was created on the IdentityServer?

The simplest is i think to create a simple WebApi in IdentityServer that returns the latest users and then let the other application poll this API every X seconds. In that way the system is cleanly decoupled. Perhaps expose the data as a a RSS XML document or a JSON list of items.
There is a built in eventing model in IdentityServer that you could use and push notifications to the Admin application. But push is a bit more complicated to get right, especially how to deal with all the failre/error cases.

I's suggest to add a custom event sink to process UserLoginSuccessEvent or any other event you need, here is list of all builtin events. Find their code here.
In the custom sink as suggested in the other answer you can call an API on admin app to inform it about changes.
Here is a sample for custom sink.

I think to keep two applications decoupled you better to setup a service-bus for simple implementation a sub/pub mechanism. when any user complete registration(or any other actions),then as mentioned in another answer handle the events and add message. admin UI should subscribed before to receive these messages with some information to create a user related data.

Related

How send notification into ms teams user from custom tab

I'm designing a custom team tab using React that calls third party API, I need after executing the API successfully, user gets notified . What is the best way to achieve this? I used Bot in my project, but not sure how can I call it from my custom tab class. I'm aware of the existence of proactive messaging, is it the only way to do it? If it is, a pointer on how to implement it to a custom tab would be appreciated.
If you're wanting to message the user 1-1 (like in the personal app), then proactive messaging is definitely what you need (inside a Team, there are other options), and considering you have the bot already in place that's perfect. The only thing you might be missing are the details required to send the actual proactive message (the best time to get them is when the bot is first installed by the user). In particular, you need ConversationId and ServiceUrl.
With regards the concept of Proactive Messaging, basically once the bot is installed, and you have the required values, you can -send- the message from any backend code at all. That can include, for example, custom tab's backend api. You need to identify the user, which you can do using the Teams Context (it's not the safest way but it's the easiest), and then look up the values in your own backend store (e.g. database or whatever) to get the ConversationId and ServiceUrl, then just message the user in your backend.

How to add multiple subscription in Azure Logic app Service bus topic trigger

As I am having a logic app where the trigger is service bus topic subscription. I want to add multiple subscription ("A", "B","C") for the given topic in my logic app service bus topic trigger . Whenever i select topic it only allows me to select single subscription. Is there any way to add multiple subscription from an array or static variables ? if yes then how to add conditions ? I tried using array, but i have to provide the index of the subscription.
I can use multi trigger logic app for all of the subscriptions to achieve what I am looking for, but is there any other way like using some wildcard characters ***** or / or something else which i am not familiar with .
The action supports selecting only one subscription as you have observed.
Multi Trigger Logic App is indeed one way to go about it but note that the designer doesn't support them, and you will be forced to edit only using the code view.
One alternative would be to split your logic app into two
one for your business logic that is triggered by a HTTP request
one (or more) that is triggered by the service bus subscription trigger and calls the first logic app
Another alternative is to leverage the Event Grid Integration in Service Bus, but note that this is currently applicable only for the Premium Tier.
In this approach, the logic app would trigger based on an event message from Event Grid with details of the subscription that has messages ready to process. You would then use the Get messages from a topic subscription action to fetch the messages to process.

Send updates to a user using Socket.io and nodejs

I'm building an app using MEAN Stack (something like Facebook). So a user can login to my app using different browsers and I want for example, if there user will add a new message to the MongoDB, I want to update his messages in the other sessions. The same of he will remove a massage. At the same time, there maybe logged in different users from different browsers and I want to notify the user with his update in the other sessions.
Does Socket.io supports such an option? And what is the best way to do it?
Thanks.
Yes socket.io do support that. Here is an example made by socket.io themselves: https://github.com/socketio/socket.io/tree/master/examples/chat
You should be looking for socket.on() which are the listeners for an event on the server side and look into socket.emit() which are the senders of the events. the .emit()could be added into an function which are triggered on a button click for example.
Depending on you needs, if you're going to send the message to every user using your app then you could use this above code. But if you only wants to send to a specific list of persons you should look into something called Rooms (http://socket.io/docs/rooms-and-namespaces/#rooms).
This does exactly what it sounds like, it emits the messages to the specific room where users have been added to when they connect to your application.

Listening to changes in sling's users and groups

I want to be notified of changes to users or groups in sling's userManager as they happen. For example, when a new group is created, I need to create a new node with the same name under /content. When a new user is created, I want to give them write-permissions for /content/foo. And similar tearDown steps when objects are deleted.
I tried registering a EventHandler (org.osgi.service.event.EventHandler), with event.topics set to "*" (all topics), but this captured only resource changes and not userManager changes because users and groups are synthetic resources (I think)
I tried using a org.apache.sling.api.request.SlingRequestListener, but the SlingRequestEvent did not come with any info that would help me distinguish the request (or I didn't know how). Also, I am not sure if this is can even be used for callbacks that need to be called AFTER the request is processed.
I have used Filters for a different issue and I tried applying them for this purpose too. But they have their limitations - My filter is called BEFORE the request, so it's not possible to know if the request will result in SUCCESS before deciding to take action.
Any suggestions on how to listen and respond to changes in sling's user and group models?
In https://issues.apache.org/jira/browse/SLING-977 Ian Boston suggests using a SlingPostProcessor service to be informed of calls to the user management's POST servlets.
I haven't tried it myself, and if you do it you might anyway miss changes that are done via Sling's user management APIs - but that might be good enough depending on your use case.
Apart from that I don't think there's currently a surefire way of being notified of such changes. To implement that in Sling we'd need to wrap the org.apache.jackrabbit.api.security.user.* objects (Group, User, UserManager) to send events when they're changed. Certainly doable but would require changes to that Sling bundle.

Best practice to authenticate an ashx request

I have a Silverlight application from which I have to call a ASHX file, something like this GetFile.ashx?orderId=4
The problem is that I want to allow this call to be made only through the application, and thus I thought of using some sort of authentication (sending the username+pass from silverlight) when calling the ashx file. I don't want to add them in the query string. Any other suggestions?
Thank you
The easy answer is to turn on ASP.Net authorization by whatever means are suitable for you.
If your users log in through an AuthenticationService in the Silverlight client, or through an ASP.Net page, you will be able to access the CurrentUser object from the HttpContext in your handler and from there do whatever checks you want.
The following link should get you started on finding more info if you need MSDN

Resources