Sage / omniauth-cognito-idp

OmniAuth Strategy for AWS Cognito in Ruby
Apache License 2.0
35 stars 13 forks source link

Rename strategy name to match devise omniauth patterns #13

Open jkintscher opened 7 months ago

jkintscher commented 7 months ago

Carbon copy of https://github.com/Sage/omniauth-cognito-idp/pull/12. This should really be fixed.


This PR aims to resolve an integration issue between your gem and OmniAuth 2 within the Devise ecosystem. The current problem arises from the strategy name not being properly normalized, resulting in conflicts that skip the middleware. Additionally, there is an issue with the on_auth_path? method from the OmniAuth strategy not matching under Devise configurations. Let's delve into these points in more detail for improved clarity and readability.

The specific line in the OmniAuth gem (https://github.com/omniauth/omniauth/blob/a86acdfd7639c9e4c4dc9968d36c1eae0e9141d7/lib/omniauth/strategy.rb#LL187C7-L187C56) expects to find the authentication path that matches the name "cognito-idp". However, the normalization methods used by Devise expect patterns from Rails routes to use underscores (_), resulting in callbacks and methods expecting "cognito_idp". Consequently, the strategy in the middleware gets ignored because it expects the correct name. To address this issue, the proposed solution involves renaming the strategy to match the expected methods from Devise's OmniAuth callbacks controller.