coherence icon indicating copy to clipboard operation
coherence copied to clipboard

Feature Request - Swap/replace Server Credential Store

Open jdobrzanski opened this issue 7 years ago • 5 comments

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?

jdobrzanski avatar May 31 '18 16:05 jdobrzanski

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.

smpallen99 avatar Aug 27 '18 20:08 smpallen99

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

jdobrzanski avatar Sep 12 '18 21:09 jdobrzanski

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.

jdobrzanski avatar Sep 12 '18 21:09 jdobrzanski

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.

smpallen99 avatar Sep 12 '18 23:09 smpallen99

I should be merging the extendible-controllers branch to master soon. I want to soak it a little longer on my personal project.

smpallen99 avatar Sep 30 '18 15:09 smpallen99