NAME

Mojo::UserAgent::Signature::Base - Signature base class

SYNOPSIS

package Mojo::UserAgent::Signature::SomeService;
use Mojo::Base 'Mojo::UserAgent::Signature::Base;

sub sign_tx {
  my ($self, $tx, $args) = @_;

  # Magic here! :)
}

DESCRIPTION

Mojo::UserAgent::Signature::Base is an abstract base class for Mojo::UserAgent signatures.

METHODS

Mojo::UserAgent::Signature::Base inherits all methods from Mojo::UserAgent::Signature and implements the following new ones.

apply_signature

$signed_tx = $signature->apply_signature($tx, $args);

Applies the signature produced by "sign_tx" to Mojo::UserAgent transaction. Also adds a header to the transaction, X-Mojo-Signature: SomeService, to indicate that this transaction has been signed -- this prevents the automatic signature handling from applying the signature a second time, after the generator.

init

$signature = $signature->init($ua);

Adds a transactor generator named sign to the supplied $ua instance for applying a signature to a transaction. Useful for overriding the signature details in the "signature" instance.

Another generator can follow the use of the sign generator.

$ua->get($url => sign => {%args});

sign_tx

$signed_tx = $signature->sign_tx($tx, {%args});

This method will be called by "apply_signature", either automatically when the transaction is built, or explicitly via the transaction generator. Meant to be overloaded in a subclass.

COPYRIGHT AND LICENSE

Copyright (C) 2020, Stefan Adams.

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.

SEE ALSO

https://github.com/stefanadams/mojo-useragent-role-signature, Mojo::UserAgent.