Class: BarkestCore::AuthConfig
- Inherits:
-
Object
- Object
- BarkestCore::AuthConfig
- Includes:
- ActiveModel::Model, ActiveModel::Validations
- Defined in:
- app/models/barkest_core/auth_config.rb
Overview
Defines the authentication configuration for the system.
Instance Attribute Summary collapse
-
#enable_db_auth ⇒ Object
Returns the value of attribute enable_db_auth.
-
#enable_ldap_auth ⇒ Object
Returns the value of attribute enable_ldap_auth.
-
#ldap_auto_activate ⇒ Object
Returns the value of attribute ldap_auto_activate.
-
#ldap_base_dn ⇒ Object
Returns the value of attribute ldap_base_dn.
-
#ldap_browse_password ⇒ Object
Returns the value of attribute ldap_browse_password.
-
#ldap_browse_user ⇒ Object
Returns the value of attribute ldap_browse_user.
-
#ldap_host ⇒ Object
Returns the value of attribute ldap_host.
-
#ldap_port ⇒ Object
Returns the value of attribute ldap_port.
-
#ldap_ssl ⇒ Object
Returns the value of attribute ldap_ssl.
-
#ldap_system_admin_groups ⇒ Object
Returns the value of attribute ldap_system_admin_groups.
Class Method Summary collapse
-
.load ⇒ Object
Loads the configuration from the SystemConfig.
Instance Method Summary collapse
-
#enable_db_auth? ⇒ Boolean
Is DB authentication enabled?.
-
#enable_ldap_auth? ⇒ Boolean
Is LDAP authentication enabled?.
-
#initialize(*args) ⇒ AuthConfig
constructor
Creates the configuration.
-
#ldap_auto_activate? ⇒ Boolean
Is automatic activation enabled for LDAP authenticated users?.
-
#ldap_ssl? ⇒ Boolean
Is SSL enabled for LDAP authentication?.
-
#save ⇒ Object
Saves the configuration (encrypted) to the SystemConfig.
-
#to_h ⇒ Object
Converts the configuration to a hash.
Constructor Details
#initialize(*args) ⇒ AuthConfig
Creates the configuration.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/barkest_core/auth_config.rb', line 27 def initialize(*args) args.each do |arg| if arg.is_a?(Hash) arg.each do |k,v| if respond_to?(:"#{k}?") send :"#{k}=", ((v === true || v === '1') ? '1' : '0') elsif respond_to?(k) send :"#{k}=", v.to_s end end end end end |
Instance Attribute Details
#enable_db_auth ⇒ Object
Returns the value of attribute enable_db_auth.
9 10 11 |
# File 'app/models/barkest_core/auth_config.rb', line 9 def enable_db_auth @enable_db_auth end |
#enable_ldap_auth ⇒ Object
Returns the value of attribute enable_ldap_auth.
9 10 11 |
# File 'app/models/barkest_core/auth_config.rb', line 9 def enable_ldap_auth @enable_ldap_auth end |
#ldap_auto_activate ⇒ Object
Returns the value of attribute ldap_auto_activate.
9 10 11 |
# File 'app/models/barkest_core/auth_config.rb', line 9 def ldap_auto_activate @ldap_auto_activate end |
#ldap_base_dn ⇒ Object
Returns the value of attribute ldap_base_dn.
9 10 11 |
# File 'app/models/barkest_core/auth_config.rb', line 9 def ldap_base_dn @ldap_base_dn end |
#ldap_browse_password ⇒ Object
Returns the value of attribute ldap_browse_password.
9 10 11 |
# File 'app/models/barkest_core/auth_config.rb', line 9 def ldap_browse_password @ldap_browse_password end |
#ldap_browse_user ⇒ Object
Returns the value of attribute ldap_browse_user.
9 10 11 |
# File 'app/models/barkest_core/auth_config.rb', line 9 def ldap_browse_user @ldap_browse_user end |
#ldap_host ⇒ Object
Returns the value of attribute ldap_host.
9 10 11 |
# File 'app/models/barkest_core/auth_config.rb', line 9 def ldap_host @ldap_host end |
#ldap_port ⇒ Object
Returns the value of attribute ldap_port.
9 10 11 |
# File 'app/models/barkest_core/auth_config.rb', line 9 def ldap_port @ldap_port end |
#ldap_ssl ⇒ Object
Returns the value of attribute ldap_ssl.
9 10 11 |
# File 'app/models/barkest_core/auth_config.rb', line 9 def ldap_ssl @ldap_ssl end |
#ldap_system_admin_groups ⇒ Object
Returns the value of attribute ldap_system_admin_groups.
9 10 11 |
# File 'app/models/barkest_core/auth_config.rb', line 9 def ldap_system_admin_groups @ldap_system_admin_groups end |
Class Method Details
.load ⇒ Object
Loads the configuration from the SystemConfig.
90 91 92 |
# File 'app/models/barkest_core/auth_config.rb', line 90 def AuthConfig.load AuthConfig.new(SystemConfig.get(:auth) || {}) end |
Instance Method Details
#enable_db_auth? ⇒ Boolean
Is DB authentication enabled?
43 44 45 |
# File 'app/models/barkest_core/auth_config.rb', line 43 def enable_db_auth? enable_db_auth.to_s.to_i != 0 end |
#enable_ldap_auth? ⇒ Boolean
Is LDAP authentication enabled?
49 50 51 |
# File 'app/models/barkest_core/auth_config.rb', line 49 def enable_ldap_auth? enable_ldap_auth.to_s.to_i != 0 end |
#ldap_auto_activate? ⇒ Boolean
Is automatic activation enabled for LDAP authenticated users?
61 62 63 |
# File 'app/models/barkest_core/auth_config.rb', line 61 def ldap_auto_activate? ldap_auto_activate.to_s.to_i != 0 end |
#ldap_ssl? ⇒ Boolean
Is SSL enabled for LDAP authentication?
55 56 57 |
# File 'app/models/barkest_core/auth_config.rb', line 55 def ldap_ssl? ldap_ssl.to_s.to_i != 0 end |
#save ⇒ Object
Saves the configuration (encrypted) to the SystemConfig.
84 85 86 |
# File 'app/models/barkest_core/auth_config.rb', line 84 def save SystemConfig.set :auth, to_h, true end |
#to_h ⇒ Object
Converts the configuration to a hash.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/models/barkest_core/auth_config.rb', line 67 def to_h { enable_db_auth: enable_db_auth?, enable_ldap_auth: enable_ldap_auth?, ldap_host: ldap_host.to_s, ldap_port: ldap_port.to_s.to_i, ldap_ssl: ldap_ssl?, ldap_base_dn: ldap_base_dn.to_s, ldap_browse_user: ldap_browse_user.to_s, ldap_browse_password: ldap_browse_password.to_s, ldap_auto_activate: ldap_auto_activate?, ldap_system_admin_groups: ldap_system_admin_groups.to_s, } end |