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

sp_request_initiation_protocol #2073

Conversation

ioigoume
Copy link
Contributor

@ioigoume ioigoume commented Apr 29, 2024

Addresses issue #174

@ioigoume ioigoume marked this pull request as draft April 29, 2024 13:34
modules/saml/src/Controller/ServiceProvider.php Outdated Show resolved Hide resolved
modules/saml/src/Controller/ServiceProvider.php Outdated Show resolved Hide resolved
modules/saml/src/Controller/ServiceProvider.php Outdated Show resolved Hide resolved
modules/saml/src/Controller/ServiceProvider.php Outdated Show resolved Hide resolved
modules/saml/src/Controller/ServiceProvider.php Outdated Show resolved Hide resolved
tests/modules/saml/src/Controller/ServiceProviderTest.php Outdated Show resolved Hide resolved
Copy link
Contributor

@pradtke pradtke left a comment

Choose a reason for hiding this comment

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

@ioigoume It is looking pretty good. I'll test it out in our of our environments.

tests/modules/saml/src/Controller/ServiceProviderTest.php Outdated Show resolved Hide resolved
tests/modules/saml/src/Controller/ServiceProviderTest.php Outdated Show resolved Hide resolved
@pradtke
Copy link
Contributor

pradtke commented May 3, 2024

I ran some tests in our dev environment and things behaved like I expected. Thank you @ioigoume

@ioigoume ioigoume marked this pull request as ready for review May 3, 2024 07:03
@ioigoume ioigoume force-pushed the sp_request_initiation_protocol branch from 3111e54 to 56a57a3 Compare May 3, 2024 07:05
@ioigoume
Copy link
Contributor Author

ioigoume commented May 3, 2024

Hi @tvdijen,
this pull request is ready for review. We introduced a new method, the loginHandler, in order to facilitate testing.

Thank you,
Ioannis Igoumenos

@tvdijen tvdijen force-pushed the simplesamlphp-2.3 branch 3 times, most recently from 440f4ab to edcc508 Compare May 4, 2024 23:45
@ioigoume ioigoume force-pushed the sp_request_initiation_protocol branch from 56a57a3 to 4f272ef Compare May 8, 2024 09:05
Copy link

codecov bot commented May 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 44.86%. Comparing base (37bb64f) to head (1517e08).

Additional details and impacted files
@@                   Coverage Diff                   @@
##             simplesamlphp-2.3    #2073      +/-   ##
=======================================================
+ Coverage                44.71%   44.86%   +0.14%     
- Complexity                3849     3865      +16     
=======================================================
  Files                      162      162              
  Lines                    12876    12902      +26     
=======================================================
+ Hits                      5758     5788      +30     
+ Misses                    7118     7114       -4     

@ioigoume ioigoume requested a review from monkeyiq May 15, 2024 16:24
@monkeyiq
Copy link
Contributor

I should probably also include a link here to the previous PR #2046

@monkeyiq
Copy link
Contributor

One thing I notice is that in general this will accept RelayState and turn it into ReturnTo if there is no existing returnTo. If that is ok for a general case in SAML then all is well, otherwise we are introducing a potential change.

From my reading it seems RelayState might be a deep pointer the SP wants mirrored back from the IdP. Does the RelayState have potential other semantics with SP Request Initiation Protocol interactions?

It may also make sense to hint to the reader that they might like to investigate the trusted.url.domains configuration option to best validate the target. I imagine sites will already have trusted domains set up but mentioning it in the docs seems like a good idea to follow section 2.5 of the spec.

@ioigoume ioigoume force-pushed the sp_request_initiation_protocol branch from 6f1438c to b51c532 Compare May 16, 2024 08:15
@ioigoume ioigoume requested a review from tvdijen May 16, 2024 08:16
@ioigoume
Copy link
Contributor Author

@monkeyiq

One thing I notice is that in general this will accept RelayState and turn it into ReturnTo if there is no existing returnTo. If that is ok for a general case in SAML then all is well, otherwise we are introducing a potential change.

According to the SAML specification

Some bindings define a "RelayState" mechanism for preserving and conveying state information. When such a mechanism is used in conveying a request message as the initial step of a SAML protocol, it places requirements on the selection and use of the binding subsequently used to convey the response. Namely, if a SAML request message is accompanied by RelayState data, then the SAML responder MUST return its SAML protocol response using a binding that also supports a RelayState mechanism, and it MUST place the exact RelayState data it received with the request into the corresponding RelayState parameter in the response.

and

Sometimes a binding-specific field called RelayState is used to coordinate messages and actions of IdPs and SPs, for example, to allow an IdP (with which SSO was initiated) to indicate the URL of a desired resource when communicating with an SP."

Based on above descriptions from the specification, the RelayState is just a pointer that the Service Provider will use to find out the final TARGET or ReturnTo URL.

From my reading it seems RelayState might be a deep pointer the SP wants mirrored back from the IdP. Does the RelayState have potential other semantics with SP Request Initiation Protocol interactions?

According to the protocol if the target is omitted then the SP MUST use a default value, which it unilaterally determines. In other words, the RelayState is the fallback in case the target URL is omitted.

It may also make sense to hint to the reader that they might like to investigate the trusted.url.domains configuration option to best validate the target. I imagine sites will already have trusted domains set up but mentioning it in the docs seems like a good idea to follow section 2.5 of the spec.

I added a sentence in the md file

@monkeyiq
Copy link
Contributor

I am happy with the RelayState being used for the target if that is not set in a Sstc-request-initiation setting. As mentioned in 2.3.1 Defined Parameters in Sstc-request-initiation-cs-01 the SP must provide a default if nothing is given and has the choice of what to provide there.

@monkeyiq
Copy link
Contributor

Actually that seems ok in general. The returnto is coming from the request first in both the old and new code and only from the sp metadata as a fallback in the PR. There isn't any call facing change here and if the sp->md has a relaystate it should come from the configuration and so be chosen by the admin anyway.

--- $returnTo = $request->query->get('ReturnTo');
+++ $request->query->get('ReturnTo') ?? $spSource->getMetadata()->getString('RelayState')

@monkeyiq
Copy link
Contributor

It also helps the review that this has been tested in a dev environment as well :)

@monkeyiq monkeyiq merged commit a085a42 into simplesamlphp:simplesamlphp-2.3 May 20, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants