Class: Unmagic::Passkeys::WebAuthn::RelyingParty

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

Overview

Action Pack WebAuthn Relying Party

Represents the relying party (your application) in WebAuthn ceremonies. The relying party identity is sent to authenticators during registration and authentication to scope credentials to your application.

Usage

# Using defaults (host from Current, name from Rails application)
relying_party = Unmagic::Passkeys::WebAuthn::RelyingParty.new

# With explicit values
relying_party = Unmagic::Passkeys::WebAuthn::RelyingParty.new(
  id: "example.com",
  name: "Example Application"
)

Attributes

id

The relying party identifier, typically the application’s domain name (e.g., “example.com”). This must match the origin’s effective domain or be a registrable domain suffix of it. Credentials are scoped to this identifier. Defaults to Unmagic::Passkeys::WebAuthn::Current.host.

name

A human-readable name for your application, displayed by authenticators during ceremonies. Defaults to Rails.application.name.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: Unmagic::Passkeys::WebAuthn::Current.host, name: Rails.application.name) ⇒ RelyingParty

Creates a new relying party configuration.

Options

:id

Optional. The relying party identifier (domain).

:name

Optional. The application display name.



41
42
43
44
# File 'lib/unmagic/passkeys/web_authn/relying_party.rb', line 41

def initialize(id: Unmagic::Passkeys::WebAuthn::Current.host, name: Rails.application.name)
  @id = id
  @name = name
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



30
31
32
# File 'lib/unmagic/passkeys/web_authn/relying_party.rb', line 30

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



30
31
32
# File 'lib/unmagic/passkeys/web_authn/relying_party.rb', line 30

def name
  @name
end

Instance Method Details

#as_jsonObject

Returns a Hash suitable for JSON serialization.



47
48
49
# File 'lib/unmagic/passkeys/web_authn/relying_party.rb', line 47

def as_json(*)
  { id: id, name: name }
end