Class: Unmagic::Passkeys::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/unmagic/passkeys/configuration.rb

Overview

Central configuration for the passkeys engine, set through a single Unmagic::Passkeys.configure block. The defaults here are the single source of truth — there is no separate Rails engine config.

# config/initializers/passkeys.rb
Unmagic::Passkeys.configure do |config|
config.relying_party_name           = "Shopping"
config.request_challenge_expiration  = 5.minutes
config.default_request_options       = { user_verification: :required }
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Configuration

Returns a new instance of Configuration.



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/unmagic/passkeys/configuration.rb', line 40

def initialize
  @parent_class_name = "ApplicationRecord"
  @routes_prefix = "/auth/passkeys"
  @draw_routes = true
  @challenge_url = nil
  @default_creation_options = {}
  @default_request_options = {}
  @creation_challenge_expiration = 10.minutes
  @request_challenge_expiration = 5.minutes
  @relying_party_id = nil
  @relying_party_name = nil
end

Instance Attribute Details

#challenge_url ⇒ Object

Optional callable, +instance_exec+'d in the view, returning the URL the form helpers point the challenge fetch at. Defaults to the engine's challenge path when nil.



27
28
29
# File 'lib/unmagic/passkeys/configuration.rb', line 27

def challenge_url
  @challenge_url
end

#creation_challenge_expiration ⇒ Object

How long an issued challenge stays valid, per ceremony.



34
35
36
# File 'lib/unmagic/passkeys/configuration.rb', line 34

def creation_challenge_expiration
  @creation_challenge_expiration
end

#default_creation_options ⇒ Object

Global option defaults merged into every registration / authentication ceremony.



31
32
33
# File 'lib/unmagic/passkeys/configuration.rb', line 31

def default_creation_options
  @default_creation_options
end

#default_request_options ⇒ Object

Global option defaults merged into every registration / authentication ceremony.



31
32
33
# File 'lib/unmagic/passkeys/configuration.rb', line 31

def default_request_options
  @default_request_options
end

#draw_routes ⇒ Object

Where the stateless challenge endpoint is mounted, and whether the engine draws it at all. Override these in config/application.rb if you need them applied before the engine draws its routes.



22
23
24
# File 'lib/unmagic/passkeys/configuration.rb', line 22

def draw_routes
  @draw_routes
end

#parent_class_name ⇒ Object

The Active Record base class the Credential model inherits from.



17
18
19
# File 'lib/unmagic/passkeys/configuration.rb', line 17

def parent_class_name
  @parent_class_name
end

#relying_party_id ⇒ Object

Relying party identity. When nil, falls back to the request host and Rails.application.name respectively.



38
39
40
# File 'lib/unmagic/passkeys/configuration.rb', line 38

def relying_party_id
  @relying_party_id
end

#relying_party_name ⇒ Object

Relying party identity. When nil, falls back to the request host and Rails.application.name respectively.



38
39
40
# File 'lib/unmagic/passkeys/configuration.rb', line 38

def relying_party_name
  @relying_party_name
end

#request_challenge_expiration ⇒ Object

How long an issued challenge stays valid, per ceremony.



34
35
36
# File 'lib/unmagic/passkeys/configuration.rb', line 34

def request_challenge_expiration
  @request_challenge_expiration
end

#routes_prefix ⇒ Object

Where the stateless challenge endpoint is mounted, and whether the engine draws it at all. Override these in config/application.rb if you need them applied before the engine draws its routes.



22
23
24
# File 'lib/unmagic/passkeys/configuration.rb', line 22

def routes_prefix
  @routes_prefix
end