Result:
found 319 distributions and 1179 files matching your query ! ( run in 1.979 )


JIRA-REST-OAuth

 view release on metacpan or  search on metacpan

lib/JIRA/REST/OAuth.pm  view on Meta::CPAN

    else {
        %args = @_;
    }

    # remove arguments for this subclass
    my @opts = qw( rsa_private_key oauth_token oauth_token_secret consumer_key );
    my %a;
    foreach my $opt (@opts) {
        croak __PACKAGE__.'::new requires argument '.$opt unless defined $args{$opt};
        $a{$opt} = delete $args{$opt};
    }

lib/JIRA/REST/OAuth.pm  view on Meta::CPAN

    my $url  = $args{url} if exists $args{url};
    my $self = $class->SUPER::new(\%args);
    $$self{url} = $url;

    # handle our options
    if (-e $a{rsa_private_key}) {
        open(my $fh, '<', $a{rsa_private_key}) or die "Unable to read $a{rsa_private_key}! $!";
        local $/ = undef;
        my $data = <$fh>;
        close($fh);

        $a{rsa_private_key} = Crypt::OpenSSL::RSA->new_private_key($data);
    }
    else {
        $a{rsa_private_key} = Crypt::OpenSSL::RSA->new_private_key($a{rsa_private_key});
    }

    foreach my $opt (@opts) {
        $$self{$opt} = delete $a{$opt};
    }

lib/JIRA/REST/OAuth.pm  view on Meta::CPAN


        consumer_key     => $$self{consumer_key},
        consumer_secret  => 'ignore',
        signature_method => 'RSA-SHA1',
        protocol_version => Net::OAuth::PROTOCOL_VERSION_1_0,
        signature_key    => $$self{rsa_private_key},
        token            => $$self{oauth_token},
        token_secret     => $$self{oauth_token_secret},

        timestamp => time,
        nonce     => int(rand(2**32)),

lib/JIRA/REST/OAuth.pm  view on Meta::CPAN


    use JIRA::REST::OAuth;
    my $jira = JIRA::REST::OAuth->new(
        {
            url                => 'https://jira.example.net',
            rsa_private_key    => '/path/to/private/key.pem',
            oauth_token        => '<oauth_token>',
            oauth_token_secret => '<oauth_token_secrete>',
            consumer_key       => '<key>',
        }
    );

 view all matches for this distribution


JSON-WebEncryption

 view release on metacpan or  search on metacpan

lib/JSON/WebEncryption.pm  view on Meta::CPAN

    my $self =  bless {}, $caller;

    $self->{alg}         = $arg{alg};
    $self->{enc}         = $arg{enc};
    $self->{key}         = $arg{key};
    $self->{private_key} = $arg{private_key};
    $self->{public_key}  = $arg{public_key};

    return $self;
}

lib/JSON/WebEncryption.pm  view on Meta::CPAN


# -----------------------------------------------------------------------------

sub _alg_RSA1_5_decode
{
    my ( $self, $enc_params, $private_key, $iv, $ciphertext, $encrypted_key  ) = @_;

    $private_key //= $self->{private_key};

    my $cipherType = $enc_params->[0];
    my $keysize    = $enc_params->[1] / 8; # /8 to get it in bytes
    my $padding    = $crypt_padding_map{ $enc_params->[3] };

    # Decrypt the encryption key using the Private Key
    my $rsa = Crypt::OpenSSL::RSA->new_private_key( $private_key ); # Key passed in is a Private Key
    $rsa->use_pkcs1_oaep_padding;
    my $CEK = $rsa->decrypt( $encrypted_key );

    # Use the encryption key to decrypt the message
    my $cipher = _getCipher( $cipherType, $CEK, $padding, $iv, $keysize );

 view all matches for this distribution


JSON-WebToken

 view release on metacpan or  search on metacpan

lib/JSON/WebToken/Crypt/RSA.pm  view on Meta::CPAN

};

sub sign {
    my ($class, $algorithm, $message, $key) = @_;

    my $private_key = Crypt::OpenSSL::RSA->new_private_key($key);
    my $method = $ALGORITHM2SIGNING_METHOD_MAP->{$algorithm};
    $private_key->$method;
    return $private_key->sign($message);
}

