Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id EF877200D12 for ; Sat, 23 Sep 2017 00:26:59 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EE51F1609E5; Fri, 22 Sep 2017 22:26:59 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E6E421609D0 for ; Sat, 23 Sep 2017 00:26:58 +0200 (CEST) Received: (qmail 23068 invoked by uid 500); 22 Sep 2017 22:26:58 -0000 Mailing-List: contact user-help@guacamole.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@guacamole.incubator.apache.org Delivered-To: mailing list user@guacamole.incubator.apache.org Received: (qmail 23058 invoked by uid 99); 22 Sep 2017 22:26:58 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Sep 2017 22:26:58 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 757D4191C71 for ; Fri, 22 Sep 2017 22:26:57 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.301 X-Spam-Level: X-Spam-Status: No, score=-0.301 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-2.8, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=guac-dev-org.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id fPxNulk-BkdM for ; Fri, 22 Sep 2017 22:26:55 +0000 (UTC) Received: from mail-ua0-f172.google.com (mail-ua0-f172.google.com [209.85.217.172]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 30C705FBB1 for ; Fri, 22 Sep 2017 22:26:54 +0000 (UTC) Received: by mail-ua0-f172.google.com with SMTP id 72so1509079uas.8 for ; Fri, 22 Sep 2017 15:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=guac-dev-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=GQv0UCOhtgwpLjWgqd9uNQs3pkj7SwkxBsQc/oWXCuU=; b=pCDMi+y65lt5ZHWAL/atRyqmGsLgz6sky451jER9QonsBpBoc/6aZBDtZCes4Q1Vji VqTrC9wojtH6KQ3Y5r6xMbYbFcvZgsyteB8ZxiuAkY9UwWrMOZsN4c/YTk6aB02n0foO f08ZdV2OUjsUKfN6mvlLfZG6HOZ7mrU8AS+FqBYRaQiClYEG5wOp+0vKgs6E+peiE/Xs 0rT+bTg+ZQw+7o+iRSmy2Z5tC3xwHIFa5cQ3l0f5NTiugMOYZFzl/IEQExF+kyVRp+ug 4XaymR2ol4xlNZNoZfkqlg3u6N+nvHoQ0dGq9TYiQz9b3SORFjs9tyT6zDWP8g3t4ODW j/xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=GQv0UCOhtgwpLjWgqd9uNQs3pkj7SwkxBsQc/oWXCuU=; b=t4GjVBVzKy/cwNGUERZ9HMyvSHvZduZkWSGFkE6DOtkXwAoHxddz9WSrTVBkgrh+Bd nV0wJr5pqTq4/en+kL7/J644uJIOtobUfZHXYNunsJy7FE+PoZ0XA2zKbrgGPM8QMbMw zPGIYglNlZiJkyT3gK08oSscLBzg6kso4v31TY3hWcR3Zg4Y5WCPhXEA8zvAExrPJ34d uETUVxP4UgmDkhT6dA+mrVZVAHsDDc5ZPxAuFjO7dmw6vFh11dUy0prf1gIizoOMnJGh bO+BmJl3xethVVX4PPja3b8m3gWUF4lWf4O6tBKG4YjitmDGqSM4vwN85bgYl+C6GLhF X11w== X-Gm-Message-State: AHPjjUhOQPuZK5mBdsxAqbK4bPr/ZOtW9ti4WScA2uelFczwq6owsKE1 rTOLDdF3af5b3MyhCxCkMLyvXoJkk/0yaZ9Zt5S2HLri X-Google-Smtp-Source: AOwi7QBxYdZRySspFMLT9dW2yf85O0BKOR2ZkpfeNxLOijHSWIYJe7jaOlT5WVuyEPIdwy+Y7kN1yTfQ3KLS8y21FW8= X-Received: by 10.176.86.138 with SMTP id a10mr708435uab.148.1506119212594; Fri, 22 Sep 2017 15:26:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.82.139 with HTTP; Fri, 22 Sep 2017 15:26:12 -0700 (PDT) X-Originating-IP: [157.130.212.6] In-Reply-To: <1506116383746-0.post@n4.nabble.com> References: <1506116383746-0.post@n4.nabble.com> From: Mike Jumper Date: Fri, 22 Sep 2017 15:26:12 -0700 Message-ID: Subject: Re: Handling a SAML POST response To: user@guacamole.incubator.apache.org Content-Type: multipart/alternative; boundary="94eb2c1b047ea80b4b0559ceb453" archived-at: Fri, 22 Sep 2017 22:27:00 -0000 --94eb2c1b047ea80b4b0559ceb453 Content-Type: text/plain; charset="UTF-8" On Fri, Sep 22, 2017 at 2:39 PM, Colin McGuigan < colin_guacamole@walkingshadows.org> wrote: > tldr: The SAML POST body is getting thrown away, and I don't know how to > keep > that from happening. > > Longer: I'm writing a SAML authentication extension, based off of Mike > Jumper's OpenID extension: > https://github.com/mike-jumper/guacamole-auth-openid > > FYI - that code is missing recent changes, as I moved things over to the "openid-auth" branch of my development fork of incubator-guacamole-client, to prepare things to be merged into mainline: https://github.com/mike-jumper/incubator-guacamole-client/tree/openid-auth ... > 5. Identity provider redirects user back to guacamole site > (/?id_token=...) > 6. Javascript detects id_token, redirects user again > (/#/id_token=...) > (I don't fully understand the point of this step, but not relevant to my > actual question) > With OpenID Connect's "implicit flow" (which is what the guacamole-auth-openid extension implements), the IDP sends the token back within the URL fragment, with that token intended to be handled by client-side code. The Guacamole extension manually rearranges that token such that Guacamole's existing automatic authentication code will forward it along to the authentication service for server-side verification and handling. OpenID Connect also provides a different flow which involves a POST to a defined service, but Guacamole's authentication system doesn't work this way. There is a .../api/tokens REST service which produces a JSON response containing the auth token to be used for all future requests. POSTing to that service would result in the generation of an auth token, but would not result in the user being redirected back to Guacamole. > ... Now on my SAML extension, step 1-4 are conceptually the same, and work > fine. > Step 5 is where things break down. The IDP isn't sending information back > in the URL, as is done with the id_token request parameter -- instead, it's > a POST with the SAMLRequest data in the request body. I see this POST > going > to the guacamole site. > > However, when it hits the extension, the request body is empty, which is > not > what I want -- I want the SAMLRequest body that the IDP sent. > > The POST is not hitting the extension; it's hitting a static file. I /presume/ that what is happening is that client-side Javascript is > executing a separate POST to guacamole/api/tokens, and that it is this > request that is actually being handled by the authentication extension. > However, this request does not contain the original request body, hence, my > problem. > > Yes, this is exactly what is happening. The URL that the IDP is using is not a service (it's static HTML and JavaScript), and the JavaScript will not be able to see the body of that POST. I see two possibilities: 1) Reconfigure things with the IDP such that the necessary token is included in the URL, ideally via normal query parameters. Guacamole will forward these automatically, and your extension will receive them in the authentication request. Not sure whether this is possible with SAML. 2) Add a custom REST service within your extension that can accept the POST and deal with the SAML body, generating some unique temporary token and redirecting the user back to the main Guacamole page, including the token in the URL. When the user is taken to that URL in their browser, Guacamole will automatically send the token within the URL through the authentication system, and your extension can validate and complete the process. - Mike --94eb2c1b047ea80b4b0559ceb453 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On F= ri, Sep 22, 2017 at 2:39 PM, Colin McGuigan <colin_guac= amole@walkingshadows.org> wrote:
tldr: The SAML POST body is getting thrown away, a= nd I don't know how to keep
that from happening.

