Skip to content

Commit

Permalink
Support Server-Based Configs
Browse files Browse the repository at this point in the history
  • Loading branch information
timcortesi committed Jun 1, 2018
1 parent afcf1d8 commit 1d662e0
Show file tree
Hide file tree
Showing 16 changed files with 214 additions and 194 deletions.
9 changes: 9 additions & 0 deletions .ebextensions/01migrate.config
@@ -0,0 +1,9 @@
container_commands:
artisanmigrate:
command: "php artisan migrate"
leader_only: true
artisanmigratemodules:
command: "php artisan modules:migrate"
leader_only: true
set_time_zone:
command: "ln -f -s /usr/share/zoneinfo/US/Eastern /etc/localtime"
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -7,3 +7,8 @@ Homestead.json
.vscode

config/database.php

# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml
7 changes: 4 additions & 3 deletions app/Http/Controllers/AppInstanceController.php
Expand Up @@ -337,9 +337,10 @@ public function get_data(AppInstance $app_instance, $endpoint_name, Request $req

if ($endpoint->type == 'http_no_auth' || $endpoint->type == 'http_basic_auth') {
$data = $this->http_endpoint($endpoint, $resource_app, $verb, $all_data, $app_instance->id);
} else if ($endpoint->type == 'google_sheets') {
$data = $this->google_endpoint($endpoint, $resource_app, $verb, $all_data);
}
}
// else if ($endpoint->type == 'google_sheets') {
// $data = $this->google_endpoint($endpoint, $resource_app, $verb, $all_data);
// }
return $data;
}

Expand Down
41 changes: 21 additions & 20 deletions app/Http/Controllers/EndpointController.php
Expand Up @@ -35,17 +35,18 @@ public function create(Request $request)
$endpoint->group_id = $request->get('group_id');
if ($endpoint->type == 'http_basic_auth' || $endpoint->type == 'http_no_auth') {
$endpoint->save();
} else if ($endpoint->type == 'google_sheets') {
$endpoint->save();
$googleClient = new \PulkitJalan\Google\Client(config('google'));
$client = $googleClient->getClient();
$client->setState(base64_encode(json_encode(['endpoint_id'=>$endpoint->id])));
$client->setAccessType('offline'); // required to get refresh access token!
$client->setPrompt('consent'); // required to get refresh access token!
$authUrl = $client->createAuthUrl();
$endpoint->config->google_redirect = $authUrl;
$endpoint->save();
}
}
// else if ($endpoint->type == 'google_sheets') {
// $endpoint->save();
// $googleClient = new \PulkitJalan\Google\Client(config('google'));
// $client = $googleClient->getClient();
// $client->setState(base64_encode(json_encode(['endpoint_id'=>$endpoint->id])));
// $client->setAccessType('offline'); // required to get refresh access token!
// $client->setPrompt('consent'); // required to get refresh access token!
// $authUrl = $client->createAuthUrl();
// $endpoint->config->google_redirect = $authUrl;
// $endpoint->save();
// }
return $endpoint;
}

Expand All @@ -62,13 +63,13 @@ public function destroy(Endpoint $endpoint)
}
}

public function google_callback(Request $request) {
$state = json_decode(base64_decode($request->state),true);
$endpoint = Endpoint::find($state['endpoint_id']);
$googleClient = new \PulkitJalan\Google\Client(config('google'));
$client = $googleClient->getClient();
$endpoint->config->secret = $client->fetchAccessTokenWithAuthCode($request->code);
$endpoint->config->google_redirect = 'Successfully Configured';
$endpoint->save();
}
// public function google_callback(Request $request) {
// $state = json_decode(base64_decode($request->state),true);
// $endpoint = Endpoint::find($state['endpoint_id']);
// $googleClient = new \PulkitJalan\Google\Client(config('google'));
// $client = $googleClient->getClient();
// $endpoint->config->secret = $client->fetchAccessTokenWithAuthCode($request->code);
// $endpoint->config->google_redirect = 'Successfully Configured';
// $endpoint->save();
// }
}
1 change: 1 addition & 0 deletions app/Http/Controllers/ImageController.php
Expand Up @@ -21,6 +21,7 @@ public function __construct()

public function get(Image $image) {
session_write_close();
// response()->header('Cache-Control', 'no-cache, must-revalidate');
$headers = [
"Cache-Control"=>"max-age=86400",
"Pragma"=>"cache",
Expand Down
13 changes: 7 additions & 6 deletions config/app.php
Expand Up @@ -15,7 +15,7 @@
| any other location as required by the application or its packages.
*/

'name' => 'Laravel',
'name' => 'Graphene',

/*
|--------------------------------------------------------------------------
Expand All @@ -28,7 +28,7 @@
|
*/

'env' => env('APP_ENV', 'local'),
'env' => env('APP_ENV', isset($_SERVER['APP_ENV'])?$_SERVER['APP_ENV']:'local'),

/*
|--------------------------------------------------------------------------
Expand All @@ -41,7 +41,7 @@
|
*/

'debug' => env('APP_DEBUG', true),
'debug' => env('APP_DEBUG', isset($_SERVER['APP_DEBUG'])?$_SERVER['APP_DEBUG']:true),

/*
|--------------------------------------------------------------------------
Expand All @@ -67,7 +67,7 @@
|
*/

'timezone' => 'EST',
'timezone' => env('APP_TIMEZONE',isset($_SERVER['APP_TIMEZONE'])?$_SERVER['APP_TIMEZONE']:'EST'),

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -106,10 +106,11 @@
|
*/

'key' => env('APP_KEY','base64:SCguh35vL7jDEyLDEV8SqhXYM7Y4+2K+AYkvZXqCNgA='),

'key' => env('APP_KEY',isset($_SERVER['APP_KEY'])?$_SERVER['APP_KEY']:'base64:SCguh35vL7jDEyLDEV8SqhXYM7Y4+2K+AYkvZXqCNgA='),
'cipher' => 'AES-256-CBC',

'key_portal' => env('APP_KEY_PORTAL',isset($_SERVER['APP_KEY_PORTAL'])?$_SERVER['APP_KEY_PORTAL']:''),

/*
|--------------------------------------------------------------------------
| Logging Configuration
Expand Down
112 changes: 56 additions & 56 deletions config/broadcasting.php
@@ -1,58 +1,58 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Default Broadcaster
|--------------------------------------------------------------------------
|
| This option controls the default broadcaster that will be used by the
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
| Supported: "pusher", "redis", "log", "null"
|
*/

'default' => env('BROADCAST_DRIVER', 'null'),

/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/

'connections' => [

'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_KEY'),
'secret' => env('PUSHER_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
//
],
],

'redis' => [
'driver' => 'redis',
'connection' => 'default',
],

'log' => [
'driver' => 'log',
],

'null' => [
'driver' => 'null',
],

],

];
// return [

// /*
// |--------------------------------------------------------------------------
// | Default Broadcaster
// |--------------------------------------------------------------------------
// |
// | This option controls the default broadcaster that will be used by the
// | framework when an event needs to be broadcast. You may set this to
// | any of the connections defined in the "connections" array below.
// |
// | Supported: "pusher", "redis", "log", "null"
// |
// */

// 'default' => env('BROADCAST_DRIVER', 'null'),

// /*
// |--------------------------------------------------------------------------
// | Broadcast Connections
// |--------------------------------------------------------------------------
// |
// | Here you may define all of the broadcast connections that will be used
// | to broadcast events to other systems or over websockets. Samples of
// | each available type of connection are provided inside this array.
// |
// */

// 'connections' => [

// 'pusher' => [
// 'driver' => 'pusher',
// 'key' => env('PUSHER_KEY'),
// 'secret' => env('PUSHER_SECRET'),
// 'app_id' => env('PUSHER_APP_ID'),
// 'options' => [
// //
// ],
// ],

// 'redis' => [
// 'driver' => 'redis',
// 'connection' => 'default',
// ],

// 'log' => [
// 'driver' => 'log',
// ],

// 'null' => [
// 'driver' => 'null',
// ],

// ],

// ];
68 changes: 34 additions & 34 deletions config/cache.php
Expand Up @@ -30,48 +30,48 @@

'stores' => [

'apc' => [
'driver' => 'apc',
],
// 'apc' => [
// 'driver' => 'apc',
// ],

'array' => [
'driver' => 'array',
],
// 'array' => [
// 'driver' => 'array',
// ],

'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
],
// 'database' => [
// 'driver' => 'database',
// 'table' => 'cache',
// 'connection' => null,
// ],

'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache'),
],

'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
// 'memcached' => [
// 'driver' => 'memcached',
// 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
// 'sasl' => [
// env('MEMCACHED_USERNAME'),
// env('MEMCACHED_PASSWORD'),
// ],
// 'options' => [
// // Memcached::OPT_CONNECT_TIMEOUT => 2000,
// ],
// 'servers' => [
// [
// 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
// 'port' => env('MEMCACHED_PORT', 11211),
// 'weight' => 100,
// ],
// ],
// ],

'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
// 'redis' => [
// 'driver' => 'redis',
// 'connection' => 'default',
// ],

],

Expand All @@ -86,6 +86,6 @@
|
*/

'prefix' => 'laravel',
'prefix' => 'graphene',

];
26 changes: 14 additions & 12 deletions config/database.php
Expand Up @@ -54,25 +54,26 @@

'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'crazystairs'),
'username' => env('DB_USERNAME', 'crazystairs'),
'password' => env('DB_PASSWORD', 'crazystairs'),
'host' => env('DB_HOST', isset($_SERVER['DB_HOST'])?$_SERVER['DB_HOST']:'127.0.0.1'),
'port' => env('DB_PORT', isset($_SERVER['DB_PORT'])?$_SERVER['DB_PORT']:'3306'),
'database' => env('DB_DATABASE', isset($_SERVER['DB_DATABASE'])?$_SERVER['DB_DATABASE']:'crazystairs'),
'username' => env('DB_USERNAME', isset($_SERVER['DB_USERNAME'])?$_SERVER['DB_USERNAME']:'crazystairs'),
'password' => env('DB_PASSWORD', isset($_SERVER['DB_PASSWORD'])?$_SERVER['DB_PASSWORD']:'crazystairs'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],

// This is specifically for running a migration from legacy myBinghamton database. Will be removed.
'mysql-portal' => [
'driver' => 'mysql',
'host' => env('PORTAL_DB_HOST', '127.0.0.1'),
'port' => env('PORTAL_DB_PORT', '3306'),
'database' => env('PORTAL_DB_DATABASE', 'portal'),
'username' => env('PORTAL_DB_USERNAME', 'crazystairs'),
'password' => env('PORTAL_DB_PASSWORD', 'crazystairs'),
'host' => env('PORTAL_DB_HOST', isset($_SERVER['PORTAL_DB_HOST'])?$_SERVER['PORTAL_DB_HOST']:'127.0.0.1'),
'port' => env('PORTAL_DB_PORT', isset($_SERVER['PORTAL_DB_PORT'])?$_SERVER['PORTAL_DB_PORT']:'3306'),
'database' => env('PORTAL_DB_DATABASE', isset($_SERVER['PORTAL_DB_DATABASE'])?$_SERVER['PORTAL_DB_DATABASE']:'portal'),
'username' => env('PORTAL_DB_USERNAME', isset($_SERVER['PORTAL_DB_USERNAME'])?$_SERVER['PORTAL_DB_USERNAME']:'crazystairs'),
'password' => env('PORTAL_DB_PASSWORD', isset($_SERVER['PORTAL_DB_PASSWORD'])?$_SERVER['PORTAL_DB_PASSWORD']:'crazystairs'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
Expand Down Expand Up @@ -108,8 +109,9 @@

'migrations' => 'migrations',

'full_seed' => env('FULL_SEED',false), /* Run Portal DB seed in full/abridged mode -- faster but less complete */
'download_images' => env('DOWNLOAD_IMAGES',false), /* Download Images from Portal S3 Bucket */
// This is specifically for running a migration from legacy myBinghamton database. Will be removed.
'full_seed' => env('FULL_SEED',isset($_SERVER['FULL_SEED'])?$_SERVER['FULL_SEED']:false), /* Run Portal DB seed in full/abridged mode -- faster but less complete */
'download_images' => env('DOWNLOAD_IMAGES',isset($_SERVER['DOWNLOAD_IMAGES'])?$_SERVER['DOWNLOAD_IMAGES']:false), /* Download Images from Portal S3 Bucket */

/*
|--------------------------------------------------------------------------
Expand Down

0 comments on commit 1d662e0

Please sign in to comment.