Module: Linzer::Signer
- Extended by:
- Common
- Defined in:
- lib/linzer/signer.rb
Overview
Handles HTTP message signing according to RFC 9421.
This module provides the core signing functionality. It creates signatures by computing a signature base from the message components and signing it with the provided key.
Constant Summary collapse
- DEFAULT_LABEL =
Default label used for signatures when none is specified.
"sig1"
Class Method Summary collapse
-
.default_label ⇒ String
Returns the default signature label.
-
.sign(key, message, components, options = {}) ⇒ Linzer::Signature
Signs an HTTP message.
Methods included from Common
signature_base, signature_base_line, signature_params_line
Class Method Details
.default_label ⇒ String
Returns the default signature label.
101 102 103 |
# File 'lib/linzer/signer.rb', line 101 def default_label DEFAULT_LABEL end |
.sign(key, message, components, options = {}) ⇒ Linzer::Signature
Signs an HTTP message.
Creates a signature by:
-
Serializing the component identifiers
-
Building the signature base from the message and parameters
-
Signing the signature base with the key
-
Returning a Signature object with the result
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/linzer/signer.rb', line 70 def sign(key, , components, = {}) serialized_components, field_ids = FieldId.serialize_components_with_field_ids(Array(components)) validate key, , serialized_components, field_ids: field_ids # Reuse the already-parsed items from field_ids parsed_items = field_ids.map(&:item) parameters = populate_parameters(key, ) signature_base = signature_base(, serialized_components, parameters, field_ids: field_ids) raw_signature = key.sign(signature_base) label = [:label] || DEFAULT_LABEL # Build the signature directly, bypassing the serialize -> parse round-trip headers = serialize(raw_signature, serialized_components, parameters, label) Linzer::Signature.from_components( components: serialized_components, raw_signature: raw_signature, label: label, parameters: parameters, parsed_items: parsed_items, headers: headers ) end |