June 22, 2020, 2:01am
I’m wanting to implement a licensing model that will shutoff services if they are not licensed. We are planning to release a code each 3 months, licensing for 6 months ahead.
Is there a centralized location in the servicestack service model where I can wire in this mechanism ? I had considered the authorization code as that is centralized but open to suggestions.
June 22, 2020, 3:45am
Typically you’d do license verification once on Startup, I.e. throw an Exception if invalid.
If you wanted to do the license verification per request you could do it in a PreRequestFilter.
June 22, 2020, 4:24am
The trouble with doing it on startup is that it would require a restart of the services should the license code be changed. I was thinking to have a static class that loads once per day from DB.
I will investigate the PreRequestFilter option, thanks.
June 22, 2020, 4:34am
PreRequestFilters basically allow you to run custom logic on every ServiceStack request, note: if performance is important I’d also maintain a static counter and only perform the license check every ~1000 requests.
June 22, 2020, 4:40am
Nice idea, yes looks ideal thanks.