sub verify {
    my ($class, $algorithm, $message, $key, $signature) = @_;

 view all matches for this distribution


Jifty-Plugin-OAuth

 view release on metacpan or  search on metacpan

t/lib/TestApp/Plugin/OAuth/Test.pm  view on Meta::CPAN


    my $signature;

    if ($sig_method eq 'RSA-SHA1') {
        require Crypt::OpenSSL::RSA;
        my $pubkey = Crypt::OpenSSL::RSA->new_private_key($key);
        $signature = encode_base64($pubkey->sign($signature_base_string), "");
    }
    elsif ($sig_method eq 'HMAC-SHA1') {
        my $key = join '&',
          map { Jifty->web->escape_uri($_||'') }

 view all matches for this distribution


LaTeXML-Plugin-LtxMojo

 view release on metacpan or  search on metacpan

lib/LaTeXML/Plugin/LtxMojo/public/js/external/ace-min/mode-php.js  view on Meta::CPAN

define("ace/mode/php",["require","exports","module","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/php_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cs...

 view all matches for this distribution


Lemonldap-NG-Common

 view release on metacpan or  search on metacpan

lib/Lemonldap/NG/Common/Util/Crypto.pm  view on Meta::CPAN

    my ( $key_size, $password ) = @_;

    my $rsa = Crypt::OpenSSL::RSA->generate_key($key_size);

    my $keys = {
        'private' => $rsa->get_private_key_string(),
        'public'  => $rsa->get_public_key_x509_string(),
        'hash'    => md5_base64( $rsa->get_public_key_string() ),
    };
    if ($password) {
        my $pem = Convert::PEM->new(

 view all matches for this distribution


Lemonldap-NG-Manager

 view release on metacpan or  search on metacpan

lib/Lemonldap/NG/Manager/Attributes.pm  view on Meta::CPAN

                {
                    'k' => 'client_secret_jwt',
                    'v' => 'client_secret_jwt'
                },
                {
                    'k' => 'private_key_jwt',
                    'v' => 'private_key_jwt'
                }
            ],
            'type' => 'select'
        },
        'oidcOPMetaDataOptionsTokenEndpointAuthSigAlg' => {

lib/Lemonldap/NG/Manager/Attributes.pm  view on Meta::CPAN

                {
                    'k' => 'client_secret_jwt',
                    'v' => 'client_secret_jwt'
                },
                {
                    'k' => 'private_key_jwt',
                    'v' => 'private_key_jwt'
                }
            ],
            'type' => 'select'
        },
        'oidcRPMetaDataOptionsAuthnLevel' => {

 view all matches for this distribution


Lemonldap-NG-Portal

 view release on metacpan or  search on metacpan

lib/Lemonldap/NG/Portal/Issuer/JitsiMeetTokens.pm  view on Meta::CPAN

        if ( !$key_id ) {
            $self->logger->error("jitsiSigningKey is not set");
            return PE_ERROR;
        }

        my $pkey = $self->get_private_key($key_id);
        if ( !$pkey ) {
            $self->logger->error("Jitsi signing key $key_id was not found");
            return PE_ERROR;
        }

 view all matches for this distribution


Lexical-Attributes

 view release on metacpan or  search on metacpan

t/BusyDestroy.pm  view on Meta::CPAN


use strict;
use warnings;
use Lexical::Attributes;

has $.private_key;
has $.simple_key   is ro;
has $.settable_key is rw;

sub new {
    bless [] => shift;
}

method load_me {
    $.private_key  = $_ [0] if @_;
    $.simple_key   = $_ [1] if @_ > 1;
    $.settable_key = $_ [2] if @_ > 2;
}

sub count_keys {
   (scalar keys %simple_key,
    scalar keys %private_key,
    scalar keys %settable_key,)
}

method DESTRUCT {
    1;

 view all matches for this distribution


Linux-Event

 view release on metacpan or  search on metacpan

xstls/TLS.xs  view on Meta::CPAN

    }
    SSL_CTX_set_min_proto_version(tls->ctx, TLS1_2_VERSION);
    if (SSL_CTX_use_certificate_chain_file(tls->ctx, cert_file) != 1
        || SSL_CTX_use_PrivateKey_file(tls->ctx, key_file,
            SSL_FILETYPE_PEM) != 1
        || SSL_CTX_check_private_key(tls->ctx) != 1) {
        let_set_error(tls, "failed to load TLS server identity");
        snprintf(construction_error, sizeof(construction_error), "%s", tls->error);
        SSL_CTX_free(tls->ctx);
        free(tls);
        croak("%s", construction_error);

xstls/TLS.xs  view on Meta::CPAN

    }
    SSL_CTX_set_min_proto_version(tls->ctx, TLS1_2_VERSION);
    if (SSL_CTX_use_certificate_chain_file(tls->ctx, cert_file) != 1
        || SSL_CTX_use_PrivateKey_file(tls->ctx, key_file,
            SSL_FILETYPE_PEM) != 1
        || SSL_CTX_check_private_key(tls->ctx) != 1) {
        let_set_error(tls, "failed to load prepared TLS server identity");
        snprintf(construction_error, sizeof(construction_error), "%s", tls->error);
        SSL_CTX_free(tls->ctx);
        free(tls);
        croak("%s", construction_error);

 view all matches for this distribution


Linux-WireGuard

 view release on metacpan or  search on metacpan

lib/Linux/WireGuard.pm  view on Meta::CPAN


=item * C<name>

=item * C<ifindex>

=item * C<public_key> and C<private_key> (raw strings, or undef)

=item * C<fwmark> (can be undef)

=item * C<listen_port> (can be undef)

lib/Linux/WireGuard.pm  view on Meta::CPAN


=head2 del_device( $NAME )

Deletes a WireGuard device with the given $NAME.

=head2 $bin = generate_private_key()

Returns a newly-generated private key (raw string).

=head2 $bin = generate_public_key( $PRIVATE_KEY )

 view all matches for this distribution


Mail-DKIM-Iterator

 view release on metacpan or  search on metacpan

lib/Mail/DKIM/Iterator.pm  view on Meta::CPAN

	return;
    };
    my $hash = _compute_hdrhash($hdr,
	$sig{'h:list'},$sig->{'a:hash'},$sig->{'c:hdr'},$dkh);

    my $priv = ref($key) ? $key : Crypt::OpenSSL::RSA->new_private_key($key);
    $priv or do {
	$$error = "using private key failed";
	return;
    };
    $priv->use_no_padding;

 view all matches for this distribution


Mail-DKIM

 view release on metacpan or  search on metacpan

lib/Mail/DKIM/Algorithm/Base.pm  view on Meta::CPAN


Call this method when all the headers have been submitted.

=head2 sign() - generates a signature using a private key

  $base64 = $algorithm->sign($private_key);

=head2 signature() - get/set the signature worked on by this algorithm

  my $old_signature = $algorithm->signature;
  $algorithm->signature($new_signature);

 view all matches for this distribution


Mail-Decency

 view release on metacpan or  search on metacpan

lib/Mail/Decency/Policy.pm  view on Meta::CPAN

    close $fh;
    
    # try load rsa and init private key
    my $load_rsa = eval "use Crypt::OpenSSL::RSA; 1;";
    if ( $load_rsa ) {
        $self->forward_sign_key_priv( Crypt::OpenSSL::RSA->new_private_key( $key_content ) );
    }
    
    # failure in loading -> bye
    else {
        die "Could not load Crypt::OpenSSL::RSA, cannot sign headers! Error: $@\n";

 view all matches for this distribution


Mail-DomainKeys

 view release on metacpan or  search on metacpan

lib/Mail/DomainKeys/Key/Private.pm  view on Meta::CPAN


	
	my $cork;

	eval {
		$cork = new_private_key Crypt::OpenSSL::RSA($pkcs);
	};

	$@ and
		$self->errorstr($@),
		return;

 view all matches for this distribution


Mail-Make

 view release on metacpan or  search on metacpan

lib/Mail/Make/SMIME.pm  view on Meta::CPAN


    $self->_ensure_envelope_headers( $entity ) || return( $self->pass_error );

    my $smime = $self->_make_crypt_smime || return( $self->pass_error );

    $self->_load_private_key( $smime, $opts ) || return( $self->pass_error );

    $self->_load_ca_cert( $smime, $opts );    # optional; ignore error

    my $raw = $self->_serialise_for_smime( $entity ) || return( $self->pass_error );

lib/Mail/Make/SMIME.pm  view on Meta::CPAN


    $self->_ensure_envelope_headers( $entity ) || return( $self->pass_error );

    my $smime = $self->_make_crypt_smime || return( $self->pass_error );

    $self->_load_private_key( $smime, $opts ) || return( $self->pass_error );

    $self->_load_ca_cert( $smime, $opts );    # optional

    # Load recipient certificate(s)
    my @certs = ref( $opts->{RecipientCert} ) eq 'ARRAY'

lib/Mail/Make/SMIME.pm  view on Meta::CPAN

    return( $self->error( "Failed to load CA certificate: $@" ) ) if( $@ );

    return(1);
}

# _load_private_key( $smime_obj, \%opts )
# Loads the private key and signing certificate into a Crypt::SMIME instance.
# Source priority: option Cert/Key > constructor cert/key.
# Handles key_password as string or CODE ref.
sub _load_private_key
{
    my( $self, $smime, $opts_ref ) = @_;

    my $cert_source = $opts_ref->{Cert} // $self->{cert};
    my $key_source  = $opts_ref->{Key}  // $self->{key};

 view all matches for this distribution


Mail-Milter-Authentication-Handler-BIMI

 view release on metacpan or  search on metacpan

t/04-unit-handler-bimi.t  view on Meta::CPAN

use Test::More;
use Mail::DKIM::Signer;
use Mail::DKIM::ARC::Signer;
use Mail::DKIM::PrivateKey;

my $private_key = Mail::DKIM::PrivateKey->load(Data=>'MIICXQIBAAKBgQDErv0qLGKJ933gdhx2MUBqb/XhTloMjJhH0kdQsxkVuhRFzINgDzMGOq83xEwNEk4jC/J+E49fNQ+TSVymq+XGvrkeW7/7llEOTFosY6OGlwdeUZyyUCEM6SIYIBeHuIQn4Ohwhq7P0nZFfXNAG7Wrlxx1O+E881wTRhFOBxAjdQIDAQABAoGA...

sub signed {
  my ( $text, %args ) = @_;
  my $dkim = Mail::DKIM::Signer->new(
    Algorithm => 'rsa-sha256',
    Method => 'relaxed',
    Domain => $args{domain},
    Selector => $args{selector},
    Key => $private_key,
    Headers => $args{headers},
  );
  my $signtext = $text;
  $signtext =~ s/\n/\r\n/g;
  $dkim->PRINT( $signtext );

t/04-unit-handler-bimi.t  view on Meta::CPAN

  my $arc = Mail::DKIM::ARC::Signer->new(
    Algorithm => 'rsa-sha256',
    SrvId => $args{srvid},,
    Domain => $args{domain},
    Selector => $args{selector},
    Key => $private_key,
    Chain => 'none',
    Timestamp => time(),
  );
  my $signtext = $text;
  $signtext =~ s/\n/\r\n/g;

 view all matches for this distribution


Mail-Simple-DKIM-Signer

 view release on metacpan or  search on metacpan

lib/Mail/Simple/DKIM/Signer.pm  view on Meta::CPAN


    my $class = shift;
    my $options = shift;
    my $self = {};
    
    my $private_key = $options->{key};
    $self->{headers} = $options->{headers};
    
    my $rsa_priv = new_private_key Crypt::OpenSSL::RSA($private_key);
    
    $self->{rsa} = $rsa_priv;
    
    $self->{BodyCanonicalization} = 'simplebody';
    $self->{HeadersCanonicalization} = 'simpleheader';

lib/Mail/Simple/DKIM/Signer.pm  view on Meta::CPAN

    
    use Mail::Simple::DKIM::Signer;
    
    my $dkim = Mail::Simple::DKIM::Signer->new({
        
        key => $private_key, #private key string
        domain => 'example.com',
        selector => 'dkim',
        c => 'simple/simple', ###simple/simple is the only supported Canonicalization
        a => 'rsa-sha1', ##rsa-sha1 is the only supported method
        i => '@example.com',

 view all matches for this distribution


Mail-SpamAssassin

 view release on metacpan or  search on metacpan

spamc/libspamc.c  view on Meta::CPAN

	    libspamc_log(flags, LOG_ERR,
			 "unable to load key file %s: %s",
			 tp->ssl_key_file, _ssl_err_as_string());
	    return EX_OSERR;
	}
	if (!SSL_CTX_check_private_key(ctx)) {
	    libspamc_log(flags, LOG_ERR,
			 "key file %s and cert file %s do not match: %s",
			 tp->ssl_key_file, tp->ssl_cert_file,
			 _ssl_err_as_string());
	    return EX_OSERR;

 view all matches for this distribution


Manta-Client

 view release on metacpan or  search on metacpan

lib/Manta/Client.pm  view on Meta::CPAN

	my $date_header = "date: $date";
	open F, "<$self->{key_file}";
	my $key = join '', <F>;
	close F;
	my $fingerprint = Net::SSH::Perl::Key->read_private("RSA", $self->{key_file})->fingerprint("md5");
	my $privatekey = Crypt::OpenSSL::RSA->new_private_key($key);
	$privatekey->use_sha256_hash();
	my $signature = encode_base64($privatekey->sign($date_header), "");
	my $h = HTTP::Headers->new(%{$params{headers}});
	$h->header(date => $date);
	$h->header('Authorization' => "Signature keyId=\"/$self->{user}/keys/$fingerprint\",algorithm=\"rsa-sha256\",signature=\"$signature\"");

 view all matches for this distribution


Metabrik-Repository

 view release on metacpan or  search on metacpan

lib/Metabrik/Crypto/X509.pm  view on Meta::CPAN

      "dir              =  $ca_directory",
      "certificate      =  $ca_cert",
      "database         =  \$dir/index.txt",
      "#certs            =  \$dir/cert-csr",
      "new_certs_dir    =  \$dir/certs",
      "private_key      =  $ca_key",
      "serial           =  \$dir/serial",
      "default_crl_days = 7",
      "default_days     = 3650",
      "#default_md       = md5",
      "default_md       = sha1",

 view all matches for this distribution


MicroECC

 view release on metacpan or  search on metacpan

lib/MicroECC.pm  view on Meta::CPAN

# This allows declaration	use MicroECC ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our %EXPORT_TAGS = ( 'all' => [ qw(
  secp160r1 secp192r1 secp224r1 secp256r1 secp256k1
  make_key valid_public_key shared_secret curve_public_key_size curve_private_key_size
  compute_public_key verify sign
) ] );

our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );

lib/MicroECC.pm  view on Meta::CPAN

  use Digest::SHA qw/sha1 sha256/;

  #curves: secp160r1 secp192r1 secp224r1 secp256r1 secp256k1
  my $curve = MicroECC::secp160r1();
  printf "Public key size: %d, private key size: %d.\n", 
	  MicroECC::curve_public_key_size($curve), MicroECC::curve_private_key_size($curve);

  my ($pubkey, $privkey) = MicroECC::make_key($curve);
  if(!MicroECC::valid_public_key($pubkey, $curve)){
	  print "Invalid public key.\n";
  }

 view all matches for this distribution


Mobile-Executive

 view release on metacpan or  search on metacpan

Executive.pm  view on Meta::CPAN


our @EXPORT       = qw( 
                         relocate
                         $absolute_fn
                         $public_key
                         $private_key
                      );

our @EXPORT_OK    = qw(
                      );
                      

Executive.pm  view on Meta::CPAN


    our $absolute_fn = File::Spec->rel2abs( File::Spec->curdir ) . '/' . $0;

    my $rsa = new Crypt::RSA;

    our ( $public_key, $private_key ) = 
            $rsa->keygen(
                Identity  => KEY_ID . "$$" . "$0",
                Size      => KEY_SIZE,
                Password  => KEY_PASS . "$0" . "$$",
                Verbosity => FALSE

Executive.pm  view on Meta::CPAN


and it takes two parameters: a IP address (or name) of the remote Location, and the protocol port number that the Location is listening on.

=head1 Internal methods/subroutines

A Perl B<BEGIN> block determines the absolute path to the mobile agents source code file, and puts it into the B<$absolute_fn> scalar (which is automatically exported).  This block also generates a PK+/PK- pairing (in B<$public_key> and B<$private_ke...

=head1 RULES FOR WRITING MOBILE AGENTS

There used to be loads, but now there is only one.  Read the B<Scooby Guide>, available on-line at: B<http://glasnost.itcarlow.ie/~scooby/guide.html>.

 view all matches for this distribution


Mojar-Google-Analytics

 view release on metacpan or  search on metacpan

lib/Mojar/Auth/Jwt.pm  view on Meta::CPAN

has iat => sub { time };
has duration => 60*60;  # 1 hour
has exp => sub { time + $_[0]->duration };

# JWT Signature
has 'private_key';

# Mogrified chunks

sub header {
  my $self = shift;

lib/Mojar/Auth/Jwt.pm  view on Meta::CPAN

  return $self;
}

has cipher => sub {
  my $self = shift;
  foreach ('private_key') {
    croak qq{Missing required field ($_)} unless defined $self->$_;
  }

  my $cipher = Crypt::OpenSSL::RSA->new_private_key($self->private_key);
  $cipher->use_pkcs1_padding;
  $cipher->use_sha256_hash;  # Requires openssl v0.9.8+
  return $cipher;
};

lib/Mojar/Auth/Jwt.pm  view on Meta::CPAN

=head1 SYNOPSIS

  use Mojar::Auth::Jwt;
  $jwt = Mojar::Auth::Jwt->new(
    iss => $auth_user,
    private_key => $private_key
  );
  $tx = $ua->post_form($jwt->aud, 'UTF-8', {
    grant_type => $grant_type,
    assertion => $jwt->encode
  });

lib/Mojar/Auth/Jwt.pm  view on Meta::CPAN


=item exp

Expiry time (epoch seconds).  Defaults to now + duration.

=item private_key

Private key.

=item header

lib/Mojar/Auth/Jwt.pm  view on Meta::CPAN

Signed encapsulation of header + body

=item cipher

Cipher object, built from Crypt::OpenSSL::RSA.  Before accessing, ensure
C<private_key> has been set.

=back

=head1 METHODS

=over 4

=item new

Constructor; typically only C<iss> and C<private_key> are needed.

=item reset

Clear out stale fields.

 view all matches for this distribution


Mojo-ACME

 view release on metacpan or  search on metacpan

lib/Mojo/ACME/Key.pm  view on Meta::CPAN

use Crypt::OpenSSL::Bignum; # get_key_parameters
use Digest::SHA 'sha256';
use MIME::Base64 'encode_base64url';

has 'generated';
has string => sub { shift->key->get_private_key_string };
has key => sub {
  my $self = shift;
  my $path = $self->path;
  my $rsa;
  if ($path && -e $path) {
    my $string = Mojo::File->new($path)->slurp;
    $rsa = Crypt::OpenSSL::RSA->new_private_key($string);
    $self->generated(0);
  } else {
    $rsa = Crypt::OpenSSL::RSA->generate_key(4096);
    $self->generated(1);
  }

lib/Mojo/ACME/Key.pm  view on Meta::CPAN

  return encode_base64url( sha256($json) );
};

# TODO remove this once https://rt.cpan.org/Ticket/Display.html?id=111829&results=dcfe848f59fceab0efed819d62b70447
# is resolved and dependency on PKCS10 is bumped
sub key_clone { Crypt::OpenSSL::RSA->new_private_key(shift->string) }

sub sign {
  my ($self, $content) = @_;
  my $key = $self->key;
  $key->use_sha256_hash;

 view all matches for this distribution


Mojo-ATProto-OAuth

 view release on metacpan or  search on metacpan

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN

    use strict;
    return $ua;
};
has 'client_id'          => sub { die "client_id is required\n" };
has 'callback_url'       => sub { die "callback_url is required\n" };
has 'private_key'        => undef;    # Crypt::PK::ECC, confidential clients only
has 'key_id'             => undef;
has 'loopback'           => 0;        # true for new_localhost() clients - see below
has 'identity'           => sub { Mojo::ATProto::OAuth::Identity->new };
has 'resolver'           => sub { Mojo::ATProto::OAuth::Resolver->new };
has 'log'                => sub { Mojo::Log->new(level => $ENV{MOJO_LOG_LEVEL} || 'info') };
has 'client'             => sub($self) { Mojo::ATProto::OAuth::ResourceClient->new(oauth => $self) };

sub is_confidential ($self) {
    return defined($self->private_key) && defined($self->key_id);
}

sub store ($self, @value) {
    # this is basically straight up setter 
    if (@value) {

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN


    return Mojo::ATProto::OAuth::ClientMetadata->build(
        client_id    => $self->client_id,
        callback_url => $self->callback_url,
        scopes       => $self->scopes,
        ($self->is_confidential ? (private_key => $self->private_key, key_id => $self->key_id) : ()),
    );
}

# The `client_assertion_type`/`client_assertion` form fields every
# confidential-client request (PAR, token exchange, refresh) needs -

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN

sub _client_assertion_params ($self, $audience) {
    return {} unless $self->is_confidential;
    return {
        client_assertion_type => 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
        client_assertion      => Mojo::ATProto::OAuth::DPoP->client_assertion(
            key       => $self->private_key,
            key_id    => $self->key_id,
            client_id => $self->client_id,
            audience  => $audience,
        ),
    };

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN


# Sends the PAR request that kicks off an authorization flow. Returns an
# AuthRequestData-equivalent hashref: state, auth_server_url, scopes,
# pkce_verifier, request_uri, auth_server_token_endpoint,
# auth_server_revocation_endpoint, dpop_authserver_nonce,
# dpop_private_key_pem - everything a store needs to persist and later
# exchange for tokens via send_initial_token_request(_p) below.
#
# $auth_meta is the hashref Mojo::ATProto::OAuth::Resolver::
# resolve_auth_server_metadata(_p) already validated. Low-level: doesn't
# persist anything or resolve an identity - see start_auth_flow(_p) for

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN

        pkce_verifier                    => $pkce_verifier,
        request_uri                      => $par_resp->{request_uri},
        auth_server_token_endpoint      => $auth_meta->{token_endpoint},
        auth_server_revocation_endpoint => $auth_meta->{revocation_endpoint},
        dpop_authserver_nonce           => $dpop_nonce,
        dpop_private_key_pem            => Mojo::ATProto::OAuth::DPoP->export_private_pem($dpop_key),
    };
}

sub send_auth_request_p($self, $auth_meta, %opts) {
    my $scopes     = _normalize_scopes($opts{scopes}) // $self->scopes;

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN

            pkce_verifier                   => $pkce_verifier,
            request_uri                     => $par_resp->{request_uri},
            auth_server_token_endpoint      => $auth_meta->{token_endpoint},
            auth_server_revocation_endpoint => $auth_meta->{revocation_endpoint},
            dpop_authserver_nonce           => $dpop_nonce,
            dpop_private_key_pem            => Mojo::ATProto::OAuth::DPoP->export_private_pem($dpop_key),
        };
    });
}

# Exchanges an authorization code for tokens. $info is the AuthRequestData-equivalent

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN

        code          => $auth_code,
        code_verifier => $info->{pkce_verifier},
        %{$self->_client_assertion_params($info->{auth_server_url})},
    };

    my $dpop_key = Mojo::ATProto::OAuth::DPoP->import_private_pem($info->{dpop_private_key_pem});
    my ($res, $dpop_nonce) = $self->_post_dpop_retry(
        url => $info->{auth_server_token_endpoint}, body => $body, key => $dpop_key,
        nonce => $info->{dpop_authserver_nonce}, label => 'initial token request',
    );

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN

        code          => $auth_code,
        code_verifier => $info->{pkce_verifier},
        %{$self->_client_assertion_params($info->{auth_server_url})},
    };

    my $dpop_key = Mojo::ATProto::OAuth::DPoP->import_private_pem($info->{dpop_private_key_pem});
    return $self->_post_dpop_retry_p(
        url => $info->{auth_server_token_endpoint}, body => $body, key => $dpop_key,
        nonce => $info->{dpop_authserver_nonce}, label => 'initial token request',
    )->then(sub ($res, $dpop_nonce) {
        die "initial token request failed (HTTP " . $res->code . "): " . $self->_parse_auth_error_reason($res) . "\n"

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN

        scopes                           => [split(/ /, $token_resp->{scope} // '')],
        access_token                     => $token_resp->{access_token},
        refresh_token                    => $token_resp->{refresh_token},
        dpop_authserver_nonce            => $token_resp->{dpop_authserver_nonce},
        dpop_host_nonce                  => $token_resp->{dpop_authserver_nonce},    # bootstrap host nonce from authserver
        dpop_private_key_pem             => $info->{dpop_private_key_pem},
        client_state                     => $info->{client_state},
        extra                            => $info->{extra},
    };
}

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN

        grant_type    => 'refresh_token',
        refresh_token => $session->{refresh_token},
        %{$self->_client_assertion_params($session->{auth_server_url})},
    };

    my $dpop_key = Mojo::ATProto::OAuth::DPoP->import_private_pem($session->{dpop_private_key_pem});
    my ($res, $dpop_nonce) = $self->_post_dpop_retry(
        url => $session->{auth_server_token_endpoint}, body => $body, key => $dpop_key,
        nonce => $session->{dpop_authserver_nonce}, label => 'token refresh',
    );
    die "token refresh failed (HTTP " . $res->code . "): " . $self->_parse_auth_error_reason($res) . "\n"

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN

        grant_type    => 'refresh_token',
        refresh_token => $session->{refresh_token},
        %{$self->_client_assertion_params($session->{auth_server_url})},
    };

    my $dpop_key = Mojo::ATProto::OAuth::DPoP->import_private_pem($session->{dpop_private_key_pem});
    return $self->_post_dpop_retry_p(
        url => $session->{auth_server_token_endpoint}, body => $body, key => $dpop_key,
        nonce => $session->{dpop_authserver_nonce}, label => 'token refresh',
    )->then(sub ($res, $dpop_nonce) {
        die "token refresh failed (HTTP " . $res->code . "): " . $self->_parse_auth_error_reason($res) . "\n"

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN


Default scopes requested by L</start_auth_flow> when no per-call C<scopes> opt is given. Defaults to C<['atproto']>.

Accepts either an arrayref of individual scope strings (C<['atproto', 'account:email']>) or a single space-separated string (C<'atproto account:email'>) - either form is normalized to the arrayref-of-tokens form internally, and always read back as on...

=head2 private_key

A L<Crypt::PK::ECC> private key, for a confidential client. C<undef> (the default) for a public client. Must be set together with L</key_id> - see L</is_confidential>.

=head2 key_id

The key ID matching L</private_key>. See L</is_confidential>.

=head2 loopback

Boolean, true for clients constructed via L</new_localhost>. Governs whether L</client_metadata> may be called (it dies for a loopback client - there is no document to serve).

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN

        ua                => $ua,              # optional
        user_agent_header => $header,          # optional
        store             => $store,           # optional
    );

Builds a client using ATProto OAuth's "loopback client" allowance for local-dev testing (ported from indigo's C<NewLocalhostConfig>): rather than a real C<https://> C<client_id> URL serving a fetched metadata document, C<client_id> is the fixed senti...

The C<client_id> host is the literal string C<localhost> - a fixed spec sentinel, not a real address to resolve. That is a separate thing from C<callback_url>, which must actually point at C<127.0.0.1> (not C<localhost>) for a plain-C<http> redirect ...

=head2 new

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN


=head2 is_confidential

    my $bool = $oauth->is_confidential;

True if both L</private_key> and L</key_id> are set.

=head2 client_metadata

    my $doc = $oauth->client_metadata;

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN

        scopes                          => [ 'atproto', ... ],
        access_token                    => '...',
        refresh_token                   => '...',
        dpop_authserver_nonce           => '...',
        dpop_host_nonce                 => '...',
        dpop_private_key_pem            => '...',                       # PEM, see Mojo::ATProto::OAuth::DPoP
        client_state                    => $opts_client_state,          # from start_auth_flow(_p), or undef
        extra                           => $opts_extra,                 # from start_auth_flow(_p), or undef
    }

If this auth request came from L</start_scope_upgrade>, C<session_id> here is the I<existing> session's id (not a new one) and C<scopes> is the union of the existing session's scopes and the newly-granted ones - see L</start_scope_upgrade> for why.

lib/Mojo/ATProto/OAuth.pm  view on Meta::CPAN


=head2 send_auth_request / send_auth_request_p

    my $info = $oauth->send_auth_request($auth_meta, %opts);

Sends the PAR request that kicks off an authorization flow, given already-validated auth-server metadata (as returned by L<Mojo::ATProto::OAuth::Resolver/resolve_auth_server_metadata>).  C<%opts>: C<scopes> (optional, arrayref or space-separated stri...

=head2 send_initial_token_request / send_initial_token_request_p

    my $token_resp = $oauth->send_initial_token_request($auth_code, $info);

 view all matches for this distribution


Mojo-GoogleAnalytics

 view release on metacpan or  search on metacpan

lib/Mojo/GoogleAnalytics.pm  view on Meta::CPAN

);

has authorization => sub { +{} };
has client_email  => sub { Carp::confess('client_email is required') };
has client_id     => sub { Carp::confess('client_id is required') };
has private_key   => sub { Carp::confess('private_key is required') };
has ua            => sub { Mojo::UserAgent->new(max_redirects => 3) };
has view_id => '';

sub authorize {
  my ($self, $cb) = @_;

lib/Mojo/GoogleAnalytics.pm  view on Meta::CPAN


  warn "[GoogleAnalytics] Authorization exp: @{[$prev->{exp} ? $prev->{exp} : -1]} < $time\n" if DEBUG;
  return if $prev->{exp} and $time < $prev->{exp};

  $ua_args[0] = Mojo::URL->new($self->{token_uri});
  $jwt = Mojo::JWT->new->algorithm('RS256')->secret($self->private_key);

  $jwt->claims({
    aud   => $ua_args[0]->to_string,
    exp   => $time + 3600,
    iat   => $time,

lib/Mojo/GoogleAnalytics.pm  view on Meta::CPAN


  $str = $self->client_id;

Example: "103742165385019792511".

=head2 private_key

  $str = $self->private_key;

Holds the content of a pem file that looks like this:

  -----BEGIN PRIVATE KEY-----
  ...

lib/Mojo/GoogleAnalytics.pm  view on Meta::CPAN

L<https://console.developers.google.com/apis/credentials>. Example file:

  {
    "type": "service_account",
    "project_id": "cool-project-238176",
    "private_key_id": "01234abc6780dc2a3284851423099daaad8cff92",
    "private_key": "-----BEGIN PRIVATE KEY-----...\n-----END PRIVATE KEY-----\n",
    "client_email": "some-name@cool-project-238176.iam.gserviceaccount.com",
    "client_id": "103742165385019792511",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://accounts.google.com/o/oauth2/token",
  }

 view all matches for this distribution


Mojo-JWT-Google

 view release on metacpan or  search on metacpan

lib/Mojo/JWT/Google.pm  view on Meta::CPAN

sub from_json {
  my ($self, $value) = @_;
  croak 'You did not pass a filename to from_json' if not defined $value;
  croak 'Cannot find file passed to from_json' if not -f $value;
  my $json = decode_json( path($value)->slurp );
  croak 'private key was not found in file passed to from_json' unless $json->{private_key};
  croak 'from_json only works with service accounts' if $json->{type} ne 'service_account';
  $self->algorithm('RS256');
  $self->secret($json->{private_key});
  $self->client_email($json->{client_email});
  return 1
}

sub as_form_data {

 view all matches for this distribution


Mojo-JWT

 view release on metacpan or  search on metacpan

lib/Mojo/JWT.pm  view on Meta::CPAN

sub _inflate_rsa_key {
  my ($key) = @_;
  require Crypt::PK::RSA;
  return $key if $key->$isa('Crypt::PK::RSA');
  if ($key->$isa('Crypt::OpenSSL::RSA')) {
    $key = $key->is_private ? $key->get_private_key_string : $key->get_public_key_string;
  }
  return Crypt::PK::RSA->new(\$key);
}

1;

 view all matches for this distribution


Mojo-SAML

 view release on metacpan or  search on metacpan

lib/Mojo/XMLSig.pm  view on Meta::CPAN


  use Mojo::XMLSig;

  # sign
  my $xml = ...;
  my $key = Crypt::OpenSSL::RSA->new_private_key(...);
  my $signed = Mojo::XMLSig::sign($xml, $key);

  # verify using an embedded certificate
  my $verified = Mojo::XMLSig::verify($signed);

 view all matches for this distribution


( run in 1.979 second using v1.01-cache-2.11-cpan-8dfa8b56332 )