Commit c19947a
2017-11-23 23:21:34
1 parent
4678182
Changed files (6)
airport
app
controllers
models
views
registrations
config
airport/app/controllers/registrations_controller.rb
@@ -0,0 +1,19 @@
+class RegistrationsController < ApplicationController
+ skip_before_action :authenticate!
+
+ def index
+ @metadatum = Metadatum.all.limit(10)
+ end
+
+ def show
+ metadatum = Metadatum.find(params[:id])
+ render xml: metadatum.to_xml
+ end
+
+ def new
+ end
+
+ def create
+ Saml::Kit.configuration.registry.register_url(params[:url], verify_ssl: Rails.env.production?)
+ end
+end
airport/app/models/metadatum.rb
@@ -1,4 +1,8 @@
class Metadatum < ApplicationRecord
+ def to_xml
+ to_saml.to_xml
+ end
+
def to_saml
Saml::Kit::Metadata.from(metadata)
end
airport/app/views/registrations/create.js.erb
@@ -0,0 +1,1 @@
+window.location.href = '<%= registrations_path %>';
airport/app/views/registrations/index.html.erb
@@ -0,0 +1,16 @@
+<div class="container">
+ <div class="row">
+ <div class="col">
+ <%= link_to "register", new_registration_path %>
+ <table class="table">
+ <tbody>
+ <% @metadatum.each do |metadata| %>
+ <tr>
+ <td><%= link_to metadata.issuer, registration_path(metadata) %></td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+ </div>
+ </div>
+</div>
airport/app/views/registrations/new.html.erb
@@ -0,0 +1,13 @@
+<div class="container">
+ <div class="row">
+ <div class="col">
+ <h1>Register an Identity Provider</h1>
+
+ <%= form_with url: registrations_path do |form| %>
+ <%= form.label :url %>
+ <%= form.url_field :url, required: true %>
+ <%= form.submit %>
+ <% end %>
+ </div>
+ </div>
+</div>
airport/config/routes.rb
@@ -1,10 +1,10 @@
Rails.application.routes.draw do
get "dashboard", to: "dashboard#show", as: :dashboard
- resource :session, only: [:new, :create, :destroy]
+ resource :session, only: [:new, :destroy]
resource :assertion, only: [:create, :destroy]
post "/assertions/consume" => "assertions#create", as: :consume
post "/assertions/logout" => "assertions#destroy", as: :logout
resource :metadata, only: [:show]
- resources :computers, only: [:index]
+ resources :registrations, only: [:index, :show, :new, :create]
root to: "sessions#new"
end