Skip to content

Commit 5f56e26

Browse files
author
Greg Bowler
committed
Simplify decryption data
1 parent 0dcae09 commit 5f56e26

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/Authenticator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function getAdminUri(
109109

110110
public function getLogoutUri(string $returnToPath = null):UriInterface {
111111
if(is_null($returnToPath)) {
112-
$returnToPath = $this->currentUriPath;
112+
$returnToPath = (new Uri($this->currentUriPath))->getPath();
113113
}
114114

115115
return new LogoutUri($this->authwaveHost, $returnToPath);

src/Token.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22
namespace Authwave;
33

4-
use JsonException;
5-
64
class Token {
75
const ENCRYPTION_METHOD = "aes128";
86

@@ -48,25 +46,22 @@ public function decryptResponseCipher(string $cipher):UserData {
4846
$decrypted = openssl_decrypt(
4947
base64_decode($cipher),
5048
self::ENCRYPTION_METHOD,
51-
implode("|", [
52-
$this->key,
53-
$this->secretIv->getBytes(),
54-
]),
49+
$this->key,
5550
0,
56-
$this->iv->getBytes()
51+
$this->secretIv->getBytes()
5752
);
5853

5954
if(!$decrypted) {
6055
throw new ResponseCipherDecryptionException();
6156
}
6257

63-
$obj = unserialize(
58+
$data = unserialize(
6459
$decrypted
6560
);
66-
if($obj === false) {
61+
if($data === false) {
6762
throw new InvalidUserDataSerializationException();
6863
}
6964

70-
return new UserData($obj->uuid, $obj->email);
65+
return new UserData($data["uuid"], $data["email"]);
7166
}
7267
}

0 commit comments

Comments
 (0)