Class: VaultConnection
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- VaultConnection
- Includes:
- Authorizable
- Defined in:
- app/models/vault_connection.rb
Instance Method Summary collapse
- #perform_renew_token ⇒ Object
- #renew_token! ⇒ Object
- #token_valid? ⇒ Boolean
- #with_approle? ⇒ Boolean
- #with_token? ⇒ Boolean
Instance Method Details
#perform_renew_token ⇒ Object
56 57 58 |
# File 'app/models/vault_connection.rb', line 56 def perform_renew_token RefreshVaultToken.perform_later(id) end |
#renew_token! ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'app/models/vault_connection.rb', line 47 def renew_token! client.renew_token save! rescue StandardError => e # rubocop:disable Rails/SkipsModelValidations update_column(:vault_error, e.) # rubocop:enable Rails/SkipsModelValidations end |
#token_valid? ⇒ Boolean
39 40 41 42 43 44 45 |
# File 'app/models/vault_connection.rb', line 39 def token_valid? return false unless with_token? return false unless vault_error.nil? return true unless expire_time expire_time > Time.zone.now end |
#with_approle? ⇒ Boolean
35 36 37 |
# File 'app/models/vault_connection.rb', line 35 def with_approle? role_id.present? && secret_id.present? end |
#with_token? ⇒ Boolean
31 32 33 |
# File 'app/models/vault_connection.rb', line 31 def with_token? token.present? end |