Skip to content

Commit 9c761d6

Browse files
authored
Merge pull request #8 from Innmind/static-analysis
Use `innmind/static-analysis`
2 parents cc94437 + aed97ec commit 9c761d6

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
}
3232
},
3333
"require-dev": {
34-
"vimeo/psalm": "~5.6",
34+
"innmind/static-analysis": "^1.2.1",
3535
"innmind/black-box": "~6.5",
3636
"innmind/coding-standard": "~2.0"
3737
}

src/ViaBasicAuthorization.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ public function __invoke(ServerRequest $request): Attempt
3636
->filter(static fn($header) => $header->scheme() === 'Basic')
3737
->attempt(static fn() => new \RuntimeException('Failed to resolve identity'))
3838
->flatMap(function($header) {
39-
[$user, $password] = \explode(':', \base64_decode($header->parameter(), true));
39+
$string = \base64_decode($header->parameter(), true);
40+
41+
if (!\is_string($string)) {
42+
return Attempt::error(new \RuntimeException('Malformed authorization header parameter'));
43+
}
44+
45+
[$user, $password] = \explode(':', $string);
4046

4147
return ($this->resolve)($user, $password);
4248
});

0 commit comments

Comments
 (0)