attraction/google-iap-authentication
Authenticate users using Google IAP
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
Maintainers
Package info
github.com/attrdev/google-iap-authentication
pkg:composer/attraction/google-iap-authentication
Requires
- php: >=7.3
- google/auth: ^1.12
- google/cloud-core: ^1.39
- kelvinmo/simplejwt: ^0.4.1
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
MIT 7a4a379bf79568a77c1502bdae10a66bdf9c1fd5
- Frederic Houle <frederic.woop@frederichoule.com>
Authenticationlogingooglepermissionsiamiapgcpgoogle-cloudgoogle-iapgoogle-iam
This package is auto-updated.
Last update: 2024-05-14 00:13:56 UTC
README
A simple class to help you authenticate the users accessing your ressources thru Google Identity-Aware Proxy.
Installation
It's recommended that you use Composer to install google-iap-authentication.
$ composer require attraction/google-iap-authentication:^2.0
This will install google-iap-authentication and all required dependencies. google-iap-authentication requires PHP 7.3 or newer.
Usage
use Attraction\GoogleIAPAuthentication; // Project ID and Number are available in Google Cloud Project Settings - https://console.cloud.google.com/iam-admin/settings $projectId = 'YOUR_PROJECT_ID'; $projectNumber = 'YOUR_PROJECT_NUMBER'; // You can also use your preferred framework to fetch the headers, here we use getallheaders() to make it simple. $idToken = getallheaders()['X-Goog-Iap-Jwt-Assertion'] ?? ''; $iap = new GoogleIAPAuthentication($projectId, $projectNumber); try { $user = $iap->validateAssertion($idToken); } catch(Throwable $e) { print(sprintf('Unable to proceed: %s',$e->getMessage())); } print(sprintf('User logged in - Email Address: %s - User ID: %s',$user->emailAddress,$user->userId));
