coherence
coherence copied to clipboard
Feature Request - Swap/replace Server Credential Store
Want the ability to timeout sessions server side. I've add a Coherence.DbStore protocol impl that uses Redis for storage and TTL but the credentials are still stored and first accessed from the Coherence.CredentialStore.Server. How can I bypass this behavior? I want the primary credential store to be the Redis store or allow TTL within the Coherence.CredentialStore.Server. Technically I could keep shutting down the GenServer to clear its state and force a reload from the Redis cache but this is hack-ish. Thoughts?
You have a number of choices. You could implement you own Session plug and replace the calls to Coherence.Authentication.Session in ur router. Alternatively, Coherence.Authentication.Session takes a :store option that defaults to store = Keyword.get(opts, :store, Coherence.CredentialStore.Session)
So you could implement ur own CredentialStore by cloning and modifying Coherence.CredentialStore.Session.
The first option is what I wanted to do but a hardcoded case statement in deps/coherence/lib/coherence/plugs/authorization/utils.ex in the function get_credential_store/0 breaks when one tries to configure the :auth_module to something custom in the config. Ultimately, and very unfortunately, for this and other reasons/needs I was forced to fork coherence.
@spec get_credential_store() :: module
def get_credential_store do
case Config.auth_module do
Coherence.Authentication.Session ->
Coherence.CredentialStore.Session
Coherence.Authentication.Basic ->
Coherence.CredentialStore.Server
end
end
For more clarification, lib/coherence/supervisor.ex calls Coherence.Authentication.Utils. get_credential_store/0 when setting up the supervising tree before the config is loaded. This makes creating a custom version of the Coherence.Authentication.Session plug difficult.
I have done some significant changes to the controller design. One of those changes is allowing customization of the get_credential_store. The work is on a branch right now. I've upgraded my current active project over to the new design and working through regression testing. When I'm happy, I'll merge the changes into master and then ultimately release 0.6.0.
I should be merging the extendible-controllers branch to master soon. I want to soak it a little longer on my personal project.