Commit 9a8a6e7
Changed files (2)
app
controllers
app/controllers/concerns/saml_respondable.rb
@@ -1,35 +0,0 @@
-# frozen_string_literal: true
-
-module SamlRespondable
- extend ActiveSupport::Concern
- ALLOWED_SAML_PARAMS = [
- :RelayState,
- :SAMLEncoding,
- :SAMLRequest,
- :SAMLResponse,
- :SigAlg,
- :Signature,
- ].freeze
-
- def binding_for(binding, location)
- if binding == :http_post
- Saml::Kit::Bindings::HttpPost.new(location: location)
- else
- Saml::Kit::Bindings::HttpRedirect.new(location: location)
- end
- end
-
- def saml_params(allowed_params = ALLOWED_SAML_PARAMS)
- @saml_params ||=
- if request.post?
- params.permit(*allowed_params)
- else
- query_string = request.query_string
- on = query_string.include?("&") ? "&" : "&"
- result = Hash[query_string.split(on).map { |x| x.split("=", 2) }]
- result = result.symbolize_keys
- result.select! { |key, _value| allowed_params.include?(key.to_sym) }
- result
- end
- end
-end
app/controllers/sessions_controller.rb
@@ -1,7 +1,14 @@
# frozen_string_literal: true
class SessionsController < ApplicationController
- include SamlRespondable
+ ALLOWED_SAML_PARAMS = [
+ :RelayState,
+ :SAMLEncoding,
+ :SAMLRequest,
+ :SAMLResponse,
+ :SigAlg,
+ :Signature,
+ ].freeze
skip_before_action :verify_authenticity_token, only: [:new, :destroy]
skip_before_action :authenticate!, only: [:new, :create, :destroy]
@@ -77,4 +84,26 @@ class SessionsController < ApplicationController
session[:user_id] = user.to_param
session[:saml] = saml_data
end
+
+ def binding_for(binding, location)
+ if binding == :http_post
+ Saml::Kit::Bindings::HttpPost.new(location: location)
+ else
+ Saml::Kit::Bindings::HttpRedirect.new(location: location)
+ end
+ end
+
+ def saml_params(allowed_params = ALLOWED_SAML_PARAMS)
+ @saml_params ||=
+ if request.post?
+ params.permit(*allowed_params)
+ else
+ query_string = request.query_string
+ on = query_string.include?("&") ? "&" : "&"
+ result = Hash[query_string.split(on).map { |x| x.split("=", 2) }]
+ result = result.symbolize_keys
+ result.select! { |key, _value| allowed_params.include?(key.to_sym) }
+ result
+ end
+ end
end