Merge branch '17499-wb-login-form' refs #17499
authorPeter Amstutz <peter.amstutz@curii.com>
Mon, 17 May 2021 14:57:03 +0000 (10:57 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Mon, 17 May 2021 14:57:03 +0000 (10:57 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

apps/workbench/app/views/users/welcome.html.erb
apps/workbench/public/arvados-logo-big.png [new file with mode: 0644]
apps/workbench/test/integration/application_layout_test.rb
lib/config/config.default.yml
lib/config/generated_config.go
sdk/python/tests/run_test_server.py

index 479e3e1d89dec50c5d6398ad3e7dc470be211d8c..0b98909e67d81f036558153e2fb662ff70af1f30 100644 (file)
@@ -4,42 +4,74 @@ SPDX-License-Identifier: AGPL-3.0 %>
 
 <% content_for :breadcrumbs do raw '<!-- -->' end %>
 
-<div class="row">
-  <div class="col-sm-8 col-sm-push-4" style="margin-top: 1em">
-    <div class="well clearfix">
-      <%= image_tag "dax.png", style: "width: 112px; height: 150px; margin-right: 2em", class: 'pull-left' %>
-
-      <h3 style="margin-top:0">Please log in.</h3>
-
-      <p>
+<%= javascript_tag do %>
+      function controller_password_authenticate(event) {
+        event.preventDefault()
+        document.getElementById('login-authenticate-error').innerHTML = '';
+        fetch('<%= "#{Rails.configuration.Services.Controller.ExternalURL}" %>arvados/v1/users/authenticate', {
+          method: 'POST',
 
-        The "Log in" button below will show you a Google sign-in page.
-        After you assure Google that you want to log in here with your
-        Google account, you will be redirected back here to
-        <%= Rails.configuration.Workbench.SiteName %>.
+          headers: {'Content-Type': 'application/json'},
+          body: JSON.stringify({
+            username: document.getElementById('login-username').value,
+            password: document.getElementById('login-password').value,
+          }),
+        }).then(function(resp) {
+          if (!resp.ok) {
+            resp.json().then(function(respj) {
+              document.getElementById('login-authenticate-error').innerHTML = "<p>"+respj.errors[0]+"</p>";
+            });
+            return;
+           }
 
-      </p><p>
+           var redir = document.getElementById('login-return-to').value
+           if (redir.indexOf('?') > 0) {
+             redir += '&'
+           } else {
+             redir += '?'
+           }
+           resp.json().then(function(respj) {
+             document.location = redir + "api_token=v2/" + respj.uuid + "/" + respj.api_token;
+           });
+         });
+      }
+      function clear_authenticate_error() {
+        document.getElementById('login-authenticate-error').innerHTML = "";
+      }
+<% end %>
 
-        If you have never used <%= Rails.configuration.Workbench.SiteName %>
-        before, logging in for the first time will automatically
-        create a new account.
-
-      </p><p>
+<div class="row">
+  <div class="col-sm-8 col-sm-push-4" style="margin-top: 1em">
+    <div class="well clearfix">
 
-        <i><%= Rails.configuration.Workbench.SiteName %> uses your name and
-          email address only for identification, and does not retrieve
-          any other personal information from Google.</i>
+      <%= raw(Rails.configuration.Workbench.WelcomePageHTML) %>
 
-      </p>
-        <%# Todo: add list of external authentications providers to
-            discovery document, then generate the option list here. Right
-            now, don't provide 'auth_provider' to get the default one. %>
+      <% case %>
+      <% when Rails.configuration.Login.Google.Enable %>
+      <% when Rails.configuration.Login.OpenIDConnect.Enable %>
+      <% when Rails.configuration.Login.SSO.Enable %>
         <div class="pull-right">
           <%= link_to arvados_api_client.arvados_login_url(return_to: request.url), class: "btn btn-primary" do %>
           Log in to <%= Rails.configuration.Workbench.SiteName %>
           <i class="fa fa-fw fa-arrow-circle-right"></i>
           <% end %>
         </div>
+      <% when Rails.configuration.Login.PAM.Enable %>
+      <% when Rails.configuration.Login.LDAP.Enable %>
+      <% when Rails.configuration.Login.Test.Enable %>
+        <form id="login-form-tag" onsubmit="controller_password_authenticate(event)">
+          <p>username <input type="text" class="form-control" name="login-username"
+                            value="" id="login-username" style="width: 50%"
+                            oninput="clear_authenticate_error()"></input></p>
+          <p>password <input type="password" class="form-control" name="login-password" value=""
+                            id="login-password" style="width: 50%"
+                            oninput="clear_authenticate_error()"></input></p>
+        <input type="hidden" name="return_to" value="<%= "#{Rails.configuration.Services.Workbench1.ExternalURL}" %>" id="login-return-to">
+        <span style="color: red"><p id="login-authenticate-error"></p></span>
+        <button type="submit" class="btn btn-primary">Log in</button>
+        </form>
+      <% end %>
+
     </div>
   </div>
 </div>
diff --git a/apps/workbench/public/arvados-logo-big.png b/apps/workbench/public/arvados-logo-big.png
new file mode 100644 (file)
index 0000000..c511f0e
Binary files /dev/null and b/apps/workbench/public/arvados-logo-big.png differ
index e28809e1318ba42c572d9f1a3eca94387d9a39b2..7d34c43deb5103d72ac986f90a49dd24c48a5e73 100644 (file)
@@ -20,9 +20,9 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest
 
     if !user
       assert page.has_text?('Please log in'), 'Not found text - Please log in'
-      assert page.has_text?('The "Log in" button below will show you a Google sign-in page'), 'Not found text - google sign in page'
+      assert page.has_text?('If you have never used Arvados Workbench before'), 'Not found text - If you have never'
       assert page.has_no_text?('My projects'), 'Found text - My projects'
-      assert page.has_link?("Log in to #{Rails.configuration.Workbench.SiteName}"), 'Not found text - log in to'
+      assert page.has_link?("Log in"), 'Not found text - Log in'
     elsif user['is_active']
       if profile_config && !has_profile
         assert page.has_text?('Save profile'), 'No text - Save profile'
index 17fecf1582cf62f2215c98987d3a9e4951b868ed..50a965a9aaed55a5fd433ffa73045e6a81805d55 100644 (file)
@@ -1429,15 +1429,11 @@ Clusters:
         <img src="/arvados-logo-big.png" style="width: 20%; float: right; padding: 1em;" />
         <h2>Please log in.</h2>
 
-        <p>The "Log in" button below will show you a sign-in
-        page. After you log in, you will be redirected back to
-        Arvados Workbench.</p>
-
         <p>If you have never used Arvados Workbench before, logging in
         for the first time will automatically create a new
         account.</p>
 
-        <i>Arvados Workbench uses your name and email address only for
+        <i>Arvados Workbench uses your information only for
         identification, and does not retrieve any other personal
         information.</i>
 
index de233a8668c662c79184f57463cf1b334c297e00..5216f81616ed5b8c5769884fa8e42c7f383da8ca 100644 (file)
@@ -1435,15 +1435,11 @@ Clusters:
         <img src="/arvados-logo-big.png" style="width: 20%; float: right; padding: 1em;" />
         <h2>Please log in.</h2>
 
-        <p>The "Log in" button below will show you a sign-in
-        page. After you log in, you will be redirected back to
-        Arvados Workbench.</p>
-
         <p>If you have never used Arvados Workbench before, logging in
         for the first time will automatically create a new
         account.</p>
 
-        <i>Arvados Workbench uses your name and email address only for
+        <i>Arvados Workbench uses your information only for
         identification, and does not retrieve any other personal
         information.</i>
 
index 953021f0e7a18bc622920a19e8d7e73cc764ae13..917d6100ae211853d379bcc04bbd4a591f3e625f 100644 (file)
@@ -770,6 +770,7 @@ def setup_config():
                 },
                 "Login": {
                     "SSO": {
+                        "Enable": True,
                         "ProviderAppID": "arvados-server",
                         "ProviderAppSecret": "608dbf356a327e2d0d4932b60161e212c2d8d8f5e25690d7b622f850a990cd33",
                     },