saml_camel 1.0.2 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eaa10069e1db4964516ddb40334b33aacb5565ca
4
- data.tar.gz: fec0501aa4a0b2d778d3ed78193ccacc0e064aa6
3
+ metadata.gz: e845e0da15a5db2349b6572ccdb63fc432caa961
4
+ data.tar.gz: 194faeb1fe2914fe1bb5ff83248cd5c45f09e958
5
5
  SHA512:
6
- metadata.gz: f999dbb2683754347dd79f30a0351ced476e5ab87c149d71f3344080ac865e84fab34ad4cb0aad05976c26fca14985e0fd89d7b8656c9fe4f6fbe9c8c08f842a
7
- data.tar.gz: 434a08a6955a4faceac9d7fa09d57f391002f22d22774eedaf371e53869c87ad1a4c6613a281300e6191539ae5554d89a556027436a7d023ed40543b9cd7b6e1
6
+ metadata.gz: f9d873a64b44da5816d20450df7fc9f0f202abe7f2986193c16abd4bf0c00f7ae94d792e43f81df36107a1fabb52de9d38b4189c4ab0c619f5ba53bdd737d01f
7
+ data.tar.gz: 36d2840f7e8ddd89f1e155634f172a3fa0583aa47e533108078086588d617a96bd8c73c8b592bb41fa07f95cb8a9650412626450471f8bdac4192435f621d0e1
@@ -6,6 +6,7 @@ require_dependency 'saml_camel/application_controller'
6
6
  module SamlCamel::SamlService # rubocop:disable Style/ClassAndModuleChildren
7
7
  extend ActiveSupport::Concern
8
8
 
9
+
9
10
  def cache_available?(app_cache)
10
11
  if app_cache
11
12
  true
@@ -17,18 +18,36 @@ module SamlCamel::SamlService # rubocop:disable Style/ClassAndModuleChildren
17
18
 
18
19
  # TODO: refactor
19
20
  def saml_protect # rubocop:disable Metrics/MethodLength, Metrics/AbcSize:
21
+
22
+ #TODO move this
23
+ begin
24
+ settings = JSON.parse(File.read("config/saml/#{Rails.env}/settings.json"))
25
+ sp_debug = settings['settings']['debug']
26
+ rescue StandardError # rubocop:disable Lint/HandleExceptions
27
+ # rescue othewise the generator fails
28
+ end
29
+
20
30
  user_cache = cache_available?(Rails.cache.fetch(session[:saml_session_id])) if session[:saml_session_id]
21
31
  if session[:saml_session_id] && user_cache
32
+ SamlCamel::Logging.debug('Saml Session and User Cache Found.') if sp_debug
33
+ SamlCamel::Logging.debug("SAML session id: #{session[:saml_session_id]} | Cache: #{user_cache}") if sp_debug
22
34
  sp = SamlCamel::ServiceProvider.new(
23
35
  cache_permit_key: session[:saml_session_id].to_sym,
24
36
  saml_attributes: session[:saml_attributes]
25
37
  )
26
38
  session[:sp_session] = sp.validate_sp_session(session[:sp_session], request.remote_ip)
27
39
  unless session[:saml_response_success] || session[:sp_session]
40
+ SamlCamel::Logging.debug('SAML response not successful or no sp session not valid. Generating new request.') if sp_debug
41
+ SamlCamel::Logging.debug("SAML response: #{session[:saml_response_success]}") if sp_debug
42
+ SamlCamel::Logging.debug("SP session #{session[:sp_session]}") if sp_debug
43
+
28
44
  saml_request_url = sp.generate_saml_request(request)
29
45
  redirect_to(saml_request_url)
30
46
  end
31
47
  else
48
+ SamlCamel::Logging.debug('User Cache or saml session id not found. Generating new request.') if sp_debug
49
+ SamlCamel::Logging.debug("SAML session id: #{session[:saml_session_id]} | Cache: #{user_cache}") if sp_debug
50
+
32
51
  session[:saml_session_id] = SamlCamel::ServiceProvider.generate_permit_key
33
52
  saml_request_url = SamlCamel::ServiceProvider.new(
34
53
  cache_permit_key: session[:saml_session_id].to_sym
@@ -45,6 +45,8 @@ module SamlCamel
45
45
  if sp_session
46
46
  # if the session has exceeded the allowed lifetime, remove session
47
47
  if (Time.now - sp_session_init_time) > sp_lifetime.hour
48
+ SamlCamel::Logging.debug('Session has exceeded the allowed lifetime.') if SP_DEBUG
49
+ SamlCamel::Logging.debug("Current Time: #{Time.now} | Session Init: #{ sp_session_init_time}") if SP_DEBUG
48
50
  SamlCamel::Logging.expired_session(@saml_attributes)
49
51
  return nil
50
52
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SamlCamel
4
- VERSION = '1.0.2'
4
+ VERSION = '1.0.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saml_camel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - 'Danai Adkisson '
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-04 00:00:00.000000000 Z
11
+ date: 2018-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails