-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
[BUG] Redirect code is wrong in example controller.xq for POST requests #11
Comments
eXist-db's URL Rewrite facility does not provide a mechanism for controlling the Redirect Code at present, until that is possible added in future, a workaround could be something like: (: if no valid token, redirect to SAML auth :)
if (exsaml:is-enabled() and not(exsaml:check-valid-saml-token()))
then (
let $debug := exsaml:log('info', "controller: no valid token, redirect to SAML auth")
let $return-path := "/exist/apps" || $exist:controller || $exist:path
let $response-status :=
if (request:get-method() eq "GET")
then
302
else
303
let $response-location := exsaml:build-authnreq-redir-url($return-path)
return
(
response:set-status-code($response-status),
response:set-header("Location", $response-location),
response:set-header("Cache-Control", "no-cache, no-store"),
response:set-header("Pragma", "no-cache")
) |
@adamretter Have you tested that? I would be surprised if it worked. |
May I ask why that is? |
No. You're the one claiming it works, so pls show.
|
@chakl Yes. My questions was to try and understand why you wrote "I would be surprised if it worked". My suggested change is a small and straightforward one. From your language, I understood you to be dismissive of the change as you believed that it would not work. Is that not the case? If you don't think it would work, I would like to understand why, which is why I wrote "May I ask why that is?".
I am not disputing that what is there may work.
Simply because something is working mostly, does not of course mean that it is correct. We have been debugging a situation where we are using this existdb-saml module with Microsoft Azure. To help us understand the problem, we have been re-reading the 5.1.2 SP-Initiated SSO: Redirect/POST Bindings section of the OASIS specification: Security Assertion Markup Language (SAML) V2.0 Technical Overview. The specification clearly states: When to use a 302 or 303 is clearly set out in the HTTP 1.1 specification from the IETF, see:
At no point have I indicated that I have not tested this. This is a conclusion that you have drawn by yourself.
From reading the relevant specifications, it would seem that the authors of the OASIS SAML specification and the HTTP 1.1 specification might disagree with you.
I find your language to be very inflammatory. I am contributing issues and fixes to this project in good faith. I do not believe the language I have used in this bug report should cause offence to yourself or anyone else, and neither was it intended to do so. |
@adamretter sorry for the late reply, just returned from vacation. Pls give me a moment to check recent communication.
Pls accept my sincere apologies for this. I had assumed you're a native speaker who knows that schoolyard quip "put up or shut up", meaning "show what you have instead of talking about it". I still don't see a use case for this. I'll address this in another message. |
@adamretter Your initial statement is:
Nope. That works exactly as intended, so I call this correct.
Agree. The common use case is
That's where you lost me. What problem or use case does that solve? Why should the client rewrite POST to GET? The result of this code path is a single round-trip between user's browser and IDP, with the IDP POSTing the SP endpoint (which is a different code path). Ok, maybe I'm just colorblind.. Can you show I'd rather remove than add rarely used code paths, so pls show a practical use case for your change request. |
@chakl Accepted. Thank you.
I am British, and I am a native English speaker.
I am aware of it, and it is considered rude (e.g. https://en.wikipedia.org/wiki/Wikipedia:Put_up_or_shut_up#But_%22put_up_or_shut_up%22_is_rude!) Let's move forward... |
Then allow me to rephrase my comment to add further clarity. By "This is incorrect", I perhaps should have written more clearly: "This is incorrect according to the relevant international technical standards, i.e.: (a) OASIS specification: Security Assertion Markup Language (SAML) V2.0 Technical Overview, and (b) IETF RFC 9110 HTTP Semantics (i.e. HTTP 1.1)"
In SAML, the User Agent performs a HTTP POST from a HTML Form to the Service Provide (eXist-db). The SP responds by sending a redirect to the User Agent. The problem is that eXist-db in the code for this module sends a HTTP 302. As you recognised above, a 302 should only be used to redirect from a HTTP GET. It is incorrectly used here to redirect from a HTTP POST.
I am not sure what you mean by "client". Any server receiving a HTTP POST that wants to redirect the client, needs to send a 303 (at present the existdb-saml module always sends a 302). If we want this existdb-saml module to be compliant with the relevant international technical standards, and I can't imagine why we wouldn't, then we need to fix this.
This isn't rare. This occurs on every SAML authentication between UA-SP-IDP. |
Ah, I should have responded to your other msg as well..
existdb-saml currently sends 302, I don't see a violation of (a) OASIS specification at all. As for (b) IETF RFC 9110, I still don't see where this applies, except in a scenario that I think you make up.
Uhm, no. You have this wrong. The User Agent performs a HTTP POST from a HTML Form to the Identity Provider (remote IDP). After successful auth, the IDP POSTs to the configured SAML SP endpoint (called
Yes. And if it ain't broke, don't fix it.
Well, rare for me, as I never experienced issues running that code for years on a few high profile sites. Put up some traces? :) |
@chakl I don't think so. Please see the attached diagram from the OASIS specification for SAML. In my text above, I am specifically referring to what they have conveniently labelled as step 6 and step 7 in their diagram. |
… be specified in the URL Rewite Controller (i.e. `controller.xq`) See eXist-db/existdb-saml#11
… be specified in the URL Rewite Controller (i.e. `controller.xq`) See eXist-db/existdb-saml#11
In the
README.md
an examplecontroller.xq
file is given here:Unfortunately in the provided example, the
<redirect url="{exsaml:build-authnreq-redir-url($return-path)}">
will always produce a HTTP 302 Response Code. This is incorrect:The text was updated successfully, but these errors were encountered: