Class: PasskeysRails::Configuration
- Inherits:
-
Object
- Object
- PasskeysRails::Configuration
- Defined in:
- lib/passkeys_rails/configuration.rb
Instance Attribute Summary collapse
-
#auth_token_algorithm ⇒ Object
Algorithm used to generate the auth token.
-
#auth_token_expires_in ⇒ Object
How long the auth token is valid before requiring a refresh or new login.
-
#auth_token_secret ⇒ Object
Secret used to encode the auth token.
-
#class_whitelist ⇒ Object
By providing a class_whitelist, the API will require that any supplied class is in the whitelist.
-
#default_class ⇒ Object
Model to use when creating or authenticating a passkey.
-
#wa_algorithm ⇒ Object
webauthn settings.
-
#wa_algorithms ⇒ Object
webauthn settings.
-
#wa_credential_options_timeout ⇒ Object
webauthn settings.
-
#wa_encoding ⇒ Object
webauthn settings.
-
#wa_origin ⇒ Object
webauthn settings.
-
#wa_relying_party_name ⇒ Object
webauthn settings.
-
#wa_rp_id ⇒ Object
webauthn settings.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #subscribe(event_name) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
49 50 51 52 53 54 55 56 |
# File 'lib/passkeys_rails/configuration.rb', line 49 def initialize # defaults @auth_token_secret = Rails.application.secret_key_base @auth_token_algorithm = "HS256" @auth_token_expires_in = 30.days @default_class = "User" @wa_origin = "https://example.com" end |
Instance Attribute Details
#auth_token_algorithm ⇒ Object
Algorithm used to generate the auth token. Changing this value will invalidate all tokens that have been fetched through the API.
12 13 14 |
# File 'lib/passkeys_rails/configuration.rb', line 12 def auth_token_algorithm @auth_token_algorithm end |
#auth_token_expires_in ⇒ Object
How long the auth token is valid before requiring a refresh or new login. Set it to 0 for no expiration (not recommended in production).
16 17 18 |
# File 'lib/passkeys_rails/configuration.rb', line 16 def auth_token_expires_in @auth_token_expires_in end |
#auth_token_secret ⇒ Object
Secret used to encode the auth token. Rails.application.secret_key_base is used if none is defined here. Changing this value will invalidate all tokens that have been fetched through the API.
7 8 9 |
# File 'lib/passkeys_rails/configuration.rb', line 7 def auth_token_secret @auth_token_secret end |
#class_whitelist ⇒ Object
By providing a class_whitelist, the API will require that any supplied class is in the whitelist. If it is not, the auth API will return an error. This prevents a caller from attempting to create an unintended record on registration. If nil, any model will be allowed. If [], no model will be allowed. This should be an array of symbols or strings, for example: %w[User AdminUser]
38 39 40 |
# File 'lib/passkeys_rails/configuration.rb', line 38 def class_whitelist @class_whitelist end |
#default_class ⇒ Object
Model to use when creating or authenticating a passkey. This can be overridden when calling the API, but if no value is supplied when calling the API, this value is used. If nil, there is no default, and if none is supplied when calling the API, no resource is created other than a PaskeysRails::Agent that is used to track the passkey.
This library doesn’t assume that there will only be one model, but it is a common use case, so setting the default_class simplifies the use of the API in that case.
28 29 30 |
# File 'lib/passkeys_rails/configuration.rb', line 28 def default_class @default_class end |
#wa_algorithm ⇒ Object
webauthn settings
41 42 43 |
# File 'lib/passkeys_rails/configuration.rb', line 41 def wa_algorithm @wa_algorithm end |
#wa_algorithms ⇒ Object
webauthn settings
41 42 43 |
# File 'lib/passkeys_rails/configuration.rb', line 41 def wa_algorithms @wa_algorithms end |
#wa_credential_options_timeout ⇒ Object
webauthn settings
41 42 43 |
# File 'lib/passkeys_rails/configuration.rb', line 41 def @wa_credential_options_timeout end |
#wa_encoding ⇒ Object
webauthn settings
41 42 43 |
# File 'lib/passkeys_rails/configuration.rb', line 41 def wa_encoding @wa_encoding end |
#wa_origin ⇒ Object
webauthn settings
41 42 43 |
# File 'lib/passkeys_rails/configuration.rb', line 41 def wa_origin @wa_origin end |
#wa_relying_party_name ⇒ Object
webauthn settings
41 42 43 |
# File 'lib/passkeys_rails/configuration.rb', line 41 def @wa_relying_party_name end |
#wa_rp_id ⇒ Object
webauthn settings
41 42 43 |
# File 'lib/passkeys_rails/configuration.rb', line 41 def wa_rp_id @wa_rp_id end |
Instance Method Details
#subscribe(event_name) ⇒ Object
58 59 60 |
# File 'lib/passkeys_rails/configuration.rb', line 58 def subscribe(event_name) PasskeysRails.subscribe(event_name) end |