SimpleIdServer icon indicating copy to clipboard operation
SimpleIdServer copied to clipboard

Hangfire configuration and the recurring UserSessionJob

Open dpoulsen21 opened this issue 1 year ago • 4 comments

We are finally upgrading to v5.x. For context see prior issue: https://github.com/simpleidserver/SimpleIdServer/issues/725

First question:

I'm trying to upgrade to the 5.0.0 packages first. We aren't using back channel authentication, so Hangfire is not being pulled in. I can add the service manually, but then the UserSessionJob keeps firing every 10-15 seconds. I can kill the job, but I'd rather disable Hangfire altogether.

I feel like adding a flag to the following lines (or moving them to the IsBCEnabled section) in SimpleIdServer.IdServer's WebApplicationExtension.cs would make that possible:

var reccuringJobManager = webApplication.Services.GetRequiredService<IRecurringJobManager>(); // Occurs every 10 seconds. reccuringJobManager.AddOrUpdate<UserSessionJob>(nameof(UserSessionJob), j => webApplication.Services.GetRequiredService<UserSessionJob>().Execute(), "*/10 * * * * *");

If Hangfire is necessary regardless of whether or not back channel authentication is enabled, is there a way to configure it so we have some control over what background jobs are created, whether they are recurring or fire and forget, the time in between firing, etc.?

Second question/issue:

I tried to upgrade directly to the 5.2.0 packages (NuGet packages used: SimpleIdServer.IdServer and SimpleIdServer.IdServer.SqlServerMigrations), but I received the following dependency injection error:

5-0-2_Error

I feel like the DI should be handled in the package and not inside our application builder, but I could be wrong. I decided to start with v5.0.0, since that code doesn't include that AuthorizationCallbackRequestHandler class. Plan to upgrade incrementally after, but figured I might as well ask about that while I'm here.

dpoulsen21 avatar Jan 13 '25 16:01 dpoulsen21

Hello,

First question: Even if you are not using the Back-Channel Authentication method, the Hangfire library is still utilized by the UserSessionJob class to revoke user sessions across different clients by calling their respective BackChannelLogoutUri. This class is necessary to support the OpenID Connect Back-Channel Logout 1.0 specification (https://openid.net/specs/openid-connect-backchannel-1_0.html).

To view the configuration of the recurring job, you can access the Hangfire dashboard. To enable this feature, edit the Program.cs file and add the following instruction before UseSID:

app.UseHangfireDashboard();
app.UseSID()

Sample project : https://github.com/simpleidserver/SimpleIdServer/tree/Release503/samples/AddHangfireUi

Unfortunately, at the moment, it is not possible to edit the cron expressions of the different jobs. I have created a new ticket to support this feature: Ticket#831.

Second question :

Indeed, the configuration of the IDidFactoryResolver service should be moved to our application builder. I have created a new ticket to move this configuration to a more appropriate location: Ticket#832.

In the meantime, can you add the missing registration as follows?

services.AddDid()

KR,

SID

simpleidserver avatar Jan 14 '25 19:01 simpleidserver

Thank you for the reply. I will take a look at the dashboard. I'll need to reach out to our Cyber department to find out if that's something we can even deploy to Production. I can definitely add the registration in the meantime. Do you have an idea when the v5.0.3 packages might be available?

dpoulsen21 avatar Jan 15 '25 15:01 dpoulsen21

Hello,

The version 5.0.3 will be published by the end of the month! 🙂

Next month, we’ll release version 6.0.0, which introduces a new feature: a form builder.

This feature will allow you to customize the UI and workflow for authentication and registration.

KR SID

simpleidserver avatar Jan 16 '25 20:01 simpleidserver

@dpoulsen21 : The feature has been developed and is ready to be used in the 'release/6.0.0' branch. We provide a UI to manage the lifecycle of various Hangfire jobs

simpleidserver avatar Mar 07 '25 15:03 simpleidserver