Sha256: ee3dfabf731a79687a17917004690e506d3345a6a5821a6978e926a348b03d80

Contents?: true

Size: 914 Bytes

Versions: 2

Compression:

Stored size: 914 Bytes

Contents

require 'devise/strategies/authenticatable' 
module Devise
  module Strategies
    class SamlAuthenticatable < Authenticatable
      include DeviseSamlAuthenticatable::SamlConfig
      def valid?
        params[:SAMLResponse]
      end
      def authenticate!
        @response = OneLogin::RubySaml::Response.new(params[:SAMLResponse])
        @response.settings = get_saml_config
        resource = mapping.to.authenticate_with_saml(@response)
        if @response.is_valid?
          success!(resource)
        else
          fail!(:invalid)
        end
      end

      # This method should turn off storage whenever CSRF cannot be verified.
      # Any known way on how to let the IdP send the CSRF token along with the SAMLResponse ?
      # Please let me know!
      def store?
        true
      end

    end
  end
end

Warden::Strategies.add(:saml_authenticatable, Devise::Strategies::SamlAuthenticatable)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
devise_saml_authenticatable-1.0 lib/devise_saml_authenticatable/strategy.rb
devise_saml_authenticatable-0.1.0 lib/devise_saml_authenticatable/strategy.rb