Re: Extension session resource

2018-05-09 Thread Nick Couchman
On Wed, May 9, 2018 at 9:40 AM, Mark Nolan  wrote:

> I'm new to guacamole.
>
> Hopefully I have understood this correctly.
>
> I want to create an extension that exposes a RESTful resource. Eventually,
> the resource will connect to the Google Cloud Platform API to allow some
> users to start and stop the host that provides a particular connection.
>
> Currently it implements the AuthenticationProvider interface in a minimal
> way, influenced by the SimpleAuthenticationProvider. It doesn't
> authenticate, but it returns a UserContext. The UserContext returns empty
> lists and directories, except for the root (an empty connection group) and
> the user. All of this seems to work fine - all the methods log (debug
> logging is enabled) and I see the methods being called as I expected. In
> particular, I can see getUserContext being called.
>
> However, I can't seem to get the RESTful bit to work.
>
> The UserContext implements getResource. This returns a simple resource that
> works fine if I use it in a standalone service. But, even if it didn't, I
> never see getResource being called.
>
> And no matter what I use as the URL (within /api/session/ext), I get a
> permission denied reply, which implies that an exception has been
> intercepted. But no exception is logged either, so I can't see any details.
> In fact, nothing is logged at all.
>
> So, before I switch into full-blown debugging mode, can someone point me in
> the right direction.
>
> Am I on the right track?
>

Mark,
Any chance you can share the code?  It sounds to me like you're on the
right track, and I'm guessing it has something to do with the link between
the authentication provider and the user context classes.

-Nick


Extension session resource

2018-05-09 Thread Mark Nolan
I'm new to guacamole.

Hopefully I have understood this correctly.

I want to create an extension that exposes a RESTful resource. Eventually,
the resource will connect to the Google Cloud Platform API to allow some
users to start and stop the host that provides a particular connection.

Currently it implements the AuthenticationProvider interface in a minimal
way, influenced by the SimpleAuthenticationProvider. It doesn't
authenticate, but it returns a UserContext. The UserContext returns empty
lists and directories, except for the root (an empty connection group) and
the user. All of this seems to work fine - all the methods log (debug
logging is enabled) and I see the methods being called as I expected. In
particular, I can see getUserContext being called.

However, I can't seem to get the RESTful bit to work.

The UserContext implements getResource. This returns a simple resource that
works fine if I use it in a standalone service. But, even if it didn't, I
never see getResource being called.

And no matter what I use as the URL (within /api/session/ext), I get a
permission denied reply, which implies that an exception has been
intercepted. But no exception is logged either, so I can't see any details.
In fact, nothing is logged at all.

So, before I switch into full-blown debugging mode, can someone point me in
the right direction.

Am I on the right track?

Thanks,
Mark


[GitHub] guacamole-client pull request #181: GUACAMOLE-38: Implement on-demand connec...

2018-05-09 Thread necouchman
Github user necouchman commented on a diff in the pull request:

https://github.com/apache/guacamole-client/pull/181#discussion_r187026140
  
--- Diff: 
extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java
 ---
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.auth.quickconnect.utility;
+
+import java.io.UnsupportedEncodingException;
+import java.lang.StringBuilder;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.guacamole.GuacamoleClientException;
+import org.apache.guacamole.GuacamoleServerException;
+import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.protocol.GuacamoleConfiguration;
+
+/**
+ * A utility class to parse out a URI into the settings necessary
+ * to generate a GuacamoleConfiguration object.
+ */
+public class QCParser {
+
+/**
+ * The default protocol to use if one is not provided in
+ * the incoming URI.
+ */
+public static final String DEFAULT_URI_PROTOCOL = "ssh";
+
+/**
+ * The default host to use if one is not defined.
+ */
+public static final String DEFAULT_URI_HOST = "localhost";
+
+/**
+ * The regex to use to split username and password.
+ */
+private static final Pattern userinfoPattern = 
Pattern.compile("(^[^:]+):?(.*)");
+
+/**
+ * The regex group of the username.
+ */
+private static final int USERNAME_GROUP = 1;
+
+/**
+ * THe regex group of the password.
+ */
+private static final int PASSWORD_GROUP = 2;
+
+/**
+ * Parse out a URI string and get a GuacamoleConfiguration
+ * from that string, or an exception if the parsing fails.
+ *
+ * @param uri
+ * The string form of the URI to be parsed.
+ *
+ * @return
+ * A GuacamoleConfiguration using a combination of the parsed
+ * URI values and default values when not specified in the
+ * URI.
+ *
+ * @throws GuacamoleException
+ * When an error occurs parsing the URI.
+ */
+public static GuacamoleConfiguration getConfiguration(String uri)
+throws GuacamoleException {
+
+URI qcUri;
+try {
+qcUri = new URI(uri);
+}
+catch (URISyntaxException e) {
+throw new GuacamoleClientException("Invalid URI Syntax", e);
+}
+
+// Break out individual components of the URI.
+String protocol = qcUri.getScheme();
+String host = qcUri.getHost();
+int port = qcUri.getPort();
+String userInfo = qcUri.getUserInfo();
+String query = qcUri.getQuery();
+
+String username = null;
+String password = null;
+Map queryParams = null;
--- End diff --

Untangled.


---