Class: Authify::API::Models::TrustedDelegate
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Authify::API::Models::TrustedDelegate
- Extended by:
- Core::SecureHashing
- Includes:
- Core::SecureHashing
- Defined in:
- lib/authify/api/models/trusted_delegate.rb
Overview
Trusted Delegates are remote applications that can do anything
Instance Attribute Summary collapse
-
#secret_key ⇒ Object
Returns the value of attribute secret_key.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#secret_key ⇒ Object
Returns the value of attribute secret_key.
9 10 11 |
# File 'lib/authify/api/models/trusted_delegate.rb', line 9 def secret_key @secret_key end |
Class Method Details
.from_access_key(access, secret) ⇒ Object
31 32 33 34 |
# File 'lib/authify/api/models/trusted_delegate.rb', line 31 def self.from_access_key(access, secret) trusted_delegate = find_by_access_key(access) trusted_delegate if trusted_delegate && trusted_delegate.compare_secret(secret) end |
.generate_access_key ⇒ Object
27 28 29 |
# File 'lib/authify/api/models/trusted_delegate.rb', line 27 def self.generate_access_key to_hex(SecureRandom.gen_random(48))[0...48] end |
Instance Method Details
#compare_secret(unencrypted_string) ⇒ Object
19 20 21 |
# File 'lib/authify/api/models/trusted_delegate.rb', line 19 def compare_secret(unencrypted_string) compare_salted_sha512(unencrypted_string, secret_key_digest) end |
#set_secret! ⇒ Object
23 24 25 |
# File 'lib/authify/api/models/trusted_delegate.rb', line 23 def set_secret! self.secret_key = self.class.generate_access_key + self.class.generate_access_key end |