Commit 84f9b20
Changed files (6)
app
assets
stylesheets
controllers
views
app/assets/stylesheets/application.css
@@ -14,3 +14,20 @@
*= require_tree .
*= require_self
*/
+
+@keyframes spinner {
+ 0% { transform: rotate(0deg) }
+ 100% { transform: rotate(360deg) }
+}
+
+.spinner {
+ margin: auto;
+ width: 48px;
+ height: 48px;
+ animation: spinner 0.65s infinite steps(12);
+}
+
+.spinner svg {
+ width: 48px;
+ height: 48px;
+}
app/controllers/sessions_controller.rb
@@ -32,10 +32,9 @@ class SessionsController < ApplicationController
end
user = User.find_by(uuid: saml_request.name_id)
response_binding = saml_request.provider.single_logout_service_for(binding: :http_post)
- saml_response = saml_request.response_for(user)
- @url, @saml_params = response_binding.serialize(saml_response, relay_state: saml_params[:RelayState])
+ @saml_response = saml_request.response_for(user)
+ @url, @saml_params = response_binding.serialize(@saml_response, relay_state: saml_params[:RelayState])
reset_session
- render layout: "spinner"
elsif saml_params[:SAMLResponse].present?
else
end
@@ -65,10 +64,10 @@ class SessionsController < ApplicationController
def post_back(saml_request, user)
response_binding = saml_request.provider.assertion_consumer_service_for(binding: :http_post)
- saml_response = saml_request.response_for(user)
- @url, @saml_params = response_binding.serialize(saml_response, relay_state: saml_params[:RelayState])
+ @saml_response = saml_request.response_for(user)
+ @url, @saml_params = response_binding.serialize(@saml_response, relay_state: saml_params[:RelayState])
reset_session
session[:user_id] = user.id
- render :create, layout: "spinner"
+ render :create
end
end
app/views/application/_spinner.html.erb
@@ -0,0 +1,1 @@
+<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>
app/views/layouts/spinner.html.erb
@@ -1,43 +0,0 @@
-<!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,11 +1,23 @@
-<%= form_tag(@url, style: "position: absolute; left: -10000px; top: -10000px;") do %>
- <% @saml_params.each do |(key, value)| %>
- <%= hidden_field_tag key, value %>
- <% end %>
-<% end %>
+<div class="container">
+ <div class="row">
+ <div class="col">
+ <%= render partial: 'spinner' %>
+ <%= form_tag(@url, style: "position: absolute; left: -10000px; top: -10000px;") do %>
+ <% @saml_params.each do |(key, value)| %>
+ <%= hidden_field_tag key, value %>
+ <% end %>
+ <% end %>
+ <%= debug @saml_response.build.to_xhtml %>
+ </div>
+ </div>
+</div>
<%= javascript_tag do %>
+ function startTimer(duration) {
+ setInterval(function(){ if (--duration < 0) { document.forms[0].submit(); } }, 1000);
+ }
window.onload = function () {
- document.forms[0].submit();
+ var fiveSeconds = 5;
+ startTimer(fiveSeconds);
};
<% end %>
app/views/sessions/destroy.html.erb
@@ -1,12 +1,24 @@
-<h1>Logging Out of IDP</h1>
-<%= form_tag(@url, style: "position: absolute; left: -10000px; top: -10000px;") do %>
- <%= @saml_params.each do |(key, value)| %>
- <%= hidden_field_tag key, value %>
- <% end %>
-<% end %>
+<div class="container">
+ <div class="row">
+ <div class="col">
+ <%= render partial: 'spinner' %>
+ <h1>Logging Out of IDP</h1>
+ <%= form_tag(@url, style: "position: absolute; left: -10000px; top: -10000px;") do %>
+ <%= @saml_params.each do |(key, value)| %>
+ <%= hidden_field_tag key, value %>
+ <% end %>
+ <% end %>
+ <%= debug @saml_response.build.to_xhtml %>
+ </div>
+ </div>
+</div>
<%= javascript_tag do %>
- window.onload= function () {
- document.forms[0].submit();
+ function startTimer(duration) {
+ setInterval(function(){ if (--duration < 0) { document.forms[0].submit(); } }, 1000);
+ }
+ window.onload = function () {
+ var fiveSeconds = 5;
+ startTimer(fiveSeconds);
};
<% end %>