Skip to content

Update omniauthable tests for OmniAuth 2.0#5331

Merged
carlosantoniodasilva merged 1 commit into
heartcombo:ca-omniauth-2from
jkowens:ca-omniauth-2
Jan 19, 2021
Merged

Update omniauthable tests for OmniAuth 2.0#5331
carlosantoniodasilva merged 1 commit into
heartcombo:ca-omniauth-2from
jkowens:ca-omniauth-2

Conversation

@jkowens
Copy link
Copy Markdown
Contributor

@jkowens jkowens commented Jan 17, 2021

Hope this helps with #5327. Updated omniauthable links to use method: :post and revised corresponding tests. I opened a PR with omniauth-openid (ruby-openid/omniauth-openid#44), but for now I updated the Gemfile to pull it from a branch on my fork.

@carlosantoniodasilva
Copy link
Copy Markdown
Member

Thanks @jkowens, I'll take a look and report back.

@carlosantoniodasilva carlosantoniodasilva self-assigned this Jan 17, 2021
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), method: :post %><br />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@BobbyMcWho mind if I ask for some clarification here?

In the CVE wiki it mentions using link_to with method=post or a button_to should be enough, but in the release notes for OmniAuth v2 you mention specifically:

If you are using hyperlinks or buttons styled to redirect to your login route, you should update these to be a submit input or a submit type button wrapped in a form.

I'm assuming you meant those as being GET requests, that should be updated to using POST instead? (since Rails button_to or link_to + method=post use forms under the hood?)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We want to make sure that whatever way we send the POST, we're including a CSRF token to be validated in the request_validation_phase. I suggested wrapping inputs with a rails form helper since by default those automatically generate a per-form token that can be validated by Rails' RequestForgeryProtection class

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A link_to with method=post will submit a form with an authenticity token. I assume it is a per-form token, but not sure 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right, thanks for the clarification 👍. I believe link_to + method=post or a button_to should be fine then, like @jkowens mentioned they should also include the authenticity token by default in Rails. (whether they are per-form or not is controlled by the application via the individual form and/or global Rails config iirc.)

@carlosantoniodasilva
Copy link
Copy Markdown
Member

I'm merging this to my branch and will update the dependencies there now that omniauth-openid has been released as v2.0.1. Thanks again!

@carlosantoniodasilva carlosantoniodasilva merged commit 837baaf into heartcombo:ca-omniauth-2 Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants