Class: Linzer::Signature::Profile::WebBotAuth
- Defined in:
- lib/linzer/signature/profile/web_bot_auth.rb
Overview
Web Bot Auth signing profile implementation.
This profile applies the behavior defined in the Web Bot Auth HTTP Message Signatures draft specification.
It mutates a signing context to ensure compliance with the spec requirements, including:
-
selection of required signature components
-
generation of nonce values
-
enforcement of Web Bot Auth signature parameters
-
optional Signature-Agent header injection
## Lifecycle
-
Context is created
-
Profile is resolved
-
#apply mutates signing context
-
signature is generated using modified context
Constant Summary collapse
- REQUIRED_AUTH_COMPONENTS =
%w[@authority @target-uri].freeze
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#nonce ⇒ Object
readonly
Returns the value of attribute nonce.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
-
.default ⇒ WebBotAuth
Returns a default Web Bot Auth profile instance.
Instance Method Summary collapse
-
#apply(ctx) ⇒ void
Applies the Web Bot Auth profile to a signing context.
-
#initialize(params: :recommended, nonce: :generate, agent: nil) ⇒ WebBotAuth
constructor
Creates a new Web Bot Auth signing profile.
Constructor Details
#initialize(params: :recommended, nonce: :generate, agent: nil) ⇒ WebBotAuth
Creates a new Web Bot Auth signing profile.
47 48 49 50 51 52 |
# File 'lib/linzer/signature/profile/web_bot_auth.rb', line 47 def initialize(params: :recommended, nonce: :generate, agent: nil) @params = params @nonce = nonce @agent = agent freeze end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
54 55 56 |
# File 'lib/linzer/signature/profile/web_bot_auth.rb', line 54 def agent @agent end |
#nonce ⇒ Object (readonly)
Returns the value of attribute nonce.
54 55 56 |
# File 'lib/linzer/signature/profile/web_bot_auth.rb', line 54 def nonce @nonce end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
54 55 56 |
# File 'lib/linzer/signature/profile/web_bot_auth.rb', line 54 def params @params end |
Class Method Details
.default ⇒ WebBotAuth
Returns a default Web Bot Auth profile instance.
This represents the standard recommended configuration:
-
recommended signature parameters enabled
-
nonce generation enabled
102 103 104 |
# File 'lib/linzer/signature/profile/web_bot_auth.rb', line 102 def self.default new(params: :recommended, nonce: :generate) end |
Instance Method Details
#apply(ctx) ⇒ void
This method returns an undefined value.
Applies the Web Bot Auth profile to a signing context.
This method mutates:
-
signature parameters (ctx.params)
-
covered components (ctx.components)
-
overlay headers (ctx.overlay_headers)
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/linzer/signature/profile/web_bot_auth.rb', line 74 def apply(ctx) validate ctx.key, ctx. if @params == :recommended set_params!(ctx.key, ctx.components, ctx.params) end ctx.params[:nonce] = generate_nonce if @nonce == :generate if @agent set_agent!( @agent, ctx.params[:label], ctx., ctx.components, ctx. ) end end |