You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2017/09/27 02:18:11 UTC

[19/29] incubator-guacamole-client git commit: GUACAMOLE-210: Add redirect message. Refactor to use minification and pre-cached templates.

GUACAMOLE-210: Add redirect message. Refactor to use minification and pre-cached templates.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/18790356
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/18790356
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/18790356

Branch: refs/heads/master
Commit: 187903563b3b9dd0a9721a5dafe5a4a58cb268c0
Parents: 724a6a9
Author: Michael Jumper <mj...@apache.org>
Authored: Sun Aug 27 22:36:06 2017 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Mon Sep 25 13:06:44 2017 -0700

----------------------------------------------------------------------
 extensions/guacamole-auth-openid/.gitignore     |  3 +
 extensions/guacamole-auth-openid/pom.xml        | 80 ++++++++++++++++++++
 .../src/main/resources/config/openidConfig.js   | 54 +++++++++++++
 .../resources/controllers/openidController.js   | 30 ++++++++
 .../src/main/resources/guac-manifest.json       | 18 ++++-
 .../src/main/resources/license.txt              | 18 +++++
 .../src/main/resources/openidConfig.js          | 53 -------------
 .../src/main/resources/openidController.js      | 30 --------
 .../src/main/resources/styles/openid.css        | 35 +++++++++
 .../resources/templates/openidTokenField.html   |  5 ++
 .../src/main/resources/translations/en.json     | 12 +++
 11 files changed, 251 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/18790356/extensions/guacamole-auth-openid/.gitignore
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/.gitignore b/extensions/guacamole-auth-openid/.gitignore
new file mode 100644
index 0000000..30eb487
--- /dev/null
+++ b/extensions/guacamole-auth-openid/.gitignore
@@ -0,0 +1,3 @@
+*~
+target/
+src/main/resources/generated/

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/18790356/extensions/guacamole-auth-openid/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/pom.xml b/extensions/guacamole-auth-openid/pom.xml
index 14aea2b..4076998 100644
--- a/extensions/guacamole-auth-openid/pom.xml
+++ b/extensions/guacamole-auth-openid/pom.xml
@@ -53,6 +53,85 @@
                 </configuration>
             </plugin>
 
+            <!-- Pre-cache Angular templates with maven-angular-plugin -->
+            <plugin>
+                <groupId>com.keithbranton.mojo</groupId>
+                <artifactId>angular-maven-plugin</artifactId>
+                <version>0.3.2</version>
+                <executions>
+                    <execution>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>html2js</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <sourceDir>${basedir}/src/main/resources</sourceDir>
+                    <include>**/*.html</include>
+                    <target>${basedir}/src/main/resources/generated/templates-main/templates.js</target>
+                    <prefix>app/ext/guac-openid</prefix>
+                </configuration>
+            </plugin>
+
+            <!-- JS/CSS Minification Plugin -->
+            <plugin>
+                <groupId>com.samaxes.maven</groupId>
+                <artifactId>minify-maven-plugin</artifactId>
+                <version>1.7.5</version>
+                <executions>
+                    <execution>
+                        <id>default-cli</id>
+                        <configuration>
+                            <charset>UTF-8</charset>
+
+                            <webappSourceDir>${basedir}/src/main/resources</webappSourceDir>
+                            <webappTargetDir>${project.build.directory}/classes</webappTargetDir>
+
+                            <cssSourceDir>/</cssSourceDir>
+                            <cssTargetDir>/</cssTargetDir>
+                            <cssFinalFile>openid.css</cssFinalFile>
+
+                            <cssSourceFiles>
+                                <cssSourceFile>license.txt</cssSourceFile>
+                            </cssSourceFiles>
+
+                            <cssSourceIncludes>
+                                <cssSourceInclude>**/*.css</cssSourceInclude>
+                            </cssSourceIncludes>
+
+                            <jsSourceDir>/</jsSourceDir>
+                            <jsTargetDir>/</jsTargetDir>
+                            <jsFinalFile>openid.js</jsFinalFile>
+
+                            <jsSourceFiles>
+                                <jsSourceFile>license.txt</jsSourceFile>
+                            </jsSourceFiles>
+
+                            <jsSourceIncludes>
+                                <jsSourceInclude>**/*.js</jsSourceInclude>
+                            </jsSourceIncludes>
+
+                            <!-- Do not minify and include tests -->
+                            <jsSourceExcludes>
+                                <jsSourceExclude>**/*.test.js</jsSourceExclude>
+                            </jsSourceExcludes>
+                            <jsEngine>CLOSURE</jsEngine>
+
+                            <!-- Disable warnings for JSDoc annotations -->
+                            <closureWarningLevels>
+                                <misplacedTypeAnnotation>OFF</misplacedTypeAnnotation>
+                                <nonStandardJsDocs>OFF</nonStandardJsDocs>
+                            </closureWarningLevels>
+
+                        </configuration>
+                        <goals>
+                            <goal>minify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+
             <!-- Copy dependencies prior to packaging -->
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
@@ -105,6 +184,7 @@
                     <excludes>
                         <exclude>**/*.json</exclude>
                         <exclude>src/licenses/**/*</exclude>
