| 1 | package Langertha::Manifest::Auth; | ||||||||||
| 2 | # ABSTRACT: One auth mechanism of a provider manifest (type only, never a secret) | ||||||||||
| 3 | 8 | our $VERSION = '0.503'; | |||||||||
| 4 | 8 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 8 | with 'Langertha::Manifest::Validation'; | |||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | 8 | my @KNOWN_TYPES = qw( api_key ); | |||||||||
| 9 | 8 | my %KNOWN_TYPE = map { $_ => 1 } @KNOWN_TYPES; | |||||||||
| 10 | |||||||||||
| 11 | 8 | has id => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||
| 12 | 8 | has type => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||
| 13 | |||||||||||
| 14 | |||||||||||
| 15 | 84 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 16 | 84 | my ($self) = @_; | |||||||||
| 17 | 84 | $self->_check_id( 'id', $self->id ); | |||||||||
| 18 | 84 | $self->_check_token( 'type', $self->type ); | |||||||||
| 19 | 83 | return; | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | sub known_types { return @KNOWN_TYPES } | ||||||||
|
Subroutine
known_types: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | 2 | ▶ | sub is_known_type { return $KNOWN_TYPE{ $_[0]->type } ? 1 : 0 } | ||||||||
|
Subroutine
is_known_type: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||
| 26 | |||||||||||
| 27 | |||||||||||
| 28 | 62 | ▶ | sub from_hash { | ||||||||
|
Subroutine
from_hash: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 29 | 62 | my ( $class, $data ) = @_; | |||||||||
| 30 | 62 | $class->_check_fields( $data, required => [qw( id type )] ); | |||||||||
| 31 | 57 | return $class->new( map { $_ => $class->_string( $_, $data->{$_} ) } qw( id type ) ); | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | |||||||||||
| 35 | 21 | ▶ | sub to_hash { | ||||||||
|
Subroutine
to_hash: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 36 | 21 | my ($self) = @_; | |||||||||
| 37 | 21 | return { id => $self->id, type => $self->type }; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | sub TO_JSON { shift->to_hash } | ||||||||
|
Subroutine
TO_JSON: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 42 | |||||||||||
| 43 | 8 | __PACKAGE__->meta->make_immutable; | |||||||||
| 44 | |||||||||||
| 45 | |||||||||||
| 46 | 8 | 1; | |||||||||
| 47 | |||||||||||
| 48 | __END__ | ||||||||||
| 49 | |||||||||||
| 50 | =pod | ||||||||||
| 51 | |||||||||||
| 52 | =encoding UTF-8 | ||||||||||
| 53 | |||||||||||
| 54 | =head1 NAME | ||||||||||
| 55 | |||||||||||
| 56 | Langertha::Manifest::Auth - One auth mechanism of a provider manifest (type only, never a secret) | ||||||||||
| 57 | |||||||||||
| 58 | =head1 VERSION | ||||||||||
| 59 | |||||||||||
| 60 | version 0.503 | ||||||||||
| 61 | |||||||||||
| 62 | =head1 SYNOPSIS | ||||||||||
| 63 | |||||||||||
| 64 | my $auth = Langertha::Manifest::Auth->new( id => 'api', type => 'api_key' ); | ||||||||||
| 65 | |||||||||||
| 66 | =head1 DESCRIPTION | ||||||||||
| 67 | |||||||||||
| 68 | An auth entry of a L<Langertha::Manifest>. It names a B<mechanism> only. It | ||||||||||
| 69 | never holds a key, a secret path or an environment-variable name: which | ||||||||||
| 70 | local credential feeds the mechanism is the client's decision. The | ||||||||||
| 71 | header/query contract (C<Authorization: Bearer>, C<x-api-key>, C<?key=>, …) | ||||||||||
| 72 | belongs to the endpoint's dialect, not to this entry. | ||||||||||
| 73 | |||||||||||
| 74 | =head2 id | ||||||||||
| 75 | |||||||||||
| 76 | Local id, unique within the manifest; endpoints point at it with | ||||||||||
| 77 | C<auth_ref>. | ||||||||||
| 78 | |||||||||||
| 79 | =head2 type | ||||||||||
| 80 | |||||||||||
| 81 | Mechanism token (see L</known_types>). A pattern-valid but unknown type is | ||||||||||
| 82 | accepted; L</is_known_type> tells a client whether it can serve it. | ||||||||||
| 83 | |||||||||||
| 84 | =head2 known_types | ||||||||||
| 85 | |||||||||||
| 86 | The v1 auth-type vocabulary: C<api_key>. | ||||||||||
| 87 | |||||||||||
| 88 | =head2 is_known_type | ||||||||||
| 89 | |||||||||||
| 90 | True when L</type> is in the v1 vocabulary. | ||||||||||
| 91 | |||||||||||
| 92 | =head2 from_hash | ||||||||||
| 93 | |||||||||||
| 94 | Builds an auth entry from its JSON object form, rejecting unknown and | ||||||||||
| 95 | forbidden fields (a key, token, secret path or env-var name is forbidden). | ||||||||||
| 96 | |||||||||||
| 97 | =head2 to_hash | ||||||||||
| 98 | |||||||||||
| 99 | Returns the JSON object form. | ||||||||||
| 100 | |||||||||||
| 101 | =head1 SEE ALSO | ||||||||||
| 102 | |||||||||||
| 103 | =over | ||||||||||
| 104 | |||||||||||
| 105 | =item * L<Langertha::Manifest> - The provider manifest | ||||||||||
| 106 | |||||||||||
| 107 | =back | ||||||||||
| 108 | |||||||||||
| 109 | =head1 SUPPORT | ||||||||||
| 110 | |||||||||||
| 111 | =head2 Issues | ||||||||||
| 112 | |||||||||||
| 113 | Please report bugs and feature requests on GitHub at | ||||||||||
| 114 | L<https://github.com/Getty/langertha/issues>. | ||||||||||
| 115 | |||||||||||
| 116 | =head2 IRC | ||||||||||
| 117 | |||||||||||
| 118 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||||||||||
| 119 | |||||||||||
| 120 | =head1 CONTRIBUTING | ||||||||||
| 121 | |||||||||||
| 122 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||
| 123 | |||||||||||
| 124 | =head1 AUTHOR | ||||||||||
| 125 | |||||||||||
| 126 | Torsten Raudssus <getty@cpan.org> | ||||||||||
| 127 | |||||||||||
| 128 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 129 | |||||||||||
| 130 | This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>. | ||||||||||
| 131 | |||||||||||
| 132 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 133 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 134 | |||||||||||
| 135 | =cut | ||||||||||