Commit 03ab776
Changed files (3)
app
controllers
views
sessions
app/controllers/responses_controller.rb
@@ -3,12 +3,7 @@
class ResponsesController < ApplicationController
def show
if session[:saml].present?
- xml = session[:saml][:xml]
- saml = if session[:saml][:type] == 'authnrequest'
- Saml::Kit::AuthenticationRequest.new(xml)
- else
- Saml::Kit::LogoutRequest.new(xml)
- end
+ saml = Saml::Kit::Document.to_saml_document(session[:saml][:xml])
return render_error(:forbidden, model: saml) if saml.invalid?
post_back(saml, session[:saml][:params][:RelayState])
else
app/controllers/sessions_controller.rb
@@ -16,17 +16,10 @@ class SessionsController < ApplicationController
binding = binding_for(
request.post? ? :http_post : :http_redirect, new_session_url
)
- @saml_request = binding.deserialize(saml_params)
- if @saml_request.valid?
- session[:saml] = {
- type: 'authnrequest',
- params: saml_params.to_h,
- xml: @saml_request.to_xml
- }
- return redirect_to response_path if current_user?
- else
- render_error(:forbidden, model: @saml_request)
- end
+ @saml = binding.deserialize(saml_params)
+ return render_error(:forbidden, model: @saml) if @saml.invalid?
+ session[:saml] = { params: saml_params.to_h, xml: @saml.to_xml }
+ redirect_to response_path if current_user?
rescue StandardError => error
logger.error(error)
redirect_to my_dashboard_path if current_user?
@@ -48,11 +41,7 @@ class SessionsController < ApplicationController
saml = binding.deserialize(saml_params)
raise ActiveRecord::RecordInvalid.new(saml) if saml.invalid?
raise 'Unknown NameId' unless current_user.uuid == saml.name_id
- session[:saml] = {
- type: 'logout_request',
- params: saml_params.to_h,
- xml: saml.to_xml
- }
+ session[:saml] = { params: saml_params.to_h, xml: saml.to_xml }
redirect_to response_path
elsif saml_params[:SAMLResponse].present?
saml = binding.deserialize(saml_params)
app/views/sessions/new.html.erb
@@ -13,7 +13,7 @@
<%= link_to "Register", new_registration_path %>
<% end %>
- <%= debug @saml_request.try(:to_xhtml) %>
+ <%= debug @saml.try(:to_xhtml) %>
</div>
</div>
</div>