Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coloredcow/laravel-gsuite
A Laravel package to setup Google OAuth and GSuite Admin SDK.
https://github.com/coloredcow/laravel-gsuite
google google-api gsuite laravel
Last synced: 5 days ago
JSON representation
A Laravel package to setup Google OAuth and GSuite Admin SDK.
- Host: GitHub
- URL: https://github.com/coloredcow/laravel-gsuite
- Owner: ColoredCow
- License: mit
- Created: 2018-07-25T13:00:14.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-06-27T07:59:38.000Z (6 months ago)
- Last Synced: 2024-12-16T20:46:30.015Z (22 days ago)
- Topics: google, google-api, gsuite, laravel
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 18
- Watchers: 2
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel GSuite
A Laravel package to setup Google OAuth and GSuite Admin SDK.## Installation
You can install the package using composer
```
composer require coloredcow/laravel-gsuite
```Publish the configurations
```
php artisan vendor:publish --provider="ColoredCow\LaravelGSuite\Providers\GSuiteServiceProvider" --tag="config"
```## Setting up Google Oauth
Update your .env file with the Google OAuth 2.0 credentials
```
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_CLIENT_CALLBACK=your_google_callback_url
```**NOTE:** If you wish to restrict users to your organization's domain, add to your .env
```
GOOGLE_CLIENT_HD=your_domain
```Inside your `app/Http/Controllers/Auth/LoginController.php`, use the package trait `GSuiteLogin`
```php
getName(); // Jon Snow
echo $user->getJoinedOn(); // 2016-12-26 12:15:00
echo $user->getDesignation(); // Lord Commander
```## Enabling multitenancy
There are some additional steps required in case your application supports multitenancy.Set multitenancy to **true** in your `config/gsuite.php`
```php
'multitenancy' => true,
```The default value for tenant connection is `tenant`. If you're using a different name for tenant connection, update `config/gsuite.php`
```php
'connections' => [
'tenant' => 'tenant_connection',
]
```Since you'll have multiple tenants, and you may need different GSuite API credentials for each of them, the package will create a table in each tenant database. This table will store the required gsuite credentials.
Publish the tenant specific migrations using the following command. This will publish the migrations into `database/migrations/tenant` directory.
```
php artisan vendor:publish --provider="ColoredCow\LaravelGSuite\Providers\GSuiteServiceProvider" --tag="multitenancy"
```
Now, create your tenant databases.**NOTE:** If you already have existing tenants, you may need to recreate those tenant databases. You may lose some data if not done carefully.
In every tenant database, you need to define the application credentials and service account impersonate user. You can add a seeder to your multitenancy implementation so that it runs everytime a new tenant database is created.
Your `gsuite_configurations` table should look this
|id|key|value|created_at|updated_at|
|-|-|-|-|-|
|1|application_credentials|full_path_to_credentials.json|2018-06-06 16:00:00|2018-06-06 16:00:00|
|2|service_account_impersonate|`[email protected]`|2018-06-06 16:00:00|2018-06-06 16:00:00|### More multitenancy configurations
If you prefer to have a different name for the `gsuite_configurations` table, update `config/gsuite.php`
```php
'tables' => [
'tenant' => [
'gsuite-configurations' => 'your_gsuite_table_name',
]
]
```If you prefer to override the package's `GSuiteConfiguration` model, create a custom model that must implement the `ColoredCow\LaravelGSuite\Contracts\Tenant\GSuiteConfiguration` contract. Then, update your `config/gsuite.php` and replace the default model with the new model.
```php
'models' => [
'tenant' => [
'gsuite-configuration' => App\YourModelName::class
]
]
```