The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

WebService::SOP::Auth::V1_1::Util - SOP version 1.1 authentication handy utilities

SYNOPSIS

    use WebService::SOP::Auth::V1_1 qw(create_signature is_signature_valid);

When creating a signature:

    my $params = {
        app_id => 12345,
        app_mid => 'my-uniq-id-12345',
        time => 123456,
    };
    $params->{sig} = create_signature($params, $app_secret);
    #=> "$params" is signed with a valid HMAC SHA256 hash signature.

or when validating a signature:

    my $sig = delete $params->{sig};
    my $is_valid = is_signature_valid($sig, $params, $app_secret);
    #=> "$is_valid" is 1 if "sig" value is acceptable.

METHODS

create_signature( $params, $app_secret )

Creates a HMAC SHA256 hash signature. $params can either be a SCALAR or a HASH-ref.

create_string_from_hashref( $params )

Creates a string from parameters in type hashref.

is_signature_valid( $sig, $params, $app_secret, $time )

Validates if a signature is valid for given parameters. $time is optional where time() is used by default.

SEE ALSO

WebService::SOP::Auth::V1_1

LICENSE

Copyright (C) dataSpring, Inc. Copyright (C) Research Panel Asia, Inc.

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

AUTHOR

yowcow <yoko.oyama [ at ] d8aspring.com>