Longer: I'm writing a SAML authentication extension, based off of Mike<= br> Jumper's OpenID extension:
https://github.com/mike-jumper/guacamole-au= th-openid


FYI - that code is missing recent chan= ges, as I moved things over to the "openid-auth" branch of my dev= elopment fork of incubator-guacamole-client, to prepare things to be merged= into mainline:


=
...
5. Identity provider redirects user back to guacamole site
(<site>/?id_token=3D...)
6. Javascript detects id_token, redirects user again (<site>/#/id_tok= en=3D...)
(I don't fully understand the point of this step, but not relevant to m= y
actual question)

With OpenID Connect= 9;s "implicit flow" (which is what the guacamole-auth-openid exte= nsion implements), the IDP sends the token back within the URL fragment, wi= th that token intended to be handled by client-side code. The Guacamole ext= ension manually rearranges that token such that Guacamole's existing au= tomatic authentication code will forward it along to the authentication ser= vice for server-side verification and handling.

Op= enID Connect also provides a different flow which involves a POST to a defi= ned service, but Guacamole's authentication system doesn't work thi= s way. There is a .../api/tokens REST service which produces a JSON respons= e containing the auth token to be used for all future requests. POSTing to = that service would result in the generation of an auth token, but would not= result in the user being redirected back to Guacamole.
=C2=A0
... Now on my SAML= extension, step 1-4 are conceptually the same, and work fine.
Step 5 is where things break down.=C2=A0 The IDP isn't sending informat= ion back
in the URL, as is done with the id_token request parameter -- instead, it&#= 39;s
a POST with the SAMLRequest data in the request body.=C2=A0 I see this POST= going
to the guacamole site.

However, when it hits the extension, the request body is empty, which is no= t
what I want -- I want the SAMLRequest body that the IDP sent.


The POST is not hitting the extension;= it's hitting a static file.

I /presume/ that what is happening is that client-side Javascript is
executing a separate POST to guacamole/api/tokens, and that it is this
request that is actually being handled by the authentication extension.
However, this request does not contain the original request body, hence, my=
problem.


Yes, this is exactly what is happening= . The URL that the IDP is using is not a service (it's static HTML and = JavaScript), and the JavaScript will not be able to see the body of that PO= ST.

I see two possibilities:

<= div>1) Reconfigure things with the IDP such that the necessary token is inc= luded in the URL, ideally via normal query parameters. Guacamole will forwa= rd these automatically, and your extension will receive them in the authent= ication request. Not sure whether this is possible with SAML.
2) Add a custom REST service within your extension that can acc= ept the POST and deal with the SAML body, generating some unique temporary = token and redirecting the user back to the main Guacamole page, including t= he token in the URL. When the user is taken to that URL in their browser, G= uacamole will automatically send the token within the URL through the authe= ntication system, and your extension can validate and complete the process.=

- Mike

--94eb2c1b047ea80b4b0559ceb453--