示例#1
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     set_time_limit(0);
     \Log::debug('Set PHP time limit to zero (no limit)');
     //Create the Duo Admin Client and set the timeout higher than default
     $duoAdmin = new DuoAdmin();
     $duoAdmin->setRequesterOption('timeout', '6000000');
     \Log::debug('Created new DuoAdmin object', [$duoAdmin]);
     $response = $duoAdmin->groups();
     $groups = $response['response']['response'];
     \Log::debug('Obtained Groups from Duo API - ', [count($groups)]);
     //Loop Duo Groups
     foreach ($groups as $group) {
         \Log::debug('Processing Duo Group', [$group]);
         //Get an existing Duo Group or create a new one
         $duoGroup = Group::firstOrCreate(['group_id' => $group['group_id']]);
         //Update Duo Group Settings
         $duoGroup->name = $group['name'];
         $duoGroup->desc = $group['desc'];
         $duoGroup->status = $group['status'];
         $duoGroup->mobile_otp_enabled = $group['mobile_otp_enabled'];
         $duoGroup->push_enabled = $group['push_enabled'];
         $duoGroup->sms_enabled = $group['sms_enabled'];
         $duoGroup->voice_enabled = $group['voice_enabled'];
         //Save Duo Group
         $duoGroup->touch();
         $duoGroup->save();
     }
     \Log::debug('Completed FetchDuoGroups Job');
 }
示例#2
0
 /**
  * @param $id
  * @return \BladeView|bool|\Illuminate\View\View
  */
 public function showUser($id)
 {
     $user = DuoUser::find($id);
     $reports = Report::where('name', 'like', '%duo%')->get();
     $groups = Group::all();
     return view('duo.show', compact('user', 'reports', 'groups'));
 }
示例#3
0
 /**
  * @param $user
  */
 private function extractUserData($user)
 {
     \Log::debug('Extracting Data for user - ', [$user]);
     // Get an existing Duo User or create a new one
     $duoUser = User::where(['user_id' => $user['user_id']])->withTrashed()->first() ?: new User(['user_id' => $user['user_id']]);
     // If this user was somehow previously trashed then restore the account
     if ($duoUser->trashed()) {
         $duoUser->restore();
     }
     \Log::debug('Local DuoUser found or created - ', [$duoUser]);
     //Update Duo User specific fields
     $duoUser->username = $user['username'];
     $duoUser->email = $user['email'];
     $duoUser->status = $user['status'];
     $duoUser->realname = $user['realname'];
     $duoUser->notes = $user['notes'];
     $duoUser->last_login = $user['last_login'];
     //Save Duo User
     $duoUser->touch();
     $duoUser->save();
     \Log::debug('Local DuoUser saved - ', [$duoUser]);
     if (count($user['tokens']) > 0) {
         \Log::debug('This user has tokens registered - ', [$user['tokens']]);
         //Loop Duo User Desktop Tokens
         $tokenList = [];
         foreach ($user['tokens'] as $token) {
             $localToken = Token::firstOrCreate(['serial' => $token['serial'], 'token_id' => $token['token_id'], 'totp_step' => $token['totp_step'], 'type' => $token['type']]);
             $tokenList[] = $localToken->id;
         }
         $duoUser->duoTokens()->sync($tokenList);
         \Log::debug('Finished Processing User tokens');
         unset($tokenList);
     }
     //Get the Duo groups that the user is assigned to
     //in UC Insight for reporting purposes
     $userGroupList = $duoUser->duoGroups()->wherePivot('duo_assigned', false)->lists('id')->toArray();
     \Log::debug('Syncing Duo User groups ', [$userGroupList]);
     //Loop Duo-assigned User Groups
     foreach ($user['groups'] as $group) {
         //Get the ID of the group that was created
         //locally during the Duo Group sync
         $localGroup = Group::where('group_id', $group['group_id'])->first();
         //Set the duo_assigned attribute to true
         //since we got this pairing from the Duo API
         $userGroupList[$localGroup->id] = ['duo_assigned' => true];
     }
     $duoUser->duoGroups()->sync($userGroupList);
     \Log::debug('Finished Processing User Groups');
     unset($userGroupList);
     //Hand off to process the Duo User phone data
     $this->extractUserPhoneData($duoUser, $user);
     \Log::debug('Completed User data extraction process', [$duoUser]);
 }