Class: Code0::Identities::Provider::Saml
- Inherits:
-
Object
- Object
- Code0::Identities::Provider::Saml
- Defined in:
- lib/code0/identities/provider/saml.rb,
sig/code0/identities/provider/saml.rbs
Instance Attribute Summary collapse
-
#config_loader ⇒ Object
readonly
Returns the value of attribute config_loader.
Instance Method Summary collapse
- #authorization_url ⇒ String
-
#initialize(config_loader) ⇒ Saml
constructor
A new instance of Saml.
- #load_identity(**params) ⇒ Identity
- #validate_config! ⇒ void
Constructor Details
#initialize(config_loader) ⇒ Saml
Returns a new instance of Saml.
9 10 11 |
# File 'lib/code0/identities/provider/saml.rb', line 9 def initialize(config_loader) @config_loader = config_loader end |
Instance Attribute Details
#config_loader ⇒ Object (readonly)
Returns the value of attribute config_loader.
7 8 9 |
# File 'lib/code0/identities/provider/saml.rb', line 7 def config_loader @config_loader end |
Instance Method Details
#authorization_url ⇒ String
23 24 25 26 27 28 |
# File 'lib/code0/identities/provider/saml.rb', line 23 def request = OneLogin::RubySaml::Authrequest.new request.create(create_settings) request.instance_variable_get :@login_url end |
#load_identity(**params) ⇒ Identity
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/code0/identities/provider/saml.rb', line 30 def load_identity(**params) response = OneLogin::RubySaml::Response.new(params[:SAMLResponse], { **config[:response_settings], settings: create_settings }) attributes = response.attributes Identity.new(config[:provider_name], response.name_id, find_attribute(attributes, config[:attribute_statements][:username]), find_attribute(attributes, config[:attribute_statements][:email]), find_attribute(attributes, config[:attribute_statements][:firstname]), find_attribute(attributes, config[:attribute_statements][:lastname])) end |
#validate_config! ⇒ void
This method returns an undefined value.
13 14 15 16 17 18 19 20 21 |
# File 'lib/code0/identities/provider/saml.rb', line 13 def validate_config! required_keys = config[:metadata_url].nil? ? %i[settings] : %i[metadata_url] missing_keys = required_keys - config.keys invalid_keys = config.keys - %i[provider_name metadata_url settings response_settings attribute_statements] raise MissingConfigurationError, "Missing: #{missing_keys.inspect}" if missing_keys.any? raise InvalidConfigurationError, "Invalid: #{invalid_keys.inspect}" if invalid_keys.any? end |