NAME

WWW::Bund::Auth - Authentication management for Bund APIs

VERSION

version 0.001

SYNOPSIS

use WWW::Bund::Auth;

my $auth = WWW::Bund::Auth->new;

# Configure auth for API
$auth->set('my_api',
    type     => 'api_key',
    env_var  => 'MY_API_TOKEN',
    scheme   => 'Bearer',
);

# Get auth headers for request
my $headers = $auth->headers_for('my_api');
# { Authorization => 'Bearer TOKEN_VALUE' }

DESCRIPTION

Manages authentication configuration and header generation for APIs. Supports API key and OAuth2 authentication types.

Most bund.dev APIs require no authentication (type none), but this module is extensible for APIs that do.

set

$auth->set($api_id,
    type        => 'api_key',      # or 'oauth2', 'none'
    env_var     => 'MY_API_TOKEN',
    header_name => 'Authorization',
    scheme      => 'Bearer',
);

Configure authentication for an API. Returns the config HashRef.

Options:

  • type - 'api_key', 'oauth2', or 'none' (default: 'api_key')

  • env_var - Environment variable holding the token (required for api_key)

  • header_name - HTTP header name (default: 'Authorization')

  • scheme - Auth scheme for Authorization header (default: 'Bearer')

  • oauth_url - OAuth2 token URL (required for oauth2)

  • oauth_secret_env - Environment variable for OAuth2 secret

get

my $config = $auth->get($api_id);

Get auth config for an API. Returns HashRef. If not configured, returns { type =\ 'none' }>.

headers_for

my $headers = $auth->headers_for($api_id);

Generate HTTP headers for API authentication. Returns HashRef.

For api_key type, reads token from environment variable and formats according to scheme. For none type, returns empty HashRef.

Throws exception if required environment variable is not set.

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-www-bund/issues.

CONTRIBUTING

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

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus.

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