+                        <exclude>src/main/resources/templates/*.html</exclude>
                     </excludes>
                 </configuration>
 

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/18790356/extensions/guacamole-auth-openid/src/main/resources/config/openidConfig.js
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/resources/config/openidConfig.js b/extensions/guacamole-auth-openid/src/main/resources/config/openidConfig.js
new file mode 100644
index 0000000..12bc0da
--- /dev/null
+++ b/extensions/guacamole-auth-openid/src/main/resources/config/openidConfig.js
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+/**
+ * Config block which registers openid-specific field types.
+ */
+angular.module('guacOpenID').config(['formServiceProvider',
+        function guacOpenIDConfig(formServiceProvider) {
+
+    // Define field for token from OpenID service
+    formServiceProvider.registerFieldType("GUAC_OPENID_TOKEN", {
+        templateUrl : 'app/ext/guac-openid/templates/openidTokenField.html',
+        controller  : 'guacOpenIDController',
+        module      : 'guacOpenID'
+    });
+
+}]);
+
+/**
+ * Config block which augments the existing routing, providing special handling
+ * for the "id_token=" fragments provided by OpenID Connect.
+ */
+angular.module('index').config(['$routeProvider',
+        function indexRouteConfig($routeProvider) {
+
+    // Transform "/#/id_token=..." to "/#/?id_token=..."
+    $routeProvider.when('/id_token=:response', {
+
+        template   : '',
+        controller : ['$location', function reroute($location) {
+            var params = $location.path().substring(1);
+            $location.url('/');
+            $location.search(params);
+        }]
+
+    });
+
+}]);

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/18790356/extensions/guacamole-auth-openid/src/main/resources/controllers/openidController.js
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/resources/controllers/openidController.js b/extensions/guacamole-auth-openid/src/main/resources/controllers/openidController.js
new file mode 100644
index 0000000..a1fad88
--- /dev/null
+++ b/extensions/guacamole-auth-openid/src/main/resources/controllers/openidController.js
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+/**
+ * Controller for the "GUAC_OPENID_TOKEN" field which simply redirects the user
+ * immediately to the authorization URI.
+ */
+angular.module('guacOpenID').controller('guacOpenIDController', ['$scope',
+    function guacOpenIDController($scope) {
+
+    // Redirect to authorization URI
+    window.location = $scope.field.authorizationURI;
+
+}]);

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/18790356/extensions/guacamole-auth-openid/src/main/resources/guac-manifest.json
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/resources/guac-manifest.json b/extensions/guacamole-auth-openid/src/main/resources/guac-manifest.json
index c8d626f..e71c140 100644
--- a/extensions/guacamole-auth-openid/src/main/resources/guac-manifest.json
+++ b/extensions/guacamole-auth-openid/src/main/resources/guac-manifest.json
@@ -9,10 +9,20 @@
         "org.apache.guacamole.auth.openid.OpenIDAuthenticationProvider"
     ],
 
