Module: Darrrr
- Includes:
- Constants
- Defined in:
- lib/darrrr/recovery_token.rb,
lib/darrrr.rb,
lib/darrrr/version.rb,
lib/darrrr/provider.rb,
lib/darrrr/constants.rb,
lib/darrrr/crypto_helper.rb,
lib/darrrr/account_provider.rb,
lib/darrrr/recovery_provider.rb,
lib/darrrr/cryptors/default/encrypted_data.rb,
lib/darrrr/cryptors/default/default_encryptor.rb,
lib/darrrr/cryptors/default/encrypted_data_io.rb,
lib/darrrr/serialization/recovery_token_reader.rb,
lib/darrrr/serialization/recovery_token_writer.rb
Overview
Handles binary serialization/deserialization of recovery token data. It does not manage signing/verification of tokens. Only account providers will ever call the decode function
Defined Under Namespace
Modules: Constants, CryptoHelper, DefaultEncryptor, Provider Classes: AccountProvider, CountersignedTokenError, CryptoError, DelegatedRecoveryError, EncryptedData, EncryptedDataIO, ProviderConfigError, RecoveryProvider, RecoveryToken, RecoveryTokenError, RecoveryTokenReader, RecoveryTokenSerializationError, RecoveryTokenWriter, TokenFormatError, UnknownProviderError
Constant Summary collapse
- VERSION =
"0.1.6"
Constants included from Constants
Constants::CLOCK_SKEW, Constants::COUNTERSIGNED_RECOVERY_TOKEN_TYPE, Constants::DIGEST, Constants::GROUP, Constants::PRIME_256_V1, Constants::PROTOCOL_VERSION, Constants::RECOVERY_TOKEN_TYPE, Constants::TOKEN_ID_BYTE_LENGTH, Constants::WELL_KNOWN_CONFIG_PATH
Class Attribute Summary collapse
-
.account_providers ⇒ Object
recovery provider data is only loaded (and cached) upon use.
-
.allow_unsafe_urls ⇒ Object
recovery provider data is only loaded (and cached) upon use.
-
.authority ⇒ Object
recovery provider data is only loaded (and cached) upon use.
-
.cache ⇒ Object
recovery provider data is only loaded (and cached) upon use.
-
.faraday_config_callback ⇒ Object
recovery provider data is only loaded (and cached) upon use.
-
.icon_152px ⇒ Object
recovery provider data is only loaded (and cached) upon use.
-
.privacy_policy ⇒ Object
recovery provider data is only loaded (and cached) upon use.
-
.recovery_providers ⇒ Object
recovery provider data is only loaded (and cached) upon use.
Class Method Summary collapse
-
.account_and_recovery_provider_config ⇒ Object
Returns a hash of all configuration values, recovery and account provider.
-
.account_provider(provider_origin, &block) ⇒ Object
Find and load remote account provider configuration data.
-
.account_provider_config ⇒ Object
returns the account provider information in hash form.
-
.recovery_provider(provider_origin) ⇒ Object
Find and load remote recovery provider configuration data.
-
.recovery_provider_config ⇒ Object
returns the account provider information in hash form.
-
.register_account_provider(account_origin) ⇒ Object
Permit an origin to act as an account provider.
-
.register_recovery_provider(provider_origin) ⇒ Object
Permit an origin to act as a recovery provider.
-
.this_account_provider ⇒ Object
Provide a reference to the account provider configuration for this web app.
-
.this_recovery_provider ⇒ Object
Provide a reference to the recovery provider configuration for this web app.
Class Attribute Details
.account_providers ⇒ Object
recovery provider data is only loaded (and cached) upon use.
60 61 62 |
# File 'lib/darrrr.rb', line 60 def account_providers @account_providers end |
.allow_unsafe_urls ⇒ Object
recovery provider data is only loaded (and cached) upon use.
60 61 62 |
# File 'lib/darrrr.rb', line 60 def allow_unsafe_urls @allow_unsafe_urls end |
.authority ⇒ Object
recovery provider data is only loaded (and cached) upon use.
60 61 62 |
# File 'lib/darrrr.rb', line 60 def @authority end |
.cache ⇒ Object
recovery provider data is only loaded (and cached) upon use.
60 61 62 |
# File 'lib/darrrr.rb', line 60 def cache @cache end |
.faraday_config_callback ⇒ Object
recovery provider data is only loaded (and cached) upon use.
60 61 62 |
# File 'lib/darrrr.rb', line 60 def faraday_config_callback @faraday_config_callback end |
.icon_152px ⇒ Object
recovery provider data is only loaded (and cached) upon use.
60 61 62 |
# File 'lib/darrrr.rb', line 60 def icon_152px @icon_152px end |
.privacy_policy ⇒ Object
recovery provider data is only loaded (and cached) upon use.
60 61 62 |
# File 'lib/darrrr.rb', line 60 def privacy_policy @privacy_policy end |
.recovery_providers ⇒ Object
recovery provider data is only loaded (and cached) upon use.
60 61 62 |
# File 'lib/darrrr.rb', line 60 def recovery_providers @recovery_providers end |
Class Method Details
.account_and_recovery_provider_config ⇒ Object
Returns a hash of all configuration values, recovery and account provider.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/darrrr.rb', line 125 def account_and_recovery_provider_config provider_data = Darrrr.this_account_provider&.to_h || {} if Darrrr.this_recovery_provider provider_data.merge!(recovery_provider_config) do |key, lhs, rhs| unless lhs == rhs raise ArgumentError, "inconsistent config value detected #{key}: #{lhs} != #{rhs}" end lhs end end provider_data end |
.account_provider(provider_origin, &block) ⇒ Object
Find and load remote account provider configuration data.
provider_origin: the origin that contains the config data in a well-known location.
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/darrrr.rb', line 93 def account_provider(provider_origin, &block) unless self.account_providers raise "No account providers configured" end if provider_origin == this_account_provider&.origin this_account_provider elsif self.account_providers.include?(provider_origin) AccountProvider.new(provider_origin).load else raise UnknownProviderError, "Unknown account provider: #{provider_origin}" end end |
.account_provider_config ⇒ Object
returns the account provider information in hash form
142 143 144 |
# File 'lib/darrrr.rb', line 142 def account_provider_config this_account_provider&.to_h end |
.recovery_provider(provider_origin) ⇒ Object
Find and load remote recovery provider configuration data.
provider_origin: the origin that contains the config data in a well-known location.
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/darrrr.rb', line 67 def recovery_provider(provider_origin) unless self.recovery_providers raise "No recovery providers configured" end if provider_origin == this_recovery_provider&.origin this_recovery_provider elsif self.recovery_providers.include?(provider_origin) RecoveryProvider.new(provider_origin).load else raise UnknownProviderError, "Unknown recovery provider: #{provider_origin}" end end |
.recovery_provider_config ⇒ Object
returns the account provider information in hash form
147 148 149 |
# File 'lib/darrrr.rb', line 147 def recovery_provider_config this_recovery_provider&.to_h end |
.register_account_provider(account_origin) ⇒ Object
Permit an origin to act as an account provider.
account_origin: the origin to permit
109 110 111 112 |
# File 'lib/darrrr.rb', line 109 def register_account_provider(account_origin) self.account_providers ||= [] self.account_providers << account_origin end |
.register_recovery_provider(provider_origin) ⇒ Object
Permit an origin to act as a recovery provider.
provider_origin: the origin to permit
84 85 86 87 |
# File 'lib/darrrr.rb', line 84 def register_recovery_provider(provider_origin) self.recovery_providers ||= [] self.recovery_providers << provider_origin end |
.this_account_provider ⇒ Object
Provide a reference to the account provider configuration for this web app
115 116 117 |
# File 'lib/darrrr.rb', line 115 def this_account_provider AccountProvider.this end |
.this_recovery_provider ⇒ Object
Provide a reference to the recovery provider configuration for this web app
120 121 122 |
# File 'lib/darrrr.rb', line 120 def this_recovery_provider RecoveryProvider.this end |