>>>>> Steinar Bang <s...@dod.no>:

> Is it possible to have two SCR components share a karaf config value and
> have the other component pick up the changed config when one of the
> components changes the config value?

> I have a use case where I would like two different components, that
> otherwise have no knowledge of each others, share an integer value,

To provide a little more context.

The SCR components that should share a config value are a component that
exposes a shiro "realm" OSGi service[1] and a component that exposes an
OSGi service that provides the backend for a react.js admin UI for
creating and modifying users, roles and permissions[2].

They are both part of a karaf application that I made to work as a forms
auth service for nginx[3]

I am extending the shiro realm[4] in [1] to handle repeatedly failed
logins and lock the account when a limit is reached.

And it's that limit I would like to share between the admin backend[2]
and the realm[1].

Since both components talkt to the database the simplest way would be to
add that value to the database schema, but a table with a single value
felt... wrong... so I decided to explore the configuration approach.

Short story: if I can do it with config with a minimum of code (just
annotations) I'll do it with config. But if not I'll bite the bullet and
create a table with a single value in the database.

(and after sleeping on it I think I will try the database approach, in
that way I can just join the config value for limit for number of failed
logins in the select that checks for number of logins done so far... I
think I will do that...)


References:
 [1] 
<https://github.com/steinarb/authservice/blob/b3b03de37b618cd5a78dba6fc6719131754d4a98/authservice/authservice.web.security.dbrealm/src/main/java/no/priv/bang/authservice/web/security/dbrealm/AuthserviceDbRealm.java#L11>
 [2] 
<https://github.com/steinarb/authservice/blob/b3b03de37b618cd5a78dba6fc6719131754d4a98/authservice/authservice.users/src/main/java/no/priv/bang/authservice/users/UserManagementServiceProvider.java#L56>
 [3] 
<https://github.com/steinarb/authservice?tab=readme-ov-file#forms-based-nginx-login-and-pluggable-shiro-auth-in-karaf>
 [4] <https://shiro.apache.org/realm.html>

Reply via email to