Class: SamlCamel::Logging

Inherits:
Object
  • Object
show all
Defined in:
app/models/saml_camel/logging.rb

Constant Summary collapse

SP_SETTINGS =
JSON.parse(File.read("saml/#{Rails.env}/settings.json"))
PRIMARY_ID =
SP_SETTINGS["settings"]["primary_id"]
SHOULD_LOG =
SP_SETTINGS["settings"]["saml_logging"]

Class Method Summary collapse

Class Method Details

.auth_failure(error_context) ⇒ Object



14
15
16
17
18
19
20
# File 'app/models/saml_camel/logging.rb', line 14

def self.auth_failure(error_context)
  logger = Logger.new("log/saml.log")
  logger.error("An error occured during authentication. #{error_context}")
  logger.error("Backtrace: \n\t\t#{error_context.backtrace.join("\n\t\t")}")
rescue
  logger.debug("Unknown Error During auth_failure logging.")
end

.bad_ip(saml_attrs, request_ip, current_ip) ⇒ Object



36
37
38
39
40
41
# File 'app/models/saml_camel/logging.rb', line 36

def self.bad_ip(saml_attrs,request_ip,current_ip)
  logger = Logger.new("log/saml.log")
  logger.info("Bad IP address for #{saml_attrs[PRIMARY_ID]}. IP at SAML request #{request_ip} | IP presented #{current_ip}")
rescue
  logger.debug("Unknown Error During relay state logging.")
end

.expired_session(saml_attrs) ⇒ Object



29
30
31
32
33
34
# File 'app/models/saml_camel/logging.rb', line 29

def self.expired_session(saml_attrs)
  logger = Logger.new("log/saml.log")
  logger.info("Session Expired for #{saml_attrs[PRIMARY_ID]}")
rescue
  logger.debug("Unknown Error During relay state logging.")
end

.logout(saml_attrs) ⇒ Object



22
23
24
25
26
27
# File 'app/models/saml_camel/logging.rb', line 22

def self.logout(saml_attrs)
  logger = Logger.new("log/saml.log")
  logger.info("#{saml_attrs[PRIMARY_ID]} has succesfully logged out.")
rescue
  logger.debug("Unknown error logging user logout. Most likely anonymous user clicked a logout button.")
end

.saml_state(data) ⇒ Object



43
44
45
46
47
48
# File 'app/models/saml_camel/logging.rb', line 43

def self.saml_state(data)
  logger = Logger.new("log/saml.log")
  logger.info("Stored Relay: #{data[:stored_relay]} | RequestRelay: #{data[:request_relay]} | Stored IP: #{data[:stored_ip]}  RemoteIP: #{data[:remote_ip]}")
rescue
  logger.debug("Unknown Error During relay state logging.")
end

.successfull_auth(saml_attrs) ⇒ Object



7
8
9
10
11
12
# File 'app/models/saml_camel/logging.rb', line 7

def self.successfull_auth(saml_attrs)
  logger = Logger.new("log/saml.log")
  logger.info("#{saml_attrs[PRIMARY_ID]} has succesfully authenticated.")
rescue
  logger.debug("Unknown Error During successfull_auth logging. Check PRIMARY_ID configured in settings.json and that user has attribute.")
end