Class: IntegrationPal::SamlController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- IntegrationPal::SamlController
- Defined in:
- app/controllers/integration_pal/saml_controller.rb
Defined Under Namespace
Classes: ERBContext
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from ApplicationController
Class Method Details
.idp_metadata ⇒ Object
23 24 25 |
# File 'app/controllers/integration_pal/saml_controller.rb', line 23 def ||= (IntegrationPal.) end |
.parse_meta_file(filename) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/integration_pal/saml_controller.rb', line 4 def (filename) possible_names = ['.erb', ''].map { |ext| filename+ext } possible_paths = [] ['config/saml', 'config'].each do |prefix| possible_names.each do |filename| possible_paths << Rails.root.join(prefix, filename) end end = possible_paths.find &:exist? = File.read() if .extname == '.erb' = ERB.new().result(ERBContext.new.get_binding) end SAML2::Entity.parse() end |
.sp_metadata ⇒ Object
27 28 29 |
# File 'app/controllers/integration_pal/saml_controller.rb', line 27 def ||= (IntegrationPal.) end |
Instance Method Details
#create ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/integration_pal/saml_controller.rb', line 51 def create response, _relay_state = SAML2::Bindings::HTTP_POST.decode(request.request_parameters) unless self.class..valid_response?(response, self.class.) logger.error("Failed to validate SAML response: #{response.errors}") raise ActionController::RoutingError.new('Not Found') end reset_session session[:saml_username] = response.assertions.first.subject.name_id.id logger.info("Logged in using SAML2 as #{session[:saml_username]}") redirect_to root_url end |
#metadata ⇒ Object
65 66 67 |
# File 'app/controllers/integration_pal/saml_controller.rb', line 65 def render xml: self.class..to_xml end |
#new ⇒ Object
46 47 48 49 |
# File 'app/controllers/integration_pal/saml_controller.rb', line 46 def new authn_request = self.class..initiate_authn_request(self.class.) redirect_to SAML2::Bindings::HTTPRedirect.encode(authn_request) end |
#skip_authentication? ⇒ Boolean
42 43 44 |
# File 'app/controllers/integration_pal/saml_controller.rb', line 42 def skip_authentication? true end |