Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SQL store option to token store #14947

Merged

Conversation

imtayadeway
Copy link
Contributor

@imtayadeway imtayadeway commented Apr 28, 2017

This does a couple of few things:

  1. Makes the token store honor the kind of session store that's been configured in the global settings
  2. Adds support for a SQL session store, if that's been configured
  3. Updates some existing tests to use both memory and sql to ensure good integration
  4. Updates the purger to respect the ttl of the token, not the updated_on value

This is kind of a naive implementation that might have some issues. The most glaring is perhaps that we purge the Sessions based on a global ttl, meaning that this won't respect the ttl that is configured in the API/elsewhere, and that may not be easy to change. Opening this as a WIP to aid discussion

@miq-bot add-label api, core, enhancement
@miq-bot assign @gtanzillo

Fixes #14882
Fixes https://www.pivotaltracker.com/story/show/130490379

/cc @martinpovolny

@miq-bot miq-bot added the wip label Apr 28, 2017
@imtayadeway imtayadeway force-pushed the api/add-sql-store-to-token-store branch 2 times, most recently from 693d1c1 to c2b4ad0 Compare May 3, 2017 17:24
@imtayadeway
Copy link
Contributor Author

@miq-bot rm-label wip

@miq-bot miq-bot changed the title [WIP] Add SQL store option to token store Add SQL store option to token store May 3, 2017
@miq-bot miq-bot removed the wip label May 3, 2017
@imtayadeway imtayadeway force-pushed the api/add-sql-store-to-token-store branch from c2b4ad0 to dee0684 Compare May 3, 2017 17:29
@imtayadeway
Copy link
Contributor Author

@gtanzillo @abellotti I've fleshed this out into something more workable. LMK what you think. Probably best reviewed ignoring whitespace.

There were quite a few opportunities to refactor along the way with this one but I resisted as it is already quite large. You may see some further duplication added (e.g. the knowledge of how we serialize/deserialize data in sessions) along the way....because this PR is already quite large I think it would be best if I tackled that in a follow up.

@imtayadeway imtayadeway force-pushed the api/add-sql-store-to-token-store branch from dee0684 to 752073b Compare May 3, 2017 23:06
@chrisarcand
Copy link
Member

Adds support for a SQL session store, if that's been configured

Unless I'm mistaken, isn't this what https://github.com/rails/activerecord-session_store does? Can't you utilize that instead?

@chrisarcand
Copy link
Member

(we already use it in the project, I mean)

@imtayadeway
Copy link
Contributor Author

@chrisarcand we do.....but that doesn't have an abstraction layer at the level we need. It just provides an adapter for action dispatch which interacts directly with the model. The token store code is coupled to this interface, which the other adapters provide, so I'm adding an adapter for that here.

Copy link
Member

@isimluk isimluk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@imtayadeway
Copy link
Contributor Author

@gtanzillo @abellotti any feedback on this? It's currently red only because brakeman doesn't like the Marshal.load - that's somewhat unavoidable but in theory harmless because we what goes into that marshalled data is controlled by us. So we could whitelist that - I can go ahead and do that if the approach outlined above is agreeable.

@imtayadeway imtayadeway force-pushed the api/add-sql-store-to-token-store branch from 752073b to 8715446 Compare May 30, 2017 20:48
@miq-bot
Copy link
Member

miq-bot commented May 30, 2017

Some comments on commits imtayadeway/manageiq@24422a3~...8715446

spec/requests/api/authentication_spec.rb

  • ⚠️ - 175 - Detected expect_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 216 - Detected expect_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.

@miq-bot
Copy link
Member

miq-bot commented May 30, 2017

Checked commits imtayadeway/manageiq@24422a3~...8715446 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
6 files checked, 4 offenses detected

app/models/session.rb

lib/token_store/sql_store.rb

spec/lib/token_store/sql_store_spec.rb

@imtayadeway imtayadeway reopened this May 30, 2017
@gtanzillo gtanzillo added this to the Sprint 62 Ending Jun 5, 2017 milestone May 30, 2017
@gtanzillo gtanzillo merged commit ffd8972 into ManageIQ:master May 30, 2017
@imtayadeway
Copy link
Contributor Author

@miq-bot add-label fine/yes

@simaishi
Copy link
Contributor

simaishi commented Jun 9, 2017

@imtayadeway Is there a BZ for this? Can you please create if it doesn't exist?

@imtayadeway
Copy link
Contributor Author

@simaishi here's the BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1459674 (hope I interpreted this correctly)

simaishi pushed a commit that referenced this pull request Jun 9, 2017
@simaishi
Copy link
Contributor

simaishi commented Jun 9, 2017

Fine backport details:

$ git log -1
commit 9503a9a3ac59fa77f3a2cf72e5a9fcc13735bfeb
Author: Gregg Tanzillo <gtanzill@redhat.com>
Date:   Tue May 30 18:09:58 2017 -0400

    Merge pull request #14947 from imtayadeway/api/add-sql-store-to-token-store
    
    Add SQL store option to token store
    (cherry picked from commit ffd89722751ebc3fb0498a24a288b90411eea2ac)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1460348

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants