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.
86 87 88 |
# File 'lib/linzer/signer.rb', line 86 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 |
# File 'lib/linzer/signer.rb', line 70 def sign(key, , components, = {}) serialized_components = FieldId.serialize_components(Array(components)) validate key, , serialized_components parameters = populate_parameters(key, ) signature_base = signature_base(, serialized_components, parameters) signature = key.sign(signature_base) label = [:label] || DEFAULT_LABEL Linzer::Signature.build(serialize(signature, serialized_components, parameters, label)) end |