+    "translations" : [
+        "translations/en.json"
+    ],
+
     "js" : [
-        "openidModule.js",
-        "openidController.js",
-        "openidConfig.js"
-    ]
+        "openid.min.js"
+    ],
+
+    "css" : [
+        "openid.min.css"
+    ],
+
+    "resources" : {
+        "templates/openidTokenField.html" : "text/html"
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/18790356/extensions/guacamole-auth-openid/src/main/resources/license.txt
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/resources/license.txt b/extensions/guacamole-auth-openid/src/main/resources/license.txt
new file mode 100644
index 0000000..042f3ce
--- /dev/null
+++ b/extensions/guacamole-auth-openid/src/main/resources/license.txt
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/18790356/extensions/guacamole-auth-openid/src/main/resources/openidConfig.js
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/resources/openidConfig.js b/extensions/guacamole-auth-openid/src/main/resources/openidConfig.js
deleted file mode 100644
index cf4c81e..0000000
--- a/extensions/guacamole-auth-openid/src/main/resources/openidConfig.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Config block which registers openid-specific field types.
- */
-angular.module('guacOpenID').config(['formServiceProvider',
-        function guacOpenIDConfig(formServiceProvider) {
-
-    // Define field for token from OpenID service
-    formServiceProvider.registerFieldType("GUAC_OPENID_TOKEN", {
-        controller : 'guacOpenIDController',
-        module     : 'guacOpenID'
-    });
-
-}]);
-
-/**
- * Config block which augments the existing routing, providing special handling
- * for the "id_token=" fragments provided by OpenID Connect.
- */
-angular.module('index').config(['$routeProvider',
-        function indexRouteConfig($routeProvider) {
-
-    // Transform "/#/id_token=..." to "/#/?id_token=..."
-    $routeProvider.when('/id_token=:response', {
-
-        template   : '',
-        controller : ['$location', function reroute($location) {
-            var params = $location.path().substring(1);
-            $location.url('/');
-            $location.search(params);
-        }]
-
-    });
-
-}]);

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/18790356/extensions/guacamole-auth-openid/src/main/resources/openidController.js
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/resources/openidController.js b/extensions/guacamole-auth-openid/src/main/resources/openidController.js
deleted file mode 100644
index a1fad88..0000000
--- a/extensions/guacamole-auth-openid/src/main/resources/openidController.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Controller for the "GUAC_OPENID_TOKEN" field which simply redirects the user
- * immediately to the authorization URI.
- */
-angular.module('guacOpenID').controller('guacOpenIDController', ['$scope',
-    function guacOpenIDController($scope) {
-
-    // Redirect to authorization URI
-    window.location = $scope.field.authorizationURI;
-
-}]);

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/18790356/extensions/guacamole-auth-openid/src/main/resources/styles/openid.css
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/resources/styles/openid.css b/extensions/guacamole-auth-openid/src/main/resources/styles/openid.css
new file mode 100644
index 0000000..eab7f93
--- /dev/null
+++ b/extensions/guacamole-auth-openid/src/main/resources/styles/openid.css
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+.openid-token-field-container {
+    height: 100%;
+    width: 100%;
+    position: fixed;
+    left: 0;
+    top: 0;
+    display: table;
+    background: white;
+}
+
+.openid-token-field {
+    width: 100%;
+    display: table-cell;
+    vertical-align: middle;
+    text-align: center;
+}

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/18790356/extensions/guacamole-auth-openid/src/main/resources/templates/openidTokenField.html
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/resources/templates/openidTokenField.html b/extensions/guacamole-auth-openid/src/main/resources/templates/openidTokenField.html
new file mode 100644
index 0000000..49f6c6f
--- /dev/null
+++ b/extensions/guacamole-auth-openid/src/main/resources/templates/openidTokenField.html
@@ -0,0 +1,5 @@
+<div class="openid-token-field-container">
+    <div class="openid-token-field">
+        <p>{{ 'LOGIN.INFO_REDIRECT_PENDING' | translate }}</p>
+    </div>
+</div>

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/18790356/extensions/guacamole-auth-openid/src/main/resources/translations/en.json
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/resources/translations/en.json b/extensions/guacamole-auth-openid/src/main/resources/translations/en.json
new file mode 100644
index 0000000..6bc5241
--- /dev/null
+++ b/extensions/guacamole-auth-openid/src/main/resources/translations/en.json
@@ -0,0 +1,12 @@
+{
+
+    "DATA_SOURCE_OPENID" : {
+        "NAME" : "OpenID SSO Backend"
+    },
+
+    "LOGIN" : {
+        "FIELD_HEADER_ID_TOKEN" : "",
+        "INFO_REDIRECT_PENDING" : "Please wait, redirecting to identity provider..."
+    }
+
+}