Class: Proxy::AdRealm::Provider
- Inherits:
-
Object
- Object
- Proxy::AdRealm::Provider
- Includes:
- Kerberos, Log, Util
- Defined in:
- lib/smart_proxy_realm_ad/provider.rb
Instance Attribute Summary collapse
-
#computername_hash ⇒ Object
readonly
Returns the value of attribute computername_hash.
-
#computername_prefix ⇒ Object
readonly
Returns the value of attribute computername_prefix.
-
#computername_use_fqdn ⇒ Object
readonly
Returns the value of attribute computername_use_fqdn.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#domain_controller ⇒ Object
readonly
Returns the value of attribute domain_controller.
-
#keytab_path ⇒ Object
readonly
Returns the value of attribute keytab_path.
-
#ou ⇒ Object
readonly
Returns the value of attribute ou.
-
#principal ⇒ Object
readonly
Returns the value of attribute principal.
-
#realm ⇒ Object
readonly
Returns the value of attribute realm.
Instance Method Summary collapse
- #check_realm(realm) ⇒ Object
- #create(realm, hostfqdn, params) ⇒ Object
- #delete(realm, hostfqdn) ⇒ Object
- #find(_hostfqdn) ⇒ Object
-
#initialize(options = {}) ⇒ Provider
constructor
A new instance of Provider.
Constructor Details
#initialize(options = {}) ⇒ Provider
Returns a new instance of Provider.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/smart_proxy_realm_ad/provider.rb', line 13 def initialize( = {}) @realm = [:realm] @keytab_path = [:keytab_path] @principal = [:principal] @domain_controller = [:domain_controller] @domain = [:realm].downcase @ou = [:ou] @computername_prefix = [:computername_prefix] @computername_hash = .fetch(:computername_hash, false) @computername_use_fqdn = .fetch(:computername_use_fqdn, false) logger.info 'Proxy::AdRealm: initialize...' end |
Instance Attribute Details
#computername_hash ⇒ Object (readonly)
Returns the value of attribute computername_hash.
11 12 13 |
# File 'lib/smart_proxy_realm_ad/provider.rb', line 11 def computername_hash @computername_hash end |
#computername_prefix ⇒ Object (readonly)
Returns the value of attribute computername_prefix.
11 12 13 |
# File 'lib/smart_proxy_realm_ad/provider.rb', line 11 def computername_prefix @computername_prefix end |
#computername_use_fqdn ⇒ Object (readonly)
Returns the value of attribute computername_use_fqdn.
11 12 13 |
# File 'lib/smart_proxy_realm_ad/provider.rb', line 11 def computername_use_fqdn @computername_use_fqdn end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
11 12 13 |
# File 'lib/smart_proxy_realm_ad/provider.rb', line 11 def domain @domain end |
#domain_controller ⇒ Object (readonly)
Returns the value of attribute domain_controller.
11 12 13 |
# File 'lib/smart_proxy_realm_ad/provider.rb', line 11 def domain_controller @domain_controller end |
#keytab_path ⇒ Object (readonly)
Returns the value of attribute keytab_path.
11 12 13 |
# File 'lib/smart_proxy_realm_ad/provider.rb', line 11 def keytab_path @keytab_path end |
#ou ⇒ Object (readonly)
Returns the value of attribute ou.
11 12 13 |
# File 'lib/smart_proxy_realm_ad/provider.rb', line 11 def ou @ou end |
#principal ⇒ Object (readonly)
Returns the value of attribute principal.
11 12 13 |
# File 'lib/smart_proxy_realm_ad/provider.rb', line 11 def principal @principal end |
#realm ⇒ Object (readonly)
Returns the value of attribute realm.
11 12 13 |
# File 'lib/smart_proxy_realm_ad/provider.rb', line 11 def realm @realm end |
Instance Method Details
#check_realm(realm) ⇒ Object
26 27 28 |
# File 'lib/smart_proxy_realm_ad/provider.rb', line 26 def check_realm(realm) raise Exception, "Unknown realm #{realm}" unless realm.casecmp(@realm).zero? end |
#create(realm, hostfqdn, params) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/smart_proxy_realm_ad/provider.rb', line 34 def create(realm, hostfqdn, params) logger.info "Proxy::AdRealm: create... #{realm}, #{hostfqdn}, #{params}" check_realm(realm) kinit_radcli_connect password = generate_password result = { randompassword: password } computername = hostfqdn_to_computername(hostfqdn) if params[:rebuild] == 'true' radcli_password(computername, password) else radcli_join(hostfqdn, computername, password) end JSON.pretty_generate(result) end |
#delete(realm, hostfqdn) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/smart_proxy_realm_ad/provider.rb', line 53 def delete(realm, hostfqdn) logger.info "Proxy::AdRealm: delete... #{realm}, #{hostfqdn}" kinit_radcli_connect check_realm(realm) computername = hostfqdn_to_computername(hostfqdn) radcli_delete(computername) end |
#find(_hostfqdn) ⇒ Object
30 31 32 |
# File 'lib/smart_proxy_realm_ad/provider.rb', line 30 def find(_hostfqdn) true end |