NAME

Net::Async::Authentik::Role::HTTP - Sending requests to authentik through Net::Async::HTTP

VERSION

version 0.001

DESCRIPTION

The asynchronous counterpart of WWW::Authentik::Role::HTTP. Requests are built and responses read by that role's build_request and read_response, so both clients map authentik's answers the same way; this role only sends, through Net::Async::HTTP, and returns futures.

Consume it before WWW::Authentik::Role::HTTP: its error class methods then win and the errors are this distribution's subclasses.

with 'Net::Async::Authentik::Role::HTTP';
with 'WWW::Authentik::Role::HTTP';

The consuming class has an http attribute holding a Net::Async::HTTP.

api_error_class

network_error_class

validation_error_class

The classes a failed future fails with. They override the synchronous role's, which is why this role is composed first.

fail_validation

return $self->fail_validation('a client_id is needed');

A failed future with a validation error. Nothing in this distribution throws: a wrong argument fails the future the caller is already holding.

pairs_or_fail

my ( $ok, $arg ) = $self->pairs_or_fail( 1, @_ );
return $self->fail_validation('...') unless $ok;

Takes the number of positional arguments and the whole argument list, and gives back whether what follows them makes pairs, and those pairs as a hash reference. Every method that would hold such a hash across an await asks first: Future::AsyncAwait 0.71 corrupts memory when a suspended frame holds a hash built from an odd-sized list whose dangling element is a reference.

send_request_f

$self->send_request_f( POST => $url, json => \%body, bearer => $token )->then( sub {
  my ( $result ) = @_;   # status, data, location, content
  ...
} );

Sends one request. Fails with Net::Async::Authentik::Error::Network when no answer came back and with Net::Async::Authentik::Error::API for any status of 400 and above. Anything below 400 is an answer, including the 302 authentik gives where it wants a browser.

A body the JSON codec cannot encode fails with Net::Async::Authentik::Error::Validation, rather than throwing out of a method the caller expected a future from.

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-net-async-authentik/issues.

IRC

Join #kubernetes on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <getty@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.