view release on metacpan or search on metacpan
lib/Steemit/WsClient.pm view on Meta::CPAN
use Data::Dumper;
has url => 'https://api.steemit.com/';
has ua => sub { Mojo::UserAgent->new };
has posting_key => undef;
has plain_posting_key => \&_transform_private_key;
=head2 all database api methods of the steemit api
L<https://github.com/steemit/steem/blob/master/libraries/app/database_api.cpp>
lib/Steemit/WsClient.pm view on Meta::CPAN
extensions => [],
signatures => [],
};
my $serialized_transaction = $self->_serialize_transaction_message( $transaction );
my $bin_private_key = $self->plain_posting_key;
require Steemit::ECDSA;
my ( $r, $s, $i ) = Steemit::ECDSA::ecdsa_sign( $serialized_transaction, Math::BigInt->from_bytes( $bin_private_key ) );
$i += 4;
$i += 27;
my $signature = join('', map { unpack 'H*', $_ } ( pack("C", $i ), map { $_->as_bytes} ($r,$s )) );
unless( Steemit::ECDSA::is_signature_canonical_canonical( pack "H*", $signature ) ){
lib/Steemit/WsClient.pm view on Meta::CPAN
return $self->{public_posting_key}
}
sub _transform_private_key {
my( $self ) = @_;
die "posting_key missing" unless( $self->posting_key );
my $base58 = $self->posting_key;
require Steemit::Base58;
my $binary = Steemit::Base58::decode_base58( $base58 );
my $version = substr( $binary, 0, 1 );
my $binary_private_key = substr( $binary, 1, -4);
my $checksum = substr( $binary, -4);
die "invalid version in wif ( 0x80 needed ) " unless $version eq pack "H*", '80';
require Digest::SHA;
my $generated_checksum = substr( Digest::SHA::sha256( Digest::SHA::sha256( $version.$binary_private_key )), 0, 4 );
die "invalid checksum " unless $generated_checksum eq $checksum;
return $binary_private_key;
}
sub _serialize_transaction_message {
my ($self,$transaction) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Syntax/Highlight/Engine/Kate/PHP_PHP.pm view on Meta::CPAN
'openssl_public_decrypt',
'openssl_public_encrypt',
'openssl_seal',
'openssl_sign',
'openssl_verify',
'openssl_x509_check_private_key',
'openssl_x509_checkpurpose',
'openssl_x509_export',
'openssl_x509_export_to_file',
'openssl_x509_free',
'openssl_x509_parse',
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Syntax/Highlight/Universal/hrc/inet/php-gen.hrc view on Meta::CPAN
<word name="openssl_public_encrypt"/>
<word name="openssl_seal"/>
<word name="openssl_sign"/>
<word name="openssl_verify"/>
<word name="openssl_x509_checkpurpose"/>
<word name="openssl_x509_check_private_key"/>
<word name="openssl_x509_export"/>
<word name="openssl_x509_export_to_file"/>
<word name="openssl_x509_free"/>
<word name="openssl_x509_parse"/>
<word name="openssl_x509_read"/>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Syntax/Kamelon/XML/php.xml view on Meta::CPAN
<item>openssl_public_decrypt</item>
<item>openssl_public_encrypt</item>
<item>openssl_seal</item>
<item>openssl_sign</item>
<item>openssl_verify</item>
<item>openssl_x509_check_private_key</item>
<item>openssl_x509_checkpurpose</item>
<item>openssl_x509_export</item>
<item>openssl_x509_export_to_file</item>
<item>openssl_x509_free</item>
<item>openssl_x509_parse</item>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Test/SSH.pm view on Meta::CPAN
Location used to save data bewteen runs (i.e. generated user and host
key pairs).
The default is C<~/.libtest-ssh-perl>
=item private_keys =E<gt> \@key_paths
List of private keys that will be used for login into the remote host.
The default is to look for keys in C<~/.ssh>.
view all matches for this distribution
view release on metacpan or search on metacpan
utils/remote_detect_launcher.pl view on Meta::CPAN
use JSON;
# NOT finished
my $key_path = "$ENV{HOME}/.ssh/id_rsa.pub";
my $private_key = "$ENV{HOME}/.ssh/id_rsa";
# Local folders
my $log_dir = "../remote_logs";
my $output_dir = "../logs";
make_path($log_dir) unless -d $log_dir;
utils/remote_detect_launcher.pl view on Meta::CPAN
);
# Step 1: Ensure SSH key exists
unless (-e $key_path) {
print colored("No SSH key found, generating...\n", 'yellow');
system("ssh-keygen -t rsa -b 4096 -f $private_key -N ''");
}
# Step 2: Loop over each target
for my $host (@targets) {
my ($ip, $user) = ($host->{ip}, $host->{user});
view all matches for this distribution
view release on metacpan or search on metacpan
ext/uid2-client-cpp11/lib/external/httplib.h view on Meta::CPAN
};
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
class SSLServer : public Server {
public:
SSLServer(const char* cert_path, const char* private_key_path,
const char* client_ca_cert_file_path = nullptr,
const char* client_ca_cert_dir_path = nullptr);
SSLServer(X509* cert, EVP_PKEY* private_key,
X509_STORE* client_ca_cert_store = nullptr);
~SSLServer() override;
bool is_valid() const override;
ext/uid2-client-cpp11/lib/external/httplib.h view on Meta::CPAN
static SSLInit sslinit_;
} // namespace detail
// SSL HTTP server implementation
inline SSLServer::SSLServer(const char* cert_path, const char* private_key_path,
const char* client_ca_cert_file_path,
const char* client_ca_cert_dir_path) {
ctx_ = SSL_CTX_new(SSLv23_server_method());
if (ctx_) {
ext/uid2-client-cpp11/lib/external/httplib.h view on Meta::CPAN
// auto ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
// SSL_CTX_set_tmp_ecdh(ctx_, ecdh);
// EC_KEY_free(ecdh);
if (SSL_CTX_use_certificate_chain_file(ctx_, cert_path) != 1 ||
SSL_CTX_use_PrivateKey_file(ctx_, private_key_path, SSL_FILETYPE_PEM) !=
1) {
SSL_CTX_free(ctx_);
ctx_ = nullptr;
}
else if (client_ca_cert_file_path || client_ca_cert_dir_path) {
ext/uid2-client-cpp11/lib/external/httplib.h view on Meta::CPAN
nullptr);
}
}
}
inline SSLServer::SSLServer(X509* cert, EVP_PKEY* private_key,
X509_STORE* client_ca_cert_store) {
ctx_ = SSL_CTX_new(SSLv23_server_method());
if (ctx_) {
SSL_CTX_set_options(ctx_,
SSL_OP_ALL | SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 |
SSL_OP_NO_COMPRESSION |
SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
if (SSL_CTX_use_certificate(ctx_, cert) != 1 ||
SSL_CTX_use_PrivateKey(ctx_, private_key) != 1) {
SSL_CTX_free(ctx_);
ctx_ = nullptr;
}
else if (client_ca_cert_store) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/URI/Amazon/APA.pm view on Meta::CPAN
Title => shift || 'Perl',
SearchIndex => 'Books',
);
$u->sign(
key => $public_key,
secret => $private_key,
);
my $ua = LWP::UserAgent->new;
my $r = $ua->get($u);
if ( $r->is_success ) {
lib/URI/Amazon/APA.pm view on Meta::CPAN
Sings the URI accordingly to the Amazon Product Advertising API.
$u->sign(
key => $public_key,
secret => $private_key,
);
=head2 signature
Checks the signature within the URI;
view all matches for this distribution
view release on metacpan or search on metacpan
clib/tests/lib/test.cc view on Meta::CPAN
assert(err);
err = SSL_CTX_use_PrivateKey_file(ctx, key.c_str(), SSL_FILETYPE_PEM);
assert(err);
err = SSL_CTX_check_private_key(ctx);
assert(err);
return r;
}
string TServer::uri () const {
clib/tests/lib/test.cc view on Meta::CPAN
assert(err);
err = SSL_CTX_use_PrivateKey_file(ctx, key.c_str(), SSL_FILETYPE_PEM);
assert(err);
SSL_CTX_check_private_key(ctx);
assert(err);
SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, nullptr);
SSL_CTX_set_verify_depth(ctx, 4);
view all matches for this distribution
view release on metacpan or search on metacpan
clib/tests/socks.cc view on Meta::CPAN
static SSL_CTX* ctx = nullptr;
if (ctx) return ctx;
ctx = SSL_CTX_new(SSLv23_server_method());
SSL_CTX_use_certificate_file(ctx, "tests/cert/cert.pem", SSL_FILETYPE_PEM);
SSL_CTX_use_PrivateKey_file(ctx, "tests/cert/key.pem", SSL_FILETYPE_PEM);
SSL_CTX_check_private_key(ctx);
return ctx;
}
view all matches for this distribution
view release on metacpan or search on metacpan
clib/tests/cpp_tests.cc view on Meta::CPAN
assert(err);
err = SSL_CTX_use_PrivateKey_file(ctx, key.c_str(), SSL_FILETYPE_PEM);
assert(err);
err = SSL_CTX_check_private_key(ctx);
assert(err);
err = SSL_CTX_load_verify_locations(ctx, cert.c_str(), nullptr);
assert(err);
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/MyTest.pm view on Meta::CPAN
sub get_ssl_ctx {
my $SERV_CERT = "t/cert/ca.pem";
my $serv_ctx = Net::SSLeay::CTX_new();
Net::SSLeay::CTX_use_certificate_file($serv_ctx, $SERV_CERT, &Net::SSLeay::FILETYPE_PEM) or sslerr();
Net::SSLeay::CTX_use_PrivateKey_file($serv_ctx, "t/cert/ca.key", &Net::SSLeay::FILETYPE_PEM) or sslerr();
Net::SSLeay::CTX_check_private_key($serv_ctx) or die Net::SSLeay::ERR_error_string(Net::SSLeay::ERR_get_error);
return $serv_ctx unless wantarray();
my $client_ctx = Net::SSLeay::CTX_new();
Net::SSLeay::CTX_load_verify_locations($client_ctx, $SERV_CERT, '') or die "something went wrong";
view all matches for this distribution
view release on metacpan or search on metacpan
lib/VAPID.pm view on Meta::CPAN
generate_vapid_keys => [qw/all generate/],
generate_future_expiration_timestamp => [qw/all generate/],
generate_vapid_header => [qw/all generate/],
validate_subject => [qw/all validate/],
validate_public_key => [qw/all validate/],
validate_private_key => [qw/all validate/],
validate_expiration_key => [qw/all validate/],
validate_expiration => [qw/all validate/],
validate_subscription => [qw/all validate/],
encrypt_payload => [qw/all encrypt/],
build_push_request => [qw/all push/],
lib/VAPID.pm view on Meta::CPAN
die "VAPID audience is not a url.";
}
validate_subject($subject);
validate_public_key($pub);
$priv = validate_private_key($priv);
if ($expiration) {
validate_expiration($expiration);
} else {
$expiration = generate_future_expiration_timestamp();
lib/VAPID.pm view on Meta::CPAN
}
return $pub;
}
sub validate_private_key {
my ($priv) = shift;
if (!$priv) {
die "No private key passed to validate_private_key";
}
if (ref $priv) {
die "VAPID private key is must be a URL safe Base 64 encoded string";
}
lib/VAPID.pm view on Meta::CPAN
my ($public, $private) = generate_vapid_keys();
# Validate keys
validate_public_key($public);
validate_private_key($private);
# Send a push notification
my $subscription = {
endpoint => $endpoint_from_browser,
keys => {
lib/VAPID.pm view on Meta::CPAN
=head2 validate_public_key
Validate the public key.
=head2 validate_private_key
Validate the private key.
=head2 validate_expiration
view all matches for this distribution
view release on metacpan or search on metacpan
bin/sync_to_snapshot.pl view on Meta::CPAN
# Create a temporary key for ssh'ing
print STDERR "Creating a temporary ssh key...\n";
my $keypairname = "${Program_name}_$$";
$KeyFile = File::Spec->catfile(File::Spec->tmpdir,"$keypairname.pem");
$KeyPair = $ec2->create_key_pair($keypairname);
my $private_key = $KeyPair->privateKey;
open my $k,'>',$KeyFile or die "Couldn't create $KeyFile: $!";
chmod 0600,$KeyFile or die "Couldn't chmod $KeyFile: $!";
print $k $private_key;
close $k;
# Create a temporary security group for ssh'ing
print STDERR "Creating a temporary security group with ssh enabled...\n";
$Group = $ec2->create_security_group(-name => "${Program_name}_$$",
view all matches for this distribution
view release on metacpan or search on metacpan
lib/VM/HetznerCloud/API/Certificates.pm view on Meta::CPAN
=head2 create
Creates a new Certificate.
The default type **uploaded** allows for uploading your existing `certificate` and `private_key` in PEM format. You have to monitor its expiration date and handle renewal yourself.
In contrast, type **managed** requests a new Certificate from *Let's Encrypt* for the specified `domain_names`. Only domains managed by *Hetzner DNS* are supported. We handle renewal and timely alert the project owner via email if problems occur.
For type `managed` Certificates the `action` key of the response contains the Action that allows for tracking the issuance process. For type `uploaded` Certificates the `action` is always null.
view all matches for this distribution
view release on metacpan or search on metacpan
WSFC_wrap.c view on Meta::CPAN
}
void wsf_set_security_data_to_rampart_context(axutil_env_t *env,
rampart_context_t *rampart_context,
axis2_char_t *private_key,
axis2_char_t *certificate,
axis2_char_t *receiver_certificate,
axis2_char_t *user,
axis2_char_t *password,
axis2_char_t *password_type,
int ttl)
{
if (NULL != private_key) {
if (rampart_context_set_prv_key(rampart_context, env, (void *) private_key) == AXIS2_SUCCESS)
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[wsf_sec_policy] setting pvt key ");
if (rampart_context_set_prv_key_type(rampart_context, env, AXIS2_KEY_TYPE_PEM) == AXIS2_SUCCESS)
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[wsf_sec_policy] setting pvt key format ");
}
WSFC_wrap.c view on Meta::CPAN
void handle_client_security(axutil_env_t *env,
axis2_svc_client_t *svc_client,
axiom_node_t *incoming_policy_node,
axis2_char_t *private_key,
axis2_char_t *certificate,
axis2_char_t *receiver_certificate,
axis2_char_t *user,
axis2_char_t *password,
axis2_char_t *password_type,
WSFC_wrap.c view on Meta::CPAN
conf_ctx = axis2_svc_ctx_get_conf_ctx(svc_ctx, env);
if (NULL != conf_ctx) {
conf = axis2_conf_ctx_get_conf(conf_ctx, env);
if (NULL != conf) {
rampart_ctx = rampart_context_create(env);
wsf_set_security_data_to_rampart_context(env, rampart_ctx, private_key, certificate, receiver_certificate, user, password, password_type, ttl);
security_param = axutil_param_create(env, (axis2_char_t *) WSF_RAMPART_CONFIGURATION, rampart_ctx);
if (NULL != security_param)
axis2_conf_add_param(conf, env, security_param);
}
}
WSFC_wrap.c view on Meta::CPAN
int ecode9 = 0 ;
int argvi = 0;
dXSARGS;
if ((items < 9) || (items > 9)) {
SWIG_croak("Usage: wsf_set_security_data_to_rampart_context(env,rampart_context,private_key,certificate,receiver_certificate,user,password,password_type,ttl);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_axutil_env_t, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wsf_set_security_data_to_rampart_context" "', argument " "1"" of type '" "axutil_env_t *""'");
}
WSFC_wrap.c view on Meta::CPAN
int ecode10 = 0 ;
int argvi = 0;
dXSARGS;
if ((items < 10) || (items > 10)) {
SWIG_croak("Usage: handle_client_security(env,svc_client,incoming_policy_node,private_key,certificate,receiver_certificate,user,password,password_type,ttl);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_axutil_env_t, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "handle_client_security" "', argument " "1"" of type '" "axutil_env_t *""'");
}
WSFC_wrap.c view on Meta::CPAN
sv_setsv(sv, SWIG_FromCharPtr("SSL_PASSPHRASE"));
SvREADONLY_on(sv);
} while(0) /*@SWIG@*/;
/*@SWIG:/usr/share/swig/1.3.33/perl5/perltypemaps.swg,64,%set_constant@*/ do {
SV *sv = get_sv((char*) SWIG_prefix "WSF_SEC_TOK_OPT_PRIVATE_KEY", TRUE | 0x2);
sv_setsv(sv, SWIG_FromCharPtr("private_key"));
SvREADONLY_on(sv);
} while(0) /*@SWIG@*/;
/*@SWIG:/usr/share/swig/1.3.33/perl5/perltypemaps.swg,64,%set_constant@*/ do {
SV *sv = get_sv((char*) SWIG_prefix "WSF_SEC_TOK_OPT_CERT", TRUE | 0x2);
sv_setsv(sv, SWIG_FromCharPtr("certificate"));
view all matches for this distribution
view release on metacpan or search on metacpan
lib/WSRF/Lite.pm view on Meta::CPAN
$ENV{HTTPS_KEY_FILE} ? $ENV{HTTPS_KEY_FILE} : die "No Private Key\n";
open( PRIVKEY, $key_file_name )
|| die("Could not open file $key_file_name");
my $privkey = join "", <PRIVKEY>;
close(PRIVKEY);
Crypt::OpenSSL::RSA->new_private_key($privkey);
}
#returns the cert block between the begin and end delimiters
sub load_cert {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/WWW/FCM/HTTP/V1/OAuth.pm view on Meta::CPAN
my ($json, $scopes) = @_;
my $secret = decode_json($json);
return +{
client_email => $secret->{client_email},
private_key => $secret->{private_key},
private_key_id => $secret->{private_key_id},
scopes => $scopes,
token_url => $secret->{token_url} || $DEFAULT_TOKEN_URL,
};
}
sub get_token {
my ($self, %args) = @_;
my $cache_key = $self->jwt_config->{private_key_id};
if ($self->cache) {
if ($args{force_refresh}) {
$self->cache->delete($cache_key);
} else {
my $token_cache = $self->cache->get($cache_key);
return $token_cache if $token_cache;
}
}
my $claims = $self->_construct_claims($self->jwt_config);
my $jwt = JSON::WebToken->encode($claims, $self->jwt_config->{private_key}, 'RS256');
my $res = $self->ua->post(
$self->token_url,
['Content-Type' => 'application/x-www-form-urlencoded'],
['grant_type' => $self->grant_type, assertion => $jwt],
);
view all matches for this distribution
view release on metacpan or search on metacpan
=head1 SYNOPSIS
use WWW::Facebook::FQL;
## Connect and log in:
my $fb = new WWW::Facebook::FQL key => $public_key, private => $private_key;
$fb->login($email, $password);
## Get your own name and pic back:
$fb->query("SELECT name, pic FROM user WHERE uid=$fb->{uid}");
view all matches for this distribution
view release on metacpan or search on metacpan
lib/WWW/Google/Cloud/Auth/ServiceAccount.pm view on Meta::CPAN
scope => $self->scope,
aud => 'https://www.googleapis.com/oauth2/v4/token',
exp => $self->clock->() + 600,
iat => $self->clock->(),
};
my $key = $creds->{private_key};
return encode_jwt(alg => 'RS256', payload => $payload, key => \$key);
}
sub get_token {
my $self = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/WWW/Google/Drive.pm view on Meta::CPAN
my $config = Config::JSON->new($self->secret_json);
my $time = time;
my $service_acc_id = $config->get("client_email");
my $private_key_string = $config->get("private_key");
my $jwt = JSON::WebToken->encode(
{
iss => $service_acc_id,
scope => $self->scope,
lib/WWW/Google/Drive.pm view on Meta::CPAN
iat => $time,
# Access files from this users drive/ impersonate user
prn => $self->user_as,
},
$private_key_string,
'RS256',
{typ => 'JWT'}
);
# Authenticate via post, and get a token
view all matches for this distribution
view release on metacpan or search on metacpan
lib/WWW/Hetzner/Cloud/API/Certificates.pm view on Meta::CPAN
type => $params{type},
};
# For uploaded certificates
$body->{certificate} = $params{certificate} if $params{certificate};
$body->{private_key} = $params{private_key} if $params{private_key};
# For managed certificates
$body->{domain_names} = $params{domain_names} if $params{domain_names};
$body->{labels} = $params{labels} if $params{labels};
lib/WWW/Hetzner/Cloud/API/Certificates.pm view on Meta::CPAN
# Create uploaded certificate
my $cert = $cloud->certificates->create(
name => 'my-cert',
type => 'uploaded',
certificate => $pem_cert,
private_key => $pem_key,
);
# Delete
$cloud->certificates->delete($cert->id);
lib/WWW/Hetzner/Cloud/API/Certificates.pm view on Meta::CPAN
# Uploaded certificate
my $cert = $cloud->certificates->create(
name => 'my-cert', # required
type => 'uploaded', # required
certificate => $pem_cert, # required for uploaded
private_key => $pem_key, # required for uploaded
labels => { ... }, # optional
);
Creates certificate. Returns L<WWW::Hetzner::Cloud::Certificate> object.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/WWW/LetsEncrypt/JWK.pm view on Meta::CPAN
This function, when implemented, should accept a private key string as a parameter and return new JSON Web Key.
Input
{
private_key => $scalar string of the private key to use,
}
Output
JWK Object
view all matches for this distribution
view release on metacpan or search on metacpan
examples/all_characters_names.pl view on Meta::CPAN
use WWW::Marvel::Response;
my $cfg = WWW::Marvel::Config::File->new();
my $client = WWW::Marvel::Client->new({
public_key => $cfg->get_public_key,
private_key => $cfg->get_private_key,
});
my $total_records = undef;
my $founded = 0;
my $offset = 0;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/WWW/OneAll.pm view on Meta::CPAN
sub new { ## no critic (ArgUnpacking)
my $class = shift;
my %args = @_ % 2 ? %{$_[0]} : @_;
for (qw/subdomain public_key private_key/) {
$args{$_} || croak "Param $_ is required.";
}
$args{endpoint} ||= "https://" . $args{subdomain} . ".api.oneall.com";
$args{timeout} ||= 60; # for ua timeout
lib/WWW/OneAll.pm view on Meta::CPAN
my $ref_url_params = delete $params{query_params};
my $query_params = "?";
$query_params = $query_params . join("&", @$ref_url_params) if $ref_url_params;
my $ua = $self->__ua;
my $header = {Authorization => 'Basic ' . b64_encode($self->{public_key} . ':' . $self->{private_key}, '')};
$header->{'Content-Type'} = 'application/json' if %params;
my @extra = %params ? (json => \%params) : ();
my $tx = $ua->build_tx($method => $self->{endpoint} . $url . '.json' . $query_params => $header => @extra);
$tx->req->headers->accept('application/json');
lib/WWW/OneAll.pm view on Meta::CPAN
use WWW::OneAll;
my $connection_token;
my $oneall = WWW::OneAll->new(
subdomain => 'your_subdomain',
public_key => 'pubkey12-629b-4020-83fe-38af46e27b06',
private_key => 'prikey12-a7ec-48f5-b9bc-737eb74146a4',
);
my $data = $oneall->connection($connection_token) or die $oneall->errstr;
=head1 DESCRIPTION
lib/WWW/OneAll.pm view on Meta::CPAN
=item * subdomain
=item * public_key
=item * private_key
all required. get from API Settings L<https://app.oneall.com/applications/application/settings/api/>
=back
view all matches for this distribution
view release on metacpan or search on metacpan
lib/WWW/Phanfare/API.pm view on Meta::CPAN
$method =~ s/.*://; # strip fully-qualified portion
croak "method not defined" unless $method;
# Verify keys are defined
croak 'api_key not defined' unless $self->{api_key};
croak 'private_key not defined' unless $self->{private_key};
my %param = @_;
# Is POST content included
delete $param{content} if my $content = $param{content};
lib/WWW/Phanfare/API.pm view on Meta::CPAN
sprintf('%s=%s', 'api_key', $self->{api_key}),
sprintf('%s=%s', 'method', $method),
map { sprintf '%s=%s', $_, (defined $param{$_} ? $param{$_} : '') } keys %param;
# Sign request string
my $sig = md5_hex( $req . $self->{private_key} );
# Build URL escaped request string
$req = join '&',
sprintf('%s=%s', 'api_key', $self->{api_key}),
sprintf('%s=%s', 'method', $method),
lib/WWW/Phanfare/API.pm view on Meta::CPAN
Create agent. Developer API keys required.
use WWW::Phanfare::API;
my $api = WWW::Phanfare::API->new(
api_key => 'xxx',
private_key => 'yyy',
);
Authentication with account:
my $session = $api->Authenticate(
lib/WWW/Phanfare/API.pm view on Meta::CPAN
=head1 SUBROUTINES/METHODS
Refer to methods and required parameters are listed on
http://help.phanfare.com/index.php/API .
api_key and private_key is only required for the constructor,
not for individual methods.
Methods return hash references.
The value of the 'stat' key will be 'ok' if the call succeeded.
Value of 'code_value' key has error message.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/WWW/Phanfare/Class.pm view on Meta::CPAN
use WWW::Phanfare::Class::CacheAPI;
use WWW::Phanfare::API;
use WWW::Phanfare::Class::Account;
has 'api_key' => ( is=>'ro', isa=>'Str', required=>1 );
has 'private_key' => ( is=>'ro', isa=>'Str', required=>1 );
has 'email_address' => ( is=>'ro', isa=>'Str' );
has 'password' => ( is=>'ro', isa=>'Str' );
sub _childclass { 'WWW::Phanfare::Class::Account' }
# Initialize account
lib/WWW/Phanfare/Class.pm view on Meta::CPAN
my $self = shift;
# Create an API Agent
WWW::Phanfare::Class::CacheAPI->new(
api_key => $self->api_key,
private_key => $self->private_key,
);
}
# Get a subnode, by name of name.id
lib/WWW/Phanfare/Class.pm view on Meta::CPAN
use WWW::Phanfare::Class;
$class = WWW::Phanfare::Class->new(
api_key => 'secret',
private_key => 'secret',
email_address => 's@c.et',
password => 'secret',
);
# Site Name
view all matches for this distribution
view release on metacpan or search on metacpan
lib/WWW/Suffit/Server/API/Admin.pm view on Meta::CPAN
"id": 3,
"name": "Test User",
"not_after": null,
"not_before": 1678741533,
"password": "9f86...0a08",
"private_key": "",
"public_key": "",
"role": "Test user",
"username": "test"
}
]
lib/WWW/Suffit/Server/API/Admin.pm view on Meta::CPAN
"algorithm": "SHA256",
"role": "Test user",
"flags": 0,
"not_after": null,
"public_key": null,
"private_key": null,
"attributes": null,
"comment": "Test user for unit testing only"
}' \
https://owl.localhost:8695/api/admin/user
lib/WWW/Suffit/Server/API/Admin.pm view on Meta::CPAN
"id": 13,
"name": "Bob",
"not_after": 0,
"not_before": 1683893750,
"password": "81b6...8ce9",
"private_key": "-----BEGIN RSA PRIVATE KEY-----...",
"public_key": "-----BEGIN RSA PUBLIC KEY-----...",
"role": "Test user",
"status": true,
"username": "bob"
}
lib/WWW/Suffit/Server/API/Admin.pm view on Meta::CPAN
"id": 3,
"name": "Test User",
"not_after": null,
"not_before": 1678741533,
"password": "9f86...0a08",
"private_key": "",
"public_key": "",
"role": "Test user",
"status": true,
"username": "test"
}
lib/WWW/Suffit/Server/API/Admin.pm view on Meta::CPAN
"algorithm": "SHA256",
"role": "Test user",
"flags": 0,
"not_after": null,
"public_key": null,
"private_key": null,
"attributes": null,
"comment": "Test user for unit testing only"
}' \
https://owl.localhost:8695/api/admin/user/bob
lib/WWW/Suffit/Server/API/Admin.pm view on Meta::CPAN
"id": 13,
"name": "Bob Bob",
"not_after": 0,
"not_before": 1683894066,
"password": "81b6...8ce9",
"private_key": "-----BEGIN RSA PRIVATE KEY-----...",
"public_key": "-----BEGIN RSA PUBLIC KEY-----...",
"role": "Test user",
"status": true,
"username": "bob"
}
lib/WWW/Suffit/Server/API/Admin.pm view on Meta::CPAN
# Get not_after
my $is_disabled = $self->req->json('/disabled') || 0;
$data{not_after} = $is_disabled ? time() : undef;
# Text fields
foreach my $k (qw/public_key private_key attributes comment/) {
my $v = $self->req->json("/$k") // '';
$data{$k} = $v;
}
# Gen RSA keys
unless (length($data{public_key}) || length($data{private_key})) {
my %ks = $self->gen_rsakeys();
return $self->reply->json_error(500 => "E1215" => $ks{error}) if $ks{error};
$data{$_} = $ks{$_} for qw/public_key private_key/;
}
# Set user data
$authdb->user_set(%data)
or return $self->reply->json_error($authdb->code, $authdb->error || "E1216: Can't set user data to authorization database");
view all matches for this distribution
view release on metacpan or search on metacpan
lib/WWW/Suffit/AuthDB/Model.pm view on Meta::CPAN
"flags" INTEGER DEFAULT 0, -- Flags
"created" INTEGER DEFAULT NULL, -- Created at
"not_before" INTEGER DEFAULT NULL, -- Not Before
"not_after" INTEGER DEFAULT NULL, -- Not After
"public_key" TEXT DEFAULT NULL, -- Public Key (RSA/X509)
"private_key" TEXT DEFAULT NULL, -- Private Key (RSA/X509)
"attributes" TEXT DEFAULT NULL, -- Attributes (JSON)
"comment" TEXT DEFAULT NULL -- Comment
);
CREATE TABLE IF NOT EXISTS "groups" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
lib/WWW/Suffit/AuthDB/Model.pm view on Meta::CPAN
`flags` INT(11) DEFAULT 0, -- Flags
`created` INT(11) DEFAULT NULL, -- Created at
`not_before` INT(11) DEFAULT NULL, -- Not Before
`not_after` INT(11) DEFAULT NULL, -- Not After
`public_key` TEXT DEFAULT NULL, -- Public Key (RSA/X509)
`private_key` TEXT DEFAULT NULL, -- Private Key (RSA/X509)
`attributes` TEXT DEFAULT NULL, -- Attributes (JSON)
`comment` TEXT DEFAULT NULL, -- Comment
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
lib/WWW/Suffit/AuthDB/Model.pm view on Meta::CPAN
flags => 0,
created => time(),
not_before => time(),
not_after => undef,
public_key => "",
private_key => "",
attributes => qq/{"disabled": 0}/,
comment => "This user added by default",
) or die($model->error);
Add new user recored
lib/WWW/Suffit/AuthDB/Model.pm view on Meta::CPAN
role => "System administrator",
flags => 0,
not_before => time(),
not_after => undef,
public_key => "",
private_key => "",
attributes => qq/{"disabled": 0}/,
comment => "This user added by default",
) or die($model->error);
Update recored by username
lib/WWW/Suffit/AuthDB/Model.pm view on Meta::CPAN
=head2 user_setkeys
$model->user_setkeys(
id => 123,
public_key => $public_key,
private_key => $private_key,
) or die($model->error);
Sets keys to user's data
=head2 user_tokens
lib/WWW/Suffit/AuthDB/Model.pm view on Meta::CPAN
# User DMLs
use constant DML_USER_ADD => <<'DML';
INSERT INTO `users`
(`username`,`name`,`email`,`password`,`algorithm`,`role`,`flags`,`created`,
`not_before`,`not_after`,`public_key`,`private_key`,`attributes`,`comment`
)
VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?)
DML
use constant DML_USER_GET => <<'DML';
SELECT `id`,`username`,`name`,`email`,`password`,`algorithm`,`role`,`flags`,`created`,
`not_before`,`not_after`,`public_key`,`private_key`,`attributes`,`comment`
FROM `users`
WHERE `username` = ?
DML
use constant DML_USER_SET => <<'DML';
UPDATE `users`
SET `name` = ?, `email` = ?, `password` = ?, `algorithm` = ?, `role` = ?, `flags` = ?,
`not_before` = ?, `not_after` = ?, `public_key` = ?, `private_key` = ?,
`attributes` = ?, `comment` = ?
WHERE `username` = ?
DML
use constant DML_USER_DEL => <<'DML';
DELETE FROM `users` WHERE `username` = ?
DML
use constant DML_USER_GETALL => <<'DML';
SELECT `id`,`username`,`name`,`email`,`password`,`algorithm`,`role`,`flags`,`created`,
`not_before`,`not_after`,`public_key`,`private_key`,`attributes`,`comment`
FROM `users`
ORDER BY `username` ASC
DML
use constant DML_PASSWD => <<'DML';
UPDATE `users`
lib/WWW/Suffit/AuthDB/Model.pm view on Meta::CPAN
SET `name` = ?, `email` = ?, `role` = ?, `comment` = ?
WHERE `id` = ?
DML
use constant DML_USER_SETKEYS => <<'DML';
UPDATE `users`
SET `public_key` = ?, `private_key` = ?
WHERE `id` = ?
DML
# Group DMLs
use constant DML_GROUP_ADD => <<'DML';
lib/WWW/Suffit/AuthDB/Model.pm view on Meta::CPAN
# Add
$self->query(DML_USER_ADD,
$data{username}, $data{name}, $data{email}, $data{password},
uc($data{algorithm} || DEFAULT_ALGORITHM), $data{role}, $data{flags},
$data{created} || time(), $data{not_before} || time(), $data{not_after},
$data{public_key}, $data{private_key}, $data{attributes},
$data{comment},
) or return 0;
# Ok
return 1;
lib/WWW/Suffit/AuthDB/Model.pm view on Meta::CPAN
# Set
$self->query(DML_USER_SET,
$data{name}, $data{email}, $data{password},
uc($data{algorithm} || DEFAULT_ALGORITHM), $data{role}, $data{flags},
$data{not_before} || time(), $data{not_after},
$data{public_key}, $data{private_key}, $data{attributes},
$data{comment},
$data{username},
) or return 0;
# Ok
lib/WWW/Suffit/AuthDB/Model.pm view on Meta::CPAN
$self->error("No id of user specified");
return 0;
}
# Set
$self->query(DML_USER_SETKEYS, $data{public_key}, $data{private_key}, $data{id}) or return 0;
# Ok
return 1;
}
lib/WWW/Suffit/AuthDB/Model.pm view on Meta::CPAN
"flags" INTEGER DEFAULT 0, -- Flags
"created" INTEGER DEFAULT NULL, -- Created at
"not_before" INTEGER DEFAULT NULL, -- Not Before
"not_after" INTEGER DEFAULT NULL, -- Not After
"public_key" TEXT DEFAULT NULL, -- Public Key (RSA/X509)
"private_key" TEXT DEFAULT NULL, -- Private Key (RSA/X509)
"attributes" TEXT DEFAULT NULL, -- Attributes (JSON)
"comment" TEXT DEFAULT NULL -- Comment
) ;
CREATE TABLE IF NOT EXISTS "groups" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
lib/WWW/Suffit/AuthDB/Model.pm view on Meta::CPAN
`flags` INT(11) DEFAULT 0, -- Flags
`created` INT(11) DEFAULT NULL, -- Created at
`not_before` INT(11) DEFAULT NULL, -- Not Before
`not_after` INT(11) DEFAULT NULL, -- Not After
`public_key` TEXT DEFAULT NULL, -- Public Key (RSA/X509)
`private_key` TEXT DEFAULT NULL, -- Private Key (RSA/X509)
`attributes` TEXT DEFAULT NULL, -- Attributes (JSON)
`comment` TEXT DEFAULT NULL, -- Comment
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
lib/WWW/Suffit/AuthDB/Model.pm view on Meta::CPAN
flags INT DEFAULT 0, -- Flags
created INT DEFAULT NULL, -- Created at
not_before INT DEFAULT NULL, -- Not Before
not_after INT DEFAULT NULL, -- Not After
public_key TEXT DEFAULT NULL, -- Public Key (RSA/X509)
private_key TEXT DEFAULT NULL, -- Private Key (RSA/X509)
attributes TEXT DEFAULT NULL, -- Attributes (JSON)
comment TEXT DEFAULT NULL, -- Comment
PRIMARY KEY (id),
CONSTRAINT username UNIQUE (username)
) ;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/WWW/Suffit/JWT.pm view on Meta::CPAN
die $jwt->error if $jwt->error;
use WWW::Suffit::RSA;
my $rsa = WWW::Suffit::RSA->new(key_size => 1024);
$rsa->keygen;
my $private_key = $rsa->private_key;
my $public_key = $rsa->public_key;
my $jwt = WWW::Suffit::JWT->new(
private_key => $private_key,
payload => {foo => 'bar'},
algorithm => 'RS512',
);
my $token = $jwt->encode->token or die $jwt->error;
my $payload = $jwt->public_key($public_key)->decode($token)->payload;
lib/WWW/Suffit/JWT.pm view on Meta::CPAN
Payload - second part of JWT structure
The payload is a user data structure to be encoded. This must be a hash reference only.
=head2 private_key
The RSA private key to be used in edcoding an asymmetrically signed JWT. See L<WWW::Suffit::RSA>
=head2 public_key
lib/WWW/Suffit/JWT.pm view on Meta::CPAN
=head2 sign_rsa
my $signature = $jwt->sign_rsa($size, $string);
Returns the RSA signature for the given size and string.
The L</private_key> attribute is used as the private key.
The result is base64url encoded!
This method is provided mostly for the purposes of subclassing.
=head2 verify_hmac
lib/WWW/Suffit/JWT.pm view on Meta::CPAN
has 'algorithm' => DEFAULT_ALGORITHM(); # By default
has 'expires'; # Expire time
has 'not_before'; # Time "not before"
has 'iat' => 0; # Payload iat param
has 'jti' => 0; # Payload jti param
has 'private_key'; # For RSA
has 'public_key'; # For RSA
has 'error' => ''; # Error string
has 'header' => sub { {} }; # Header (first part of JWT)
has 'payload' => sub { {} }; # Payload (second parg of JWT)
lib/WWW/Suffit/JWT.pm view on Meta::CPAN
}
sub sign_rsa {
my ($self, $size, $concat) = @_;
# Get RSA private key
my $private_key = $self->private_key;
$self->error('Private key (private_key) not specified') && return unless $private_key;
# Create RSA object
my $rsa = WWW::Suffit::RSA->new(private_key => $private_key);
# Sign!
my $sign = $rsa->sign($concat, $size) // '';
unless (length($sign)) {
$self->error($rsa->error);
view all matches for this distribution