| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- function ssoCheck($username, $password, $token=null){
- $test = '';
- if($GLOBALS['ssoPlex'] && $token){
- coookie('set','mpt',$token,7);
- }
- if($GLOBALS['ssoOmbi']){
- $ombiToken = getOmbiToken($username, $password);
- if($ombiToken){
- coookie('set','Auth',$ombiToken,7, false);
- }
- }
- if($GLOBALS['ssoTautulli']){
- $tautulliToken = getTautulliToken($username, $password);
- if($tautulliToken){
- coookie('set','tautulli_token_'.$tautulliToken['uuid'],$tautulliToken['token'],7, false);
- }
- }
- return true;
- }
- function getOmbiToken($username, $password){
- try{
- $url = $GLOBALS['ombiURL'].'/api/v1/Token';
- $token = null;
- $headers = array(
- "Accept" => "application/json",
- "Content-Type" => "application/json"
- );
- $data = array(
- "username" => $username,
- "password" => $password,
- "rememberMe" => "true",
- );
- $options = (localURL($url)) ? array('verify' => false ) : array();
- $response = Requests::post($url, $headers, json_encode($data), $options);
- if($response->success){
- $token = json_decode($response->body, true)['access_token'];
- }
- return ($token) ? $token : false;
- }catch( Requests_Exception $e ) {
- writeLog('success', 'Ombi Token Function - Error: '.$e->getMessage(), $username);
- };
- }
- function getTautulliToken($username, $password){
- try{
- $url = $GLOBALS['tautulliURL'].'/auth/signin';
- $token = null;
- $headers = array(
- "Accept" => "application/json",
- "Content-Type" => "application/x-www-form-urlencoded"
- );
- $data = array(
- "username" => $username,
- "password" => $password,
- "remember_me" => 1,
- );
- $options = (localURL($url)) ? array('verify' => false ) : array();
- $response = Requests::post($url, $headers, $data, $options);
- if($response->success){
- $token['token'] = json_decode($response->body, true)['token'];
- $token['uuid'] = json_decode($response->body, true)['uuid'];
- }
- return ($token) ? $token : false;
- }catch( Requests_Exception $e ) {
- writeLog('success', 'Tautulli Token Function - Error: '.$e->getMessage(), $username);
- };
- }
|