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

Skip protect_from_forgery for #authenticate #451

Merged
merged 1 commit into from
Feb 22, 2017

Conversation

martinpovolny
Copy link
Member

@martinpovolny martinpovolny commented Feb 22, 2017

It makes no sense to check the token for the authenticate action.
It only makes the product seem broken when you return to a login screen
after the session has expired.

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1417661
EUWE BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1427172

@mzazrivec, @himdel: review?

@himdel
Copy link
Contributor

himdel commented Feb 22, 2017

I'd also remove = csrf_meta_tag from app/views/layouts/login.html.haml

It makes no sense to check the token for the authenticate action.
It only makes the product seem broken when you return to a login screen
after the session has expired.
@martinpovolny
Copy link
Member Author

@himdel : done

@himdel
Copy link
Contributor

himdel commented Feb 22, 2017

Verified in UI 👍 :

  1. log out (or refresh the login screen)
  2. echo flush_all | nc localhost 11211 (or restart memcached)
  3. click the Login button (without reloading the form first)

Before: broken
Now: logs in just fine

@miq-bot
Copy link
Member

miq-bot commented Feb 22, 2017

Checked commit martinpovolny@0f99d9a with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 0 offenses detected
Everything looks good. 🏆

@himdel himdel added this to the Sprint 55 Ending Feb 27, 2017 milestone Feb 22, 2017
@himdel himdel self-assigned this Feb 22, 2017
@himdel himdel merged commit c845be8 into ManageIQ:master Feb 22, 2017
@himdel
Copy link
Contributor

himdel commented Feb 24, 2017

@martinpovolny turns out I had a BZ for this problem (https://bugzilla.redhat.com/show_bug.cgi?id=1417661) .. added to description, and adding euwe/yes.

@himdel himdel added euwe/yes and removed euwe/no labels Feb 24, 2017
@martinpovolny
Copy link
Member Author

Should have been mine! I could have claimed I worked on it the whole Monday while I would actually delete some code!

@himdel
Copy link
Contributor

himdel commented Feb 24, 2017

Feel free to take it :D

@@ -16,7 +16,7 @@ class ApplicationController < ActionController::Base
# This secret is reset to a value found in the miq_databases table in
# MiqWebServerWorkerMixin.configure_secret_token for rails server, UI, and
# web service worker processes.
protect_from_forgery :secret => SecureRandom.hex(64), :except => :csp_report, :with => :exception
protect_from_forgery :secret => SecureRandom.hex(64), :except => [:authenticate, :csp_report], :with => :exception
Copy link
Member

Choose a reason for hiding this comment

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

/cc @jvlcek if this is related to the ext-auth issue you were troubleshooting, we might need to add exceptions for the other two methods in dashboard_controller, namely :external_authenticate (for ext-auth), and :kerberos_authenticate (SSO). Thanks.

Copy link
Member

@abellotti abellotti Mar 3, 2017

Choose a reason for hiding this comment

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

/cc @jvlcek we should be ok with SAML, but probably need to test that too. Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

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

@abellotti : what about :saml_login, :initiate_saml_login ?

@martinpovolny
Copy link
Member Author

martinpovolny commented Mar 6, 2017

EUWE: should go together with: #595

@simaishi
Copy link
Contributor

simaishi commented Mar 9, 2017

Euwe backport (to manageiq repo) details:

$ git log -1commit e5460da9a192af8b6eecab435091796faac460a8
Author: Martin Hradil <himdel@seznam.cz>
Date:   Wed Feb 22 15:34:25 2017 +0000

    Merge pull request #451 from martinpovolny/skip_pff_for_authenticate
    
    Skip protect_from_forgery for #authenticate
    (cherry picked from commit c845be80c5b6800b4824cf3ef89ea937a32dc1bb)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1427172

NickLaMuro added a commit to ManageIQ/manageiq-performance that referenced this pull request May 18, 2017
In ManageIQ/manageiq-ui-classic#451 we removed
the CSRF token in our login page, which breaks the requestor code when
trying to log in and the csrf token is no where to be found.

By using the block form, we can return the proper match in the CSRF
token regexp if it exists, but still return `nil` if it does not, which
will be fine it the header is blank (which is why a `.to_s` was added to
the caller).

Instead of removing the csrf token lookup on login, we are keeping this
in place to allow this to be used on older versions of the MIQ
application, otherwise we would need conditional logic for different
versions of the application.
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.

5 participants