-
Notifications
You must be signed in to change notification settings - Fork 9
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
/metadata and /spslo support? #4
Comments
It looks like the structure of the OmniAuth::Strategies::SAML#other_phase method changed with SLO support in omniauth/omniauth-saml@cd3fc43 to just match a path prefix so single logout and metadata might work now. Try updating the routes to include the metadata/SLO routes and pass the appropriate metadata/SLO options to |
Tried it and it doesn't seem to work. Returns |
Bummer :( Taking a quick look at
I'll have to give some thought on the best way to fix this. |
I think your best bet for a quick fix is to monkey patch OmniAuth::Strategies::SAML#other_phase to call setup_phase if the current_path matches an appropriate prefix and then call the original implementation. This will end up invoking setup_phase twice but I suspect that will be fine. If that causes issues, you can monkey patch that method to be a no-op if it's called more than once. I'm going to be offline for a little over a week but hopefully this will work. Good luck! |
Thanks for taking a stab at it. I'll post here if any progress is made. |
I've confirmed that a monkey patch like this does the trick: module OmniAuthSamlPatch
def on_auth_path?
super || on_other_phase_path?
end
def on_other_phase_path?
# TODO: Use appropriate path check
current_path.start_with?('/users/auth/saml')
end
def other_phase
setup_phase if on_other_phase_path?
super
end
end
OmniAuth::Strategies::SAML.prepend(OmniAuthSamlPatch) |
Here's a slightly more robust monkey patch to get this functionality: # This patches omn-auth-saml to ensure setup_phase is called at the beginning of other_phase
# (which is consistent with how it handles request_phase and callback_phase).
module OmniAuthSamlOtherPhaseSetupPatch
def on_auth_path?
# Override this to ensure initialization happens properly in OmniAuth::Strategies::SAML for "other"
# requests
current_path.start_with?(options.path_prefix)
end
def other_phase
# Override the other_phase method to call setup_phase before checking to see if the request
# is on an "other" request path. This ensures omniauth-multi-provider has setup the path
# prefix properly for the given identity provider. By default omniauth won't call setup_phase until
# after checking the path.
setup_phase
super
end
def setup_phase
# Make sure we only perform setup once since this method will be called twice during the other phase
unless @setup
super
@setup = true
end
end
end
OmniAuth::Strategies::SAML.prepend(OmniAuthSamlOtherPhaseSetupPatch) |
In my environment, |
@tboyko - What versions of omniauth and omniauth-saml are you using? How do you have omniauth configured? |
omniauth 1.4.2 I run the patch before |
We're using omniauth 1.8.1. It might be worth upgrading to see if that fixes the issue. |
When loading a page of the web application in question, On the third call, and right after OmniAuth logs Does this seem to be an implementation-specific issue? |
I'm not sure but we're not hitting it in the Salsify application. If you can give me access to a reproducible test case (or at least your omniauth configuration), I'd be happy to take a look. |
@jturkel your revised monkey patch doesn't appear to avoid calling # monkey patch to support metadata paths - hacked version of:
# https://github.com/salsify/omniauth-multi-provider/issues/4#issuecomment-366452170
#
# This patches omn-auth-saml to ensure setup_phase is called at the beginning of other_phase
# (which is consistent with how it handles request_phase and callback_phase).
module OmniAuthSamlOtherPhaseSetupPatch
def on_auth_path?
# Override this to ensure initialization happens properly in OmniAuth::Strategies::SAML for "other"
# requests
current_path.start_with?(options.path_prefix)
end
def on_other_path?
# Override this to ensure initialization happens properly in OmniAuth::Strategies::SAML for "other"
# requests
current_path.match(%r{/(?:metadata|spslo|slo)\z})
end
def other_phase
# Override the other_phase method to call setup_phase before checking to see if the request
# is on an "other" request path. This ensures omniauth-multi-provider has setup the path
# prefix properly for the given identity provider. By default omniauth won't call setup_phase until
# after checking the path.
setup_phase if on_auth_path? && on_other_path?
super
end
def setup_phase
# Make sure we only perform setup once since this method will be called twice during the other phase
unless @setup # TODO: always false due to the calling class being created anew each time?
super
@setup = true
end
end
end
OmniAuth::Strategies::SAML.prepend(OmniAuthSamlOtherPhaseSetupPatch) |
I've been looking into enabling OmniAuth::Strategies::SAML is not able to match request path correctly in https://github.com/omniauth/omniauth-saml/blob/master/lib/omniauth/strategies/saml.rb#L75 and thus never initiates signed SAML logout request. This is because OmniAuth::Strategy resolves the path to This is because OmniAuth::MultiProvider::Handler sets request_path to something OmniAuth does not understand. The solution would be to replace Method (see https://github.com/salsify/omniauth-multi-provider/blob/master/lib/omni_auth/multi_provider/handler.rb#L28) with the actual path https://github.com/salsify/omniauth-multi-provider/blob/master/lib/omni_auth/multi_provider/handler.rb#L57). While this seems pretty straightforward, omniauth-multi-provider is not specific to SAML and I am not sure how this change might affect other strategies. |
Hey @jturkel, thanks for all your work on this gem. Do you have any updates about implementing a more robust solution for the metadata and SLO paths in a future release, one based perhaps on @shelldweller's proposal above? |
Update: (edited) the metadata itself, when accessed after implementing the monkey patch above, shows an incorrect assertion consumer service (callback) url, ending |
Updated the full monkey patch with @joshIsCoding suggestion (for ease of copy paste for future me/gem users) # monkey patch to support metadata paths - hacked version of:
# https://github.com/salsify/omniauth-multi-provider/issues/4#issuecomment-366452170
#
# This patches omn-auth-saml to ensure setup_phase is called at the beginning of other_phase
# (which is consistent with how it handles request_phase and callback_phase).
module OmniAuthSamlOtherPhaseSetupPatch
def on_auth_path?
# Override this to ensure initialization happens properly in OmniAuth::Strategies::SAML for "other"
# requests
current_path.start_with?(options.path_prefix)
end
def on_other_path?
# Override this to ensure initialization happens properly in OmniAuth::Strategies::SAML for "other"
# requests
current_path.match(%r{/(?:metadata|spslo|slo)\z})
end
def other_phase
# Override the other_phase method to call setup_phase before checking to see if the request
# is on an "other" request path. This ensures omniauth-multi-provider has setup the path
# prefix properly for the given identity provider. By default omniauth won't call setup_phase until
# after checking the path.
@callback_path = nil
setup_phase if on_auth_path? && on_other_path?
super
end
def setup_phase
# Make sure we only perform setup once since this method will be called twice during the other phase
unless @setup # TODO: always false due to the calling class being created anew each time?
super
@setup = true
end
end
end
OmniAuth::Strategies::SAML.prepend(OmniAuthSamlOtherPhaseSetupPatch) |
I have this patch but I get the following response after signing out instead of actually redirecting and I can't figure out why. The page simply says "Redirecting to ...". The IdP is signed out though. |
I found that I had to set the |
Hello! I have implemented SLO for multi provider app using OmniAuthSamlOtherPhaseSetupPatch before middleware config. The problem is that after creating SLO logout request I get redirect loop. There is invalid signature error (idp certificate is added) in the system log. Am I missing something here? Thanks in advance for the help! |
I have the same issue. @jclusso if you have a working example please share. |
Does this gem break omniauth-saml functionality, such as the
/metadata
feature?At a minimum it seems the route examples provided in the readme need to be more lenient, but it looks like there are issues beyond that. For instance, the
request_path
used inon_path?
references a different (and perhaps default when not using omniauth-multi-provider) path and so the logic of omniauth-saml doesn't evaluate correctly here: https://github.com/omniauth/omniauth-saml/blob/946801990c58f0ccba07b91ecea07641af7e5b08/lib/omniauth/strategies/saml.rb#L105Any guidance is appreciated.
The text was updated successfully, but these errors were encountered: