@@ -15,15 +15,17 @@ With the following PHP code below, you can display a log in button that, when cl
15
15
use Authwave\Authenticator;
16
16
require __DIR__ . "/vendor/autoload.php";
17
17
18
- // This constant can be loaded from your application's configuration
19
- // or environment variables. They are supplied by the remote Authwave provider.
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");
20
21
define("CLIENT_KEY", "1234567890abcdef");
21
22
22
23
// Construct the Authenticator class as soon as possible, as this handles the
23
24
// Authentication steps passed via the query string from the remote provider.
24
25
$auth = new Authenticator(
25
- CLIENT_KEY, // See above
26
- $_SERVER["REQUEST_URI"]
26
+ CLIENT_ID,
27
+ CLIENT_KEY,
28
+ $_SERVER["REQUEST_URI"]
27
29
);
28
30
29
31
// Handle authentication login/logout action via the querystring:
@@ -32,24 +34,24 @@ if(isset($_GET["login"])) {
32
34
// remote provider. The remote provider will in turn redirect the user agent
33
35
// back to the return URI (set as 3rd parameter of Authenticator's constructor),
34
36
// at which point the user will be considered authenticated.
35
- $auth->login();
37
+ $auth->login();
36
38
}
37
39
elseif(isset($_GET["logout"])) {
38
- $auth->logout();
40
+ $auth->logout();
39
41
}
40
42
41
43
// Authentication is handled by Authwave, so you can trust "isLoggedIn"
42
44
// as a mechanism for protecting your sensitive information.
43
45
if($auth->isLoggedIn()) {
44
- echo <<<HTML
45
- <p >You are logged in as <strong >{$auth->getEmail()}</strong ></p >
46
- <p ><a href =" ?logout" >Log out</a ></p >
47
- HTML;
46
+ echo <<<HTML
47
+ <p >You are logged in as <strong >{$auth->getEmail()}</strong ></p >
48
+ <p ><a href =" ?logout" >Log out</a ></p >
49
+ HTML;
48
50
}
49
51
else {
50
- echo <<<HTML
51
- <p >You are not logged in!</p >
52
- <p ><a href =" ?login" >Log in</a ></p >
53
- HTML;
52
+ echo <<<HTML
53
+ <p >You are not logged in!</p >
54
+ <p ><a href =" ?login" >Log in</a ></p >
55
+ HTML;
54
56
}
55
57
```
0 commit comments