Example #1
0
<?php

switch ($_SERVER['REQUEST_METHOD']) {
    case 'GET':
        $G_PUBLISH = new Publisher();
        $tpl = array_key_exists('l', $_GET) ? 'oauth2/registration_done' : 'oauth2/register';
        $G_PUBLISH->AddContent('view', $tpl);
        G::RenderPage('publish', 'minimal');
        break;
    case 'POST':
        $data = $_POST['form'];
        $clientId = G::generateCode(32, 'ALPHA');
        $secret = G::generateUniqueID();
        $client = new OauthClients();
        $client->setClientId($clientId);
        $client->setClientSecret($secret);
        $client->setClientName($data['name']);
        $client->setClientDescription($data['description']);
        $client->setClientWebsite($data['web_site']);
        $client->setRedirectUri($data['callback_url']);
        $client->setUsrUid($_SESSION['USER_LOGGED']);
        $client->save();
        $data['clientId'] = $clientId;
        $data['secret'] = $secret;
        header('location: register?l=' . base64_encode(json_encode($data)));
        break;
}
Example #2
0
    public function checkMafeRequirements ($workspace,$lang) {

        $this->initPropel(true);

        $pmRestClient = OauthClientsPeer::retrieveByPK('x-pm-local-client');

        if (empty($pmRestClient)) {

            if (!is_file(PATH_DATA . 'sites/' . $workspace . '/' . '.server_info')) {

                $_CSERVER = $_SERVER;

                unset($_CSERVER['REQUEST_TIME']);

                unset($_CSERVER['REMOTE_PORT']);

                $cput = serialize($_CSERVER);

                file_put_contents(PATH_DATA . 'sites/' . $workspace . '/' . '.server_info', $cput);

            }

            if (is_file(PATH_DATA . 'sites/' . $workspace . '/' . '.server_info')) {

                $SERVER_INFO = file_get_contents(PATH_DATA . 'sites/' . $workspace . '/'.'.server_info');

                $SERVER_INFO = unserialize($SERVER_INFO);



                $envFile = PATH_CONFIG . 'env.ini';

                $skin ='neoclassic';

                if (file_exists($envFile) ) {

                    $sysConf = System::getSystemConfiguration($envFile);

                    $lang = $sysConf['default_lang'];

                    $skin = $sysConf['default_skin'];

                }



                $endpoint = sprintf(

                    '%s/sys%s/%s/%s/oauth2/grant',

                    isset($SERVER_INFO['HTTP_ORIGIN']) ? $SERVER_INFO['HTTP_ORIGIN'] : '',

                    $workspace,

                    $lang,

                    $skin

                );



                $oauthClients = new OauthClients();

                $oauthClients->setClientId('x-pm-local-client');

                $oauthClients->setClientSecret('179ad45c6ce2cb97cf1029e212046e81');

                $oauthClients->setClientName('PM Web Designer');

                $oauthClients->setClientDescription('ProcessMaker Web Designer App');

                $oauthClients->setClientWebsite('www.processmaker.com');

                $oauthClients->setRedirectUri($endpoint);

                $oauthClients->save();

            } else {

                eprintln("WARNING! No server info found!", 'red');

            }

        }

    }
Example #3
0
 public function registerPMDesignerClient()
 {
     $result = array();
     try {
         $pmRestClient = OauthClientsPeer::retrieveByPK('x-pm-local-client');
         if (!empty($pmRestClient)) {
             $pmRestClient->delete();
         }
         $http = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
         $lang = defined('SYS_LANG') ? SYS_LANG : 'en';
         $host = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : '');
         $endpoint = sprintf('%s://%s/sys%s/%s/%s/oauth2/grant', $http, $host, SYS_SYS, $lang, SYS_SKIN);
         $oauthClients = new OauthClients();
         $oauthClients->setClientId('x-pm-local-client');
         $oauthClients->setClientSecret('179ad45c6ce2cb97cf1029e212046e81');
         $oauthClients->setClientName('PM Web Designer');
         $oauthClients->setClientDescription('ProcessMaker Web Designer App');
         $oauthClients->setClientWebsite('www.processmaker.com');
         $oauthClients->setRedirectUri($endpoint);
         $oauthClients->save();
         $result['success'] = true;
         $result['message'] = '';
     } catch (Exception $e) {
         $result['success'] = false;
         $result['message'] = $e->getMessage();
     }
     return $result;
 }