aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2014-12-30 10:45:58 +0000
committerdakkar <dakkar@thenautilus.net>2014-12-30 10:45:58 +0000
commit5b9e381988ca256d7fc49106c1b0feb18e32fd59 (patch)
treec9f42e0743d4e52ea6f9f02202ad070f120dec04
parentin p6 .= is spelled ~= (diff)
downloadnet-hawk-5b9e381988ca256d7fc49106c1b0feb18e32fd59.tar.gz
net-hawk-5b9e381988ca256d7fc49106c1b0feb18e32fd59.tar.bz2
net-hawk-5b9e381988ca256d7fc49106c1b0feb18e32fd59.zip
whitespace fixes
-rw-r--r--lib/Net/Hawk/Client.pm109
1 files changed, 55 insertions, 54 deletions
diff --git a/lib/Net/Hawk/Client.pm b/lib/Net/Hawk/Client.pm
index 288252c..5f649c4 100644
--- a/lib/Net/Hawk/Client.pm
+++ b/lib/Net/Hawk/Client.pm
@@ -64,9 +64,9 @@ package Net::Hawk::Client {
%artifacts<ts>,
%artifacts<nonce>,
)
- ~ (%artifacts<hash> ?? sprintf(', hash="%s"',%artifacts<hash>) !! '')
- ~ ($has_ext ?? sprintf(', ext="%s"', %artifacts<ext>.trans(['\\','"']=>['\\\\','\\"']) ) !! '' )
- ~ sprintf(', mac="%s"',$mac);
+ ~ (%artifacts<hash> ?? sprintf(', hash="%s"',%artifacts<hash>) !! '')
+ ~ ($has_ext ?? sprintf(', ext="%s"', %artifacts<ext>.trans(['\\','"']=>['\\\\','\\"']) ) !! '' )
+ ~ sprintf(', mac="%s"',$mac);
if (%artifacts<app>) {
$header ~= sprintf(', app="%s"', %artifacts<app>);
@@ -79,69 +79,70 @@ package Net::Hawk::Client {
field => $header,
artifacts => %artifacts,
};
- }
+ };
- my sub get_header(Str:D $key, @headers) returns Str {
- @headers \
- ==> grep { .key eq $key } \
- ==> map { .value } \
- ==> join ',';
- }
- our sub authenticate(
+ my sub get_header(Str:D $key, @headers) returns Str {
+ @headers \
+ ==> grep { .key eq $key } \
+ ==> map { .value } \
+ ==> join ',';
+ };
+ our sub authenticate(
Array:D $headers,
Hash:D $credentials,
- Hash $artifacts?,
- Hash $options?,
- ) returns Bool {
-
- my $www_auth = get_header('www-authenticate',$headers);
-
- if ($www_auth) {
- my $attributes = try {
- $attributes = parse_authorization_header(
- $www_auth,<ts tsm error>,
- );
- };
- return False unless $attributes;
-
- if ($attributes<ts>) {
- my $tsm = calculate_ts_mac(
- +$attributes<ts>,$credentials,
- );
- return False unless $tsm eq $attributes<tsm>;
- }
- }
+ Hash $artifacts?,
+ Hash $options?,
+ ) returns Bool {
- my $serv_auth = get_header('server-authorization',$headers);
- return True unless $serv_auth || $options<required>;
+ my $www_auth = get_header('www-authenticate',$headers);
+ if ($www_auth) {
my $attributes = try {
- parse_authorization_header(
- $serv_auth,
- <mac ext hash>,
+ $attributes = parse_authorization_header(
+ $www_auth,<ts tsm error>,
);
};
return False unless $attributes;
- my $mac = calculate_mac(
- 'response',
- $credentials,
- %(
- %$artifacts,
- ext => $attributes<ext>,
- hash => $attributes<hash>,
- ),
- );
- return False unless $mac eq $attributes<mac>;
+ if ($attributes<ts>) {
+ my $tsm = calculate_ts_mac(
+ +$attributes<ts>,$credentials,
+ );
+ return False unless $tsm eq $attributes<tsm>;
+ }
+ }
- return True unless defined $options<payload>;
- return False unless $attributes<hash>;
+ my $serv_auth = get_header('server-authorization',$headers);
+ return True unless $serv_auth || $options<required>;
- my $calculated_hash = calculate_payload_hash(
- $options<payload>,
- $credentials<algorithm>,
- get_header('content-type',$headers),
+ my $attributes = try {
+ parse_authorization_header(
+ $serv_auth,
+ <mac ext hash>,
);
- return $calculated_hash eq $attributes<hash>;
};
+ return False unless $attributes;
+
+ my $mac = calculate_mac(
+ 'response',
+ $credentials,
+ %(
+ %$artifacts,
+ ext => $attributes<ext>,
+ hash => $attributes<hash>,
+ ),
+ );
+ return False unless $mac eq $attributes<mac>;
+
+ return True unless defined $options<payload>;
+ return False unless $attributes<hash>;
+
+ my $calculated_hash = calculate_payload_hash(
+ $options<payload>,
+ $credentials<algorithm>,
+ get_header('content-type',$headers),
+ );
+ return $calculated_hash eq $attributes<hash>;
+ };
+
}