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

.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



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

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