In this blog, we will add user authentication to a simple PHP web application with Akamai Identity Cloud. The primary use case is user registration and log in or out from a simple PHP application. In this example, we will use the OpenID Connect (OIDC) Authorization Code flow built into Akamai Identity Cloud as illustrated below.
You can complete the login life cycle for a simple PHP web app in just five steps.
Step 1. Gather Your Details
Gather your details from the Akamai Identity Cloud console, where the following are the arbitrary values:
Step 2. Configure PHP to Use Akamai Identity Cloud
Here you need to fill all of the values in a PHP configuration file (config_aic.php) as shown below. Simply create PHP constants to put all the values that we gathered in Step 1.
Step 3. Trigger Authentication
Let’s trigger the authorization endpoint to have a login link for the PHP application. This code will go to another file of index.php, which includes the config_aic.php file.
A sign-in link is triggered:
Pressing the sign-in button will bring up Akamai’s pre-built hosted login page:
At this point, you can register a Generic User (John Doe) as follows:
Complete the display name, email address, desired password, and confirm the password
- Now John Doe is registered and displayed
The login process is just as simple:
Insert user name and password
- John Doe is registered and displayed
After registration or login, users are redirected to a “welcome.php” page where authentication transpires:
Exchanging access token with authorization code
- Using that access token to access user information from OIDC user info endpoint
Step 4. Display User Information
Here, user information is fetched and displayed by calling the OIDC user info endpoint.
Step 5. Logout
As shown above, you can logout from the PHP application by pressing the "Logout" link. The link button is backed by the logout URL, resulting in the following pop-up:
For more coding examples of PHP with OIDC client and server visit:
You Might Also Like
Learn More: https://developer.akamai.com/identity-cloud
Get started: https://identitydocs.akamai.com/getting-started/
Browse Resources: https://developer.akamai.com/akamai-identity-cloud-resources