Commit 1bed713

mo <mo.khan@gmail.com>
2017-11-14 00:33:13
post to IDP to logout.
1 parent 8beb40f
Changed files (4)
app/controllers/sessions_controller.rb
@@ -1,5 +1,5 @@
 class SessionsController < ApplicationController
-  skip_before_action :verify_authenticity_token, only: [:new]
+  skip_before_action :verify_authenticity_token, only: [:new, :destroy]
   before_action :load_saml_request, only: [:new, :create]
 
   def new
@@ -13,12 +13,16 @@ class SessionsController < ApplicationController
       session[:user_id] = user.id
       @saml_response = @saml_request.response_for(user)
       @relay_state = params[:RelayState]
-      render layout: nil
+      render layout: "spinner"
     else
       redirect_to new_session_path, error: "Invalid Credentials"
     end
   end
 
+  def destroy
+    render layout: "spinner"
+  end
+
   private
 
   def user_params
app/views/layouts/spinner.html.erb
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <style type="text/css" media="all">
+      html,
+      body {
+        width: 100%;
+        height: 100%;
+      }
+
+      body {
+        display: -ms-flexbox;
+        display: flex;
+        -ms-flex-align: center;
+        align-items: center;
+        -ms-flex-pack: center;
+        justify-content: center;
+      }
+
+      @keyframes spinner {
+        0% { transform: rotate(0deg) }
+        100% { transform: rotate(360deg) }
+      }
+
+      .spinner {
+        width: 48px;
+        height: 48px;
+        animation: spinner 0.65s infinite steps(12);
+      }
+
+      .spinner svg {
+        width: 48px;
+        height: 48px;
+      }
+    </style>
+  </head>
+  <body onload="document.forms[0].submit();">
+    <div class="spinner"><svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 25 25"><defs><style>line{fill:none;stroke:#1a1a1a;stroke-linecap:round;stroke-miterlimit:10;stroke-width:2px;}.o25{opacity:0.25;}.o85{opacity:0.85;}.o7{opacity:0.7;}.o55{opacity:0.55;}.o35{opacity:0.35;}</style></defs><line x1="12.5" y1="2" x2="12.5" y2="7.05463"/><line class="o25" x1="12.5" y1="23" x2="12.5" y2="17.94537"/><line class="o85" x1="7.25" y1="3.40674" x2="9.77942" y2="7.78778"/><line class="o25" x1="17.75" y1="21.59326" x2="15.22058" y2="17.21222"/><line class="o25" x1="17.21222" y1="15.22058" x2="21.59326" y2="17.75"/><line class="o7" x1="7.78778" y1="9.77942" x2="3.40674" y2="7.25"/><line class="o25" x1="23" y1="12.5" x2="17.94537" y2="12.5"/><line class="o55" x1="7.05463" y1="12.5" x2="2" y2="12.5"/><line class="o35" x1="7.78778" y1="15.22058" x2="3.40674" y2="17.75"/><line class="o25" x1="21.59326" y1="7.25" x2="17.21222" y2="9.77942"/><line class="o25" x1="9.77942" y1="17.21222" x2="7.25" y2="21.59326"/><line class="o25" x1="17.75" y1="3.40674" x2="15.22058" y2="7.78778"/></svg></div>
+    <%= yield %>
+  </body>
+</html>
app/views/sessions/create.html.erb
@@ -1,47 +1,11 @@
-<!DOCTYPE html>
-<html>
-  <head>
-    <meta charset="utf-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-    <style type="text/css" media="all">
-      html,
-      body {
-        width: 100%;
-        height: 100%;
-      }
-
-      body {
-        display: -ms-flexbox;
-        display: flex;
-        -ms-flex-align: center;
-        align-items: center;
-        -ms-flex-pack: center;
-        justify-content: center;
-      }
-
-      @keyframes spinner {
-        0% { transform: rotate(0deg) }
-        100% { transform: rotate(360deg) }
-      }
-
-      .spinner {
-        width: 48px;
-        height: 48px;
-        animation: spinner 0.65s infinite steps(12);
-      }
-
-      .spinner svg {
-        width: 48px;
-        height: 48px;
-      }
-    </style>
-  </head>
-  <body onload="document.forms[0].submit();">
-    <div class="spinner"><svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 25 25"><defs><style>line{fill:none;stroke:#1a1a1a;stroke-linecap:round;stroke-miterlimit:10;stroke-width:2px;}.o25{opacity:0.25;}.o85{opacity:0.85;}.o7{opacity:0.7;}.o55{opacity:0.55;}.o35{opacity:0.35;}</style></defs><line x1="12.5" y1="2" x2="12.5" y2="7.05463"/><line class="o25" x1="12.5" y1="23" x2="12.5" y2="17.94537"/><line class="o85" x1="7.25" y1="3.40674" x2="9.77942" y2="7.78778"/><line class="o25" x1="17.75" y1="21.59326" x2="15.22058" y2="17.21222"/><line class="o25" x1="17.21222" y1="15.22058" x2="21.59326" y2="17.75"/><line class="o7" x1="7.78778" y1="9.77942" x2="3.40674" y2="7.25"/><line class="o25" x1="23" y1="12.5" x2="17.94537" y2="12.5"/><line class="o55" x1="7.05463" y1="12.5" x2="2" y2="12.5"/><line class="o35" x1="7.78778" y1="15.22058" x2="3.40674" y2="17.75"/><line class="o25" x1="21.59326" y1="7.25" x2="17.21222" y2="9.77942"/><line class="o25" x1="9.77942" y1="17.21222" x2="7.25" y2="21.59326"/><line class="o25" x1="17.75" y1="3.40674" x2="15.22058" y2="7.78778"/></svg></div>
-    <%= form_tag(@saml_response.acs_url, style: "position: absolute; left: -10000px; top: -10000px;") do %>
-      <%= hidden_field_tag("SAMLResponse", @saml_response.serialize) %>
-      <%= hidden_field_tag("RelayState", @relay_state) %>
-      <%= submit_tag "Submit" %>
-    <% end %>
-  </body>
-</html>
+<%= form_tag(@saml_response.acs_url, style: "position: absolute; left: -10000px; top: -10000px;") do %>
+  <%= hidden_field_tag("SAMLResponse", @saml_response.serialize) %>
+  <%= hidden_field_tag("RelayState", @relay_state) %>
+  <%= submit_tag "Submit" %>
+<% end %>
+
+<%= javascript_tag do %>
+  window.onload= function () {
+    document.forms[0].submit();
+  };
+<% end %>
app/views/sessions/destroy.html.erb
@@ -0,0 +1,1 @@
+<h1>Logging Out of IDP</h1>