Module: Roda::RodaPlugins::HmacPaths::RequestMethods
- Defined in:
- lib/roda/plugins/hmac_paths.rb
Instance Method Summary collapse
-
#hmac_path(opts = OPTS, &block) ⇒ Object
Looks at the first segment of the remaining path, and if it contains a valid HMAC for the rest of the path considering the flags in the second segment and the given options, the block matches and is yielded to, and the result of the block is returned.
Instance Method Details
#hmac_path(opts = OPTS, &block) ⇒ Object
Looks at the first segment of the remaining path, and if it contains a valid HMAC for the rest of the path considering the flags in the second segment and the given options, the block matches and is yielded to, and the result of the block is returned. Otherwise, the block does not matches and routing continues after the call.
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
# File 'lib/roda/plugins/hmac_paths.rb', line 340 def hmac_path(opts=OPTS, &block) orig_path = remaining_path mpath = matched_path on String do |submitted_hmac| rpath = remaining_path if submitted_hmac.bytesize == 64 on String do |flags| if flags.bytesize >= 1 if flags.include?('n') ^ !scope.hmac_path_namespace(opts).nil? # Namespace required and not provided, or provided and not required. # Bail early to avoid unnecessary HMAC calculation. @remaining_path = orig_path return end if flags.include?('m') rpath = "#{env['REQUEST_METHOD'].to_s.upcase}:#{rpath}" end if flags.include?('p') rpath = "#{rpath}?#{env["QUERY_STRING"]}" end if hmac_path_valid?(mpath, rpath, submitted_hmac, opts) if flags.include?('t') on Integer do |int| if int >= Time.now.to_i always(&block) else # Return from method without matching @remaining_path = orig_path return end end else always(&block) end end end # Return from method without matching @remaining_path = orig_path return end end # Return from method without matching @remaining_path = orig_path return end end |