Skip to content

Commit 8e51531

Browse files
committed
Remove unneeded AppID
1 parent 78e9411 commit 8e51531

File tree

6 files changed

+2
-38
lines changed

6 files changed

+2
-38
lines changed

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ With the following PHP code below, you can display a log in button that, when cl
1515
use Authwave\Authenticator;
1616
require __DIR__ . "/vendor/autoload.php";
1717

18-
// These constants can be loaded from your application's configuration
19-
// or environment variables. They are created in the remote Authwave provider.
20-
define("CLIENT_ID", "my-secure-application");
18+
// This constant can be loaded from your application's configuration
19+
// or environment variables. It is created in the remote Authwave provider.
2120
define("CLIENT_KEY", "1234567890abcdef");
2221

2322
// Construct the Authenticator class as soon as possible, as this handles the
2423
// Authentication steps passed via the query string from the remote provider.
2524
$auth = new Authenticator(
26-
CLIENT_ID,
2725
CLIENT_KEY,
2826
$_SERVER["REQUEST_URI"]
2927
);

src/Authenticator.php

-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ class Authenticator {
1818
private SessionContainer $session;
1919
private SessionData $sessionData;
2020
private RedirectHandler $redirectHandler;
21-
private string $clientId;
2221

2322
public function __construct(
24-
string $clientId,
2523
string $clientKey,
2624
string $currentUriPath,
2725
string $authwaveHost = "login.authwave.com",
@@ -38,7 +36,6 @@ public function __construct(
3836
$session->set(self::SESSION_KEY, new SessionData());
3937
}
4038

41-
$this->clientId = $clientId;
4239
$this->clientKey = $clientKey;
4340
$this->currentUriPath = $currentUriPath;
4441
$this->authwaveHost = $authwaveHost;
@@ -96,7 +93,6 @@ public function getEmail():string {
9693
public function getAuthUri(Token $token):AuthUri {
9794
return new AuthUri(
9895
$token,
99-
$this->clientId,
10096
$this->currentUriPath,
10197
$this->authwaveHost
10298
);

src/ProviderUri/AuthUri.php

-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Gt\Http\Uri;
66

77
class AuthUri extends AbstractProviderUri {
8-
const QUERY_STRING_ID = "id";
98
const QUERY_STRING_CIPHER = "cipher";
109
const QUERY_STRING_INIT_VECTOR = "iv";
1110
const QUERY_STRING_CURRENT_PATH = "path";
@@ -21,15 +20,13 @@ class AuthUri extends AbstractProviderUri {
2120
*/
2221
public function __construct(
2322
Token $token,
24-
string $clientId,
2523
string $currentPath = "/",
2624
string $baseRemoteUri = self::DEFAULT_BASE_REMOTE_URI
2725
) {
2826
$baseRemoteUri = $this->normaliseBaseUri($baseRemoteUri);
2927
parent::__construct($baseRemoteUri);
3028

3129
$this->query = http_build_query([
32-
self::QUERY_STRING_ID => $clientId,
3330
self::QUERY_STRING_CIPHER => (string)$token->generateRequestCipher(),
3431
self::QUERY_STRING_INIT_VECTOR => (string)$token->getIv(),
3532
self::QUERY_STRING_CURRENT_PATH => $currentPath,

test/phpunit/AuthenticatorTest.php

-21
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class AuthenticatorTest extends TestCase {
1919
public function testConstructWithDefaultSessionNotStarted() {
2020
self::expectException(SessionNotStartedException::class);
2121
new Authenticator(
22-
"example-app-id",
2322
"test-key",
2423
"/"
2524
);
@@ -28,7 +27,6 @@ public function testConstructWithDefaultSessionNotStarted() {
2827
public function testConstructWithDefaultSession() {
2928
$_SESSION = [];
3029
new Authenticator(
31-
"example-app-id",
3230
"test-key",
3331
"/"
3432
);
@@ -41,7 +39,6 @@ public function testConstructWithDefaultSession() {
4139
public function testIsLoggedInFalseByDefault() {
4240
$_SESSION = [];
4341
$sut = new Authenticator(
44-
"example-app-id",
4542
"test-key",
4643
"/"
4744
);
@@ -60,7 +57,6 @@ public function testIsLoggedInTrueWhenSessionDataSet() {
6057
];
6158

6259
$sut = new Authenticator(
63-
"example-app-id",
6460
"test-key",
6561
"/"
6662
);
@@ -76,7 +72,6 @@ public function testLogoutClearsSession() {
7672
$redirectHandler = self::createMock(RedirectHandler::class);
7773

7874
$sut = new Authenticator(
79-
"example-app-id",
8075
"test-key",
8176
"/",
8277
AuthUri::DEFAULT_BASE_REMOTE_URI,
@@ -101,7 +96,6 @@ public function testLogoutRedirectsToCurrentPath() {
10196
));
10297

10398
$sut = new Authenticator(
104-
"example-app-id",
10599
"test-key",
106100
$currentPath,
107101
AuthUri::DEFAULT_BASE_REMOTE_URI,
@@ -122,7 +116,6 @@ public function testLoginRedirects() {
122116
));
123117

124118
$sut = new Authenticator(
125-
"example-app-id",
126119
"test-key",
127120
"/",
128121
AuthUri::DEFAULT_BASE_REMOTE_URI,
@@ -145,7 +138,6 @@ public function testLoginRedirectsLocalhost() {
145138
));
146139

147140
$sut = new Authenticator(
148-
"example-app-id",
149141
"test-key",
150142
"/",
151143
"http://localhost:8081",
@@ -161,7 +153,6 @@ public function testLoginRedirectsWithCorrectQueryString() {
161153
$key = uniqid("key-");
162154
$currentPath = uniqid("/path/");
163155

164-
$id = "example-app-id";
165156
$cipher = "example-cipher";
166157
$ivString = "example-iv";
167158

@@ -176,7 +167,6 @@ public function testLoginRedirectsWithCorrectQueryString() {
176167
->willReturn($iv);
177168

178169
$expectedQueryParts = [
179-
AuthUri::QUERY_STRING_ID => $id,
180170
AuthUri::QUERY_STRING_CIPHER => $cipher,
181171
AuthUri::QUERY_STRING_INIT_VECTOR => $ivString,
182172
AuthUri::QUERY_STRING_CURRENT_PATH => $currentPath,
@@ -191,7 +181,6 @@ public function testLoginRedirectsWithCorrectQueryString() {
191181
));
192182

193183
$sut = new Authenticator(
194-
$id,
195184
$key,
196185
$currentPath,
197186
AuthUri::DEFAULT_BASE_REMOTE_URI,
@@ -212,7 +201,6 @@ public function testLoginDoesNothingWhenAlreadyLoggedIn() {
212201
->method("redirect");
213202

214203
$sut = new Authenticator(
215-
"example-app-id",
216204
"test-key",
217205
"/",
218206
AuthUri::DEFAULT_BASE_REMOTE_URI,
@@ -226,7 +214,6 @@ public function testLoginDoesNothingWhenAlreadyLoggedIn() {
226214
public function testGetUuidThrowsExceptionWhenNotLoggedIn() {
227215
$_SESSION = [];
228216
$sut = new Authenticator(
229-
"example-app-id",
230217
"test-key",
231218
"/"
232219
);
@@ -248,7 +235,6 @@ public function testGetUuid() {
248235
Authenticator::SESSION_KEY => $sessionData,
249236
];
250237
$sut = new Authenticator(
251-
"example-app-id",
252238
"test-key",
253239
"/"
254240
);
@@ -258,7 +244,6 @@ public function testGetUuid() {
258244
public function testGetEmailThrowsExceptionWhenNotLoggedIn() {
259245
$_SESSION = [];
260246
$sut = new Authenticator(
261-
"example-app-id",
262247
"test-key",
263248
"/"
264249
);
@@ -280,7 +265,6 @@ public function testGetEmail() {
280265
Authenticator::SESSION_KEY => $sessionData,
281266
];
282267
$sut = new Authenticator(
283-
"example-app-id",
284268
"test-key",
285269
"/"
286270
);
@@ -295,7 +279,6 @@ public function testCompleteAuthNotLoggedIn() {
295279
$_SESSION = [];
296280
self::expectException(NotLoggedInException::class);
297281
new Authenticator(
298-
"example-app-id",
299282
"test-key",
300283
$currentUri
301284
);
@@ -328,7 +311,6 @@ public function testCompleteAuth() {
328311
Authenticator::SESSION_KEY => $sessionData,
329312
];
330313
new Authenticator(
331-
"example-app-id",
332314
"test-key",
333315
$currentUri,
334316
AuthUri::DEFAULT_BASE_REMOTE_URI,
@@ -356,7 +338,6 @@ public function testCompleteAuthNotAffectedByQueryString() {
356338
$_SESSION = [];
357339

358340
new Authenticator(
359-
"example-app-id",
360341
"test-key",
361342
"/example-path?filter=something",
362343
AuthUri::DEFAULT_BASE_REMOTE_URI,
@@ -368,7 +349,6 @@ public function testCompleteAuthNotAffectedByQueryString() {
368349
public function testGetAdminUri() {
369350
$_SESSION = [];
370351
$auth = new Authenticator(
371-
"example-app-id",
372352
"test-key",
373353
"/example-path",
374354
AuthUri::DEFAULT_BASE_REMOTE_URI
@@ -383,7 +363,6 @@ public function testGetAdminUri() {
383363
public function testGetAdminUriCustom() {
384364
$_SESSION = [];
385365
$auth = new Authenticator(
386-
"example-app-id",
387366
"test-key",
388367
"/example-path",
389368
AuthUri::DEFAULT_BASE_REMOTE_URI

test/phpunit/ProviderUri/AbstractProviderUriTest.php

-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public function testAuthUriHttps() {
1717

1818
$sut = new AuthUri(
1919
$token,
20-
"example-app-id",
2120
"",
2221
$baseUri
2322
);
@@ -33,7 +32,6 @@ public function testGetAuthUriHostnameLocalhostHttpsByDefault() {
3332
$token = self::createMock(Token::class);
3433
$sut = new AuthUri(
3534
$token,
36-
"example-app-id",
3735
"/",
3836
"localhost"
3937
);
@@ -49,7 +47,6 @@ public function testGetAuthUriHostnameLocalhostHttpAllowed() {
4947
$token = self::createMock(Token::class);
5048
$sut = new AuthUri(
5149
$token,
52-
"example-app-id",
5350
"/",
5451
"http://localhost"
5552
);
@@ -65,7 +62,6 @@ public function testGetAuthUriHostnameNotLocalhostHttpNotAllowed() {
6562
self::expectException(InsecureProtocolException::class);
6663
new AuthUri(
6764
$token,
68-
"example-app-id",
6965
"/",
7066
"http://localhost.com"
7167
);
@@ -80,7 +76,6 @@ public function testAuthUriHttpsInferred() {
8076

8177
$sut = new AuthUri(
8278
$token,
83-
"example-app-id",
8479
"/",
8580
$baseUri);
8681

test/phpunit/ProviderUri/AuthUriTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public function testQueryString() {
2525
$returnPath = "/examplePage";
2626
$sut = new AuthUri(
2727
$token,
28-
"example-app-id",
2928
$returnPath,
3029
$baseUri
3130
);

0 commit comments

Comments
 (0)