Apache2-API

 view release on metacpan or  search on metacpan

lib/Apache2/API.pm  view on Meta::CPAN


    # Without an Access-Control-Allow-Origin field, this would trigger an error on the web browser
    # So we make sure it is there if not set already
    unless( $resp->headers->get( 'Access-Control-Allow-Origin' ) )
    {
        $resp->headers->set( 'Access-Control-Allow-Origin' => '*' );
    }
    # As an api, make sure there is no caching by default unless the field has already been set.
    unless( $resp->headers->get( 'Cache-Control' ) )
    {
        $resp->headers->set( 'Cache-Control' => 'private, no-cache, no-store, must-revalidate' );
    }

    # If we have a locale set, we use it
    my $locale;
    if( $is_error )
    {
        if( $use_rfc_error )
        {
            $locale = $ref->{locale} if( exists( $ref->{locale} ) );
        }

lib/Apache2/API.pm  view on Meta::CPAN

    # By default, like Apache does, we use Apache md5 algorithm
    # Other possibilities are bcrypt (Blowfish)
    $self->SUPER::init( @_ ) ||
        return( $self->pass_error );
    if( $self->{create} )
    {
        my $hash = $self->make( $pwd ) ||
            return( $self->pass_error );
        $self->hash( $hash );
    }
    # Existing hash path: validate by known prefixes, also extract salt into ->salt
    elsif( $pwd =~ /\A$APR1_RE\z/ ||
           $pwd =~ /\A$BCRYPT_RE\z/ ||
           $pwd =~ /\A$SHA_RE\z/ )
    {
        $self->hash( $pwd );
    }
    else
    {
        return( $self->error(
            "Value provided is not a recognized hash (APR1/bcrypt/SHA-crypt). " .

lib/Apache2/API/Password.pod  view on Meta::CPAN

=head2 create

    $ht->create(1);
    my $bool = $ht->create;

Boolean flag indicating whether the constructor should create a new hash from the provided cleartext. Typically passed to C<new>.

=head2 hash

    my $hash = $ht->hash;
    # validate & set; also updates 'salt'
    $ht->hash( $crypt_hash );

Gets or sets the stored hash (e.g.: C<$apr1$>). Setting validates format and extracts metadata, such as C<salt>.

=head2 salt

    my $salt = $ht->salt;
    $ht->salt( 'abcd1234' );

Gets or sets the salt (1–8 chars in C<[./0-9A-Za-z]> for C<MD5>, 22 chars for C<bcrypt>, 1–16 chars for C<SHA-256/512>, alphabet C<[./0-9A-Za-z]>).

If an hash is provided upon object construction, its C<salt> will be derived, and stored.



( run in 0.675 second using v1.01-cache-2.11-cpan-2e29ac893